Initial project template
This commit is contained in:
12
apps/api/src/app/app.controller.ts
Normal file
12
apps/api/src/app/app.controller.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { Controller, Get } from '@nestjs/common';
|
||||
import { AppService } from './app.service';
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
constructor(private readonly appService: AppService) {}
|
||||
|
||||
@Get()
|
||||
getData() {
|
||||
return this.appService.getData();
|
||||
}
|
||||
}
|
||||
10
apps/api/src/app/app.module.ts
Normal file
10
apps/api/src/app/app.module.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule {}
|
||||
15
apps/api/src/app/app.service.ts
Normal file
15
apps/api/src/app/app.service.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { prisma } from '@shared/prisma-generated/src/prisma'
|
||||
import { Post } from '@shared/prisma-generated/src/types'
|
||||
|
||||
@Injectable()
|
||||
export class AppService {
|
||||
|
||||
getData(): { message: string } {
|
||||
return { message: 'Hello API' };
|
||||
}
|
||||
|
||||
async getAllPosts(): Promise<Post[]> {
|
||||
return prisma.post.findMany();
|
||||
}
|
||||
}
|
||||
0
apps/api/src/assets/.gitkeep
Normal file
0
apps/api/src/assets/.gitkeep
Normal file
21
apps/api/src/main.ts
Normal file
21
apps/api/src/main.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* This is not a production server yet!
|
||||
* This is only a minimal backend to get started.
|
||||
*/
|
||||
|
||||
import { Logger } from '@nestjs/common';
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { AppModule } from './app/app.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
const globalPrefix = 'api';
|
||||
app.setGlobalPrefix(globalPrefix);
|
||||
const port = process.env.PORT || 3000;
|
||||
await app.listen(port);
|
||||
Logger.log(
|
||||
`🚀 Application is running on: http://localhost:${port}/${globalPrefix}`,
|
||||
);
|
||||
}
|
||||
|
||||
bootstrap();
|
||||
Reference in New Issue
Block a user