初始化NestAPI模板
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
|
||||
import { WelcomeController } from '@/modules/welcome/welcome.controller';
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
controllers: [WelcomeController],
|
||||
providers: [],
|
||||
})
|
||||
export class AppModule {}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify';
|
||||
|
||||
import { AppModule } from '@/app.module';
|
||||
|
||||
const bootstrap = async () => {
|
||||
const app = await NestFactory.create<NestFastifyApplication>(AppModule, new FastifyAdapter(), {
|
||||
cors: true,
|
||||
logger: ['error', 'warn'],
|
||||
});
|
||||
|
||||
await app.listen(2333, () => {
|
||||
console.log('api: http://localhost:2333');
|
||||
});
|
||||
};
|
||||
|
||||
bootstrap();
|
||||
@@ -0,0 +1,12 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
|
||||
/**
|
||||
* 欢迎访问 Ink NestJS API
|
||||
*/
|
||||
@Controller()
|
||||
export class WelcomeController {
|
||||
@Get()
|
||||
getMessage(): string {
|
||||
return '访问 ink nestjs api, 了解更多 请联系邮箱 youzegehq@gmail.com';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user