feat(01-01): NestJS API with health endpoint and Prisma schema

- NestJS app with ConfigModule and HealthModule
- GET /health endpoint returning {status, timestamp} using HealthResponse type
- Prisma schema with PostgreSQL datasource and Tenant model (multi-tenancy foundation)
- Multi-stage Dockerfile with non-root nestjs user, monorepo root as build context
- Workspace dependency on @tessera/shared for shared types
- Type-check passes successfully
This commit is contained in:
2026-06-18 10:04:08 +02:00
parent b75d7c3b58
commit 04c78b4bdc
10 changed files with 3195 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
FROM node:24-alpine AS base
RUN corepack enable && corepack prepare pnpm@9 --activate
FROM base AS deps
WORKDIR /app
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
COPY apps/api/package.json ./apps/api/
COPY packages/shared/package.json ./packages/shared/
RUN pnpm install --frozen-lockfile --filter=@tessera/api...
FROM base AS builder
WORKDIR /app
COPY --from=deps /app/ ./
COPY apps/api/ ./apps/api/
COPY packages/shared/ ./packages/shared/
COPY tsconfig.base.json ./
RUN pnpm --filter=@tessera/api build
FROM node:24-alpine AS runner
WORKDIR /app
ENV NODE_ENV=production
RUN addgroup --system --gid 1001 nestjs && \
adduser --system --uid 1001 nestjs
COPY --from=builder /app/apps/api/dist ./dist
COPY --from=builder /app/apps/api/node_modules ./node_modules
COPY --from=builder /app/apps/api/package.json ./
COPY --from=builder /app/node_modules/.pnpm ./node_modules/.pnpm
USER nestjs
EXPOSE 3001
CMD ["node", "dist/main.js"]
+8
View File
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
}
}
+28
View File
@@ -0,0 +1,28 @@
{
"name": "@tessera/api",
"version": "0.0.1",
"private": true,
"scripts": {
"build": "nest build",
"start": "node dist/main.js",
"start:dev": "nest start --watch",
"type-check": "tsc --noEmit"
},
"dependencies": {
"@nestjs/core": "^11.0.0",
"@nestjs/common": "^11.0.0",
"@nestjs/platform-express": "^11.0.0",
"@nestjs/config": "^4.0.0",
"rxjs": "^7.0.0",
"reflect-metadata": "^0.2.0",
"@prisma/client": "^6.0.0",
"@tessera/shared": "workspace:*"
},
"devDependencies": {
"prisma": "^6.0.0",
"@nestjs/cli": "^11.0.0",
"typescript": "^5.5.0",
"@types/node": "^22.0.0",
"@types/express": "^5.0.0"
}
}
+16
View File
@@ -0,0 +1,16 @@
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
generator client {
provider = "prisma-client-js"
}
model Tenant {
id String @id @default(uuid())
name String
slug String @unique
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
+11
View File
@@ -0,0 +1,11 @@
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { HealthModule } from './health/health.module';
@Module({
imports: [
ConfigModule.forRoot({ isGlobal: true }),
HealthModule,
],
})
export class AppModule {}
+13
View File
@@ -0,0 +1,13 @@
import { Controller, Get } from '@nestjs/common';
import type { HealthResponse } from '@tessera/shared';
@Controller('health')
export class HealthController {
@Get()
check(): HealthResponse {
return {
status: 'ok',
timestamp: new Date().toISOString(),
};
}
}
+7
View File
@@ -0,0 +1,7 @@
import { Module } from '@nestjs/common';
import { HealthController } from './health.controller';
@Module({
controllers: [HealthController],
})
export class HealthModule {}
+13
View File
@@ -0,0 +1,13 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.enableCors({ origin: true });
await app.listen(3001);
console.log('Tessera API running on port 3001');
}
bootstrap();
+14
View File
@@ -0,0 +1,14 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"target": "ES2021",
"outDir": "./dist",
"rootDir": "./src",
"emitDecoratorMetadata": true,
"experimentalDecorators": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
+3055
View File
File diff suppressed because it is too large Load Diff