change express to fastify

This commit is contained in:
liuyi 2025-05-11 22:27:51 +08:00
parent 66da3530bf
commit 840590cad6
3 changed files with 589 additions and 129 deletions

View File

@ -23,7 +23,11 @@
"dependencies": {
"@nestjs/common": "^10.0.3",
"@nestjs/core": "^10.0.3",
"@nestjs/platform-express": "^10.0.3",
"@nestjs/platform-fastify": "^10.0.3",
"@nestjs/swagger": "^7.0.4",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.2",
"lodash": "^4.17.21",
"reflect-metadata": "^0.1.13",
"rimraf": "^5.0.1",
"rxjs": "^7.8.1"
@ -34,8 +38,8 @@
"@nestjs/testing": "^10.0.3",
"@swc/cli": "^0.1.62",
"@swc/core": "^1.3.66",
"@types/express": "^4.17.17",
"@types/jest": "29.5.2",
"@types/lodash": "^4.17.16",
"@types/node": "^20.3.1",
"@types/supertest": "^2.0.12",
"@typescript-eslint/eslint-plugin": "^5.60.0",

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,17 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
await app.listen(process.env.PORT ?? 3000);
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter(), {
cors: true,
logger: ['error', 'warn'],
});
app.setGlobalPrefix('api');
await app.listen(process.env.PORT ?? 3000, () => {
console.log('api: http://localhost:3000');
});
}
bootstrap();