feat: scaffold monorepo with shared types and NestJS server
- pnpm workspace with packages/app, packages/server, packages/shared - @mp-pilates/shared: enums, constants, TypeScript interfaces for all 8 data models - @mp-pilates/server: NestJS bootstrap with health check, validation pipe, CORS - Base TypeScript config with strict mode
This commit is contained in:
9
packages/server/src/app.controller.ts
Normal file
9
packages/server/src/app.controller.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { Controller, Get } from '@nestjs/common'
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
@Get('health')
|
||||
health() {
|
||||
return { status: 'ok', timestamp: new Date().toISOString() }
|
||||
}
|
||||
}
|
||||
14
packages/server/src/app.module.ts
Normal file
14
packages/server/src/app.module.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { Module } from '@nestjs/common'
|
||||
import { ConfigModule } from '@nestjs/config'
|
||||
import { AppController } from './app.controller'
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot({
|
||||
isGlobal: true,
|
||||
envFilePath: ['.env.local', '.env'],
|
||||
}),
|
||||
],
|
||||
controllers: [AppController],
|
||||
})
|
||||
export class AppModule {}
|
||||
24
packages/server/src/main.ts
Normal file
24
packages/server/src/main.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { NestFactory } from '@nestjs/core'
|
||||
import { ValidationPipe } from '@nestjs/common'
|
||||
import { ConfigService } from '@nestjs/config'
|
||||
import { AppModule } from './app.module'
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule)
|
||||
const configService = app.get(ConfigService)
|
||||
|
||||
app.setGlobalPrefix('api')
|
||||
app.useGlobalPipes(
|
||||
new ValidationPipe({
|
||||
whitelist: true,
|
||||
forbidNonWhitelisted: true,
|
||||
transform: true,
|
||||
}),
|
||||
)
|
||||
app.enableCors()
|
||||
|
||||
const port = configService.get<number>('PORT', 3000)
|
||||
await app.listen(port)
|
||||
console.log(`Server running on http://localhost:${port}`)
|
||||
}
|
||||
bootstrap()
|
||||
Reference in New Issue
Block a user