From ce5cf134ae065b84e4241ec646630f5ac5460d8c Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 20 Jul 2026 22:26:33 +0200 Subject: [PATCH] feat: scaffold NestJS API skeleton with health check --- .env.example | 9 +++++++++ .gitignore | 4 ++++ Dockerfile | 15 +++++++++++++++ README.md | 11 +++++++++++ nest-cli.json | 5 +++++ package.json | 27 +++++++++++++++++++++++++++ src/app.module.ts | 9 +++++++++ src/health/health.controller.ts | 9 +++++++++ src/main.ts | 12 ++++++++++++ tsconfig.json | 20 ++++++++++++++++++++ 10 files changed, 121 insertions(+) create mode 100644 .env.example create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 nest-cli.json create mode 100644 package.json create mode 100644 src/app.module.ts create mode 100644 src/health/health.controller.ts create mode 100644 src/main.ts create mode 100644 tsconfig.json diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..52e10cb --- /dev/null +++ b/.env.example @@ -0,0 +1,9 @@ +PORT=3000 + +# Supabase (CEO-OS project, Coolify) +DATABASE_URL=postgresql://postgres:CHANGE_ME@supabase-db:5432/postgres +SUPABASE_URL=http://supabasekong-to6mg3yxqit4ac9nl0otnvav.152.53.112.35.sslip.io:8000 +SUPABASE_SERVICE_ROLE_KEY= + +# Redis (ceo-os-redis, Coolify) +REDIS_URL=redis://default:CHANGE_ME@ceo-os-redis:6379/0 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa0926a --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +node_modules/ +dist/ +.env +*.log diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..327dc02 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM node:22-alpine AS build +WORKDIR /app +COPY package.json ./ +RUN npm install +COPY . . +RUN npm run build + +FROM node:22-alpine +WORKDIR /app +ENV NODE_ENV=production +COPY --from=build /app/node_modules ./node_modules +COPY --from=build /app/dist ./dist +COPY package.json ./ +EXPOSE 3000 +CMD ["node", "dist/main"] diff --git a/README.md b/README.md index ed1f698..9270145 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,13 @@ # ceo-api +NestJS API pentru CEO-OS. Se conecteaza la Supabase (Postgres/Auth) si Redis, deployat prin Coolify pe proiectul CEO-OS. + +## Dezvoltare + +```bash +npm install +cp .env.example .env +npm run start:dev +``` + +`GET /health` returneaza statusul serviciului. diff --git a/nest-cli.json b/nest-cli.json new file mode 100644 index 0000000..2566481 --- /dev/null +++ b/nest-cli.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://json.schemastore.org/nest-cli", + "collection": "@nestjs/schematics", + "sourceRoot": "src" +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..32e9470 --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "ceo-api", + "version": "0.1.0", + "description": "CEO-OS API (NestJS)", + "private": true, + "license": "UNLICENSED", + "scripts": { + "build": "nest build", + "start": "node dist/main", + "start:dev": "nest start --watch", + "lint": "eslint \"src/**/*.ts\"", + "test": "jest" + }, + "dependencies": { + "@nestjs/common": "^11.0.0", + "@nestjs/config": "^4.0.0", + "@nestjs/core": "^11.0.0", + "@nestjs/platform-express": "^11.0.0", + "reflect-metadata": "^0.2.2", + "rxjs": "^7.8.1" + }, + "devDependencies": { + "@nestjs/cli": "^11.0.0", + "@types/node": "^22.0.0", + "typescript": "^5.6.0" + } +} diff --git a/src/app.module.ts b/src/app.module.ts new file mode 100644 index 0000000..c4818a8 --- /dev/null +++ b/src/app.module.ts @@ -0,0 +1,9 @@ +import { Module } from '@nestjs/common'; +import { ConfigModule } from '@nestjs/config'; +import { HealthController } from './health/health.controller'; + +@Module({ + imports: [ConfigModule.forRoot({ isGlobal: true })], + controllers: [HealthController], +}) +export class AppModule {} diff --git a/src/health/health.controller.ts b/src/health/health.controller.ts new file mode 100644 index 0000000..0c9989a --- /dev/null +++ b/src/health/health.controller.ts @@ -0,0 +1,9 @@ +import { Controller, Get } from '@nestjs/common'; + +@Controller('health') +export class HealthController { + @Get() + check() { + return { status: 'ok', service: 'ceo-api', timestamp: new Date().toISOString() }; + } +} diff --git a/src/main.ts b/src/main.ts new file mode 100644 index 0000000..f075bb6 --- /dev/null +++ b/src/main.ts @@ -0,0 +1,12 @@ +import 'reflect-metadata'; +import { NestFactory } from '@nestjs/core'; +import { AppModule } from './app.module'; + +async function bootstrap() { + const app = await NestFactory.create(AppModule); + app.enableCors(); + const port = process.env.PORT ?? 3000; + await app.listen(port); +} + +bootstrap(); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..1a766ad --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "ES2022", + "moduleResolution": "node", + "declaration": false, + "removeComments": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "sourceMap": true, + "outDir": "./dist", + "baseUrl": "./", + "incremental": true, + "skipLibCheck": true, + "strict": true, + "strictNullChecks": true, + "noImplicitAny": true, + "esModuleInterop": true + } +}