Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"integ"
],
"console": "integratedTerminal",
"envFile": "${workspaceFolder}/apps/server/.env.integ",
"restart": true,
"presentation": {
"hidden": true
Expand All @@ -39,6 +40,7 @@
"dev"
],
"console": "integratedTerminal",
"envFile": "${workspaceFolder}/apps/server/.env",
"restart": true,
"presentation": {
"hidden": true
Expand Down Expand Up @@ -100,6 +102,7 @@
"run",
"start:dev"
],
"envFile": "${workspaceFolder}/apps/server-nestjs/.env.integ",
"console": "integratedTerminal",
"restart": true,
"presentation": {
Expand All @@ -123,6 +126,7 @@
"start:dev"
],
"console": "integratedTerminal",
"envFile": "${workspaceFolder}/apps/server-nestjs/.env",
"restart": true,
"presentation": {
"hidden": true
Expand Down
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Plugins use TS module augmentation to extend `ProjectStore` and `Config` interfa

## Database (Prisma)

Multi-file schema in `apps/server/src/prisma/schema/*.prisma` (project, user, token, admin, topography).
Multi-file schema in `packages/database/prisma/schema/*.prisma` (project, user, token, admin, topography).
Migrations: standard Prisma Migrate. Major version data migrations in `migrations/v9/`.

## Environment config
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ Maintenant que vous avez les prérequis projets (prérequis techniques et de con
# Installer toutes les dépendances
$ pnpm install

# Initialiser la base de données PostgreSQL lancée localement
$ pnpm db:generate

# Construire les applications client et server
$ pnpm build

Expand Down Expand Up @@ -117,9 +114,6 @@ pnpm install
# Créer les fichiers d'environnement exemples
./ci/scripts/init-env.sh

# Générer le client Prisma côté serveur
pnpm --filter @cpn-console/server run db:generate

# Construire tous les paquets applicatifs
pnpm build
```
Expand Down
3 changes: 2 additions & 1 deletion apps/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"lint:ts": "NODE_OPTIONS='--no-warnings=ExperimentalWarning' eslint ./",
"preview": "vite preview --port 8080",
"test": "vitest run",
"test:cov": "vitest run --coverage",
"test:cov": "pnpm run test --coverage",
"test:watch": "pnpm run test --watch",
"type-check": "vue-tsc --noEmit -p tsconfig.json"
},
"dependencies": {
Expand Down
12 changes: 5 additions & 7 deletions apps/server-nestjs/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ COPY --chown=node:root apps/server-nestjs/package.json ./apps/server-n
COPY --chown=node:root packages/eslintconfig/package.json ./packages/eslintconfig/package.json
COPY --chown=node:root packages/shared/package.json ./packages/shared/package.json
COPY --chown=node:root packages/logger/package.json ./packages/logger/package.json
COPY --chown=node:root packages/database/package.json ./packages/database/package.json
COPY --chown=node:root packages/hooks/package.json ./packages/hooks/package.json
COPY --chown=node:root packages/test-utils/package.json ./packages/test-utils/package.json
COPY --chown=node:root packages/tsconfig/package.json ./packages/tsconfig/package.json
Expand Down Expand Up @@ -48,18 +49,18 @@ RUN pnpm --filter @cpn-console/hooks run build
# Réinjecter les libs buildées dans node_modules (injectWorkspacePackages copie au moment de l'install)
RUN pnpm --filter @cpn-console/server-nestjs install --frozen-lockfile

# Générer le client Prisma (schéma multi-fichiers : pointer sur le dossier)
RUN pnpm --filter @cpn-console/server-nestjs exec prisma generate \
--schema=src/prisma/schema
# Générer le client Prisma depuis le package partagé
RUN pnpm --filter @cpn-console/database run generate

ENTRYPOINT ["pnpm", "--filter", "server-nestjs", "run"]
ENTRYPOINT ["pnpm", "--filter", "@cpn-console/server-nestjs", "run"]
CMD ["start:dev"]

# Build stage ----------------------------------------------------------------------
FROM dev AS build

# Build shared (génère dist/ et types/)
RUN pnpm --filter @cpn-console/logger run build
RUN pnpm --filter @cpn-console/database run build
RUN pnpm --filter @cpn-console/shared run build

# Build hooks (génère dist/ et types/ nécessaires aux imports)
Expand Down Expand Up @@ -90,11 +91,8 @@ RUN mkdir -p /home/node/logs && chmod 770 -R /home/node/logs \
# Copier l'artefact de build et les node_modules de production
COPY --chown=node:root --from=build /app/build .
COPY --chown=node:root --from=build /app/apps/server-nestjs/dist ./dist
# COPY --chown=node:root --from=build /app/build/node_modules ./node_modules

# Regénérer le client Prisma dans l'image de production
RUN npm run db:generate

USER node
EXPOSE 3001

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ module.exports = { findById, create };
import { Injectable, NotFoundException } from '@nestjs/common';
import { PrismaService } from '../prisma/prisma.service';
import { CreateUserDto } from './dto/create-user.dto';
import { User } from '@prisma/client';
import { User } from '@cpn-console/database';

@Injectable()
export class UsersService {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

- Le nginx existant dans l'image `client` proxifiait directement vers `server:8080` — upstream changé vers `nginx-strangler:8080`
- `server-nestjs/src/main.ts` utilisait `process.env.PORT ?? 0` au lieu de `ConfigurationService.port` — corrigé
- Le schéma Prisma de `server-nestjs` est multi-fichiers dans `src/prisma/schema/` — `prisma generate` doit pointer sur le dossier, pas sur `schema.prisma`
- Le schéma Prisma est multi-fichiers dans `packages/database/prisma/schema/` — `prisma generate` doit pointer sur le dossier, pas sur `schema.prisma`
- En CI (`job-lint.yml`), `nginx -t` échoue si `apt-get update -qq` n'est pas exécuté avant l'install, et si les chemins `pid`/`error_log`/`access_log` ne sont pas patchés vers `/tmp/` (runner non-root)
- En CI (`job-playwright.yml`), les images `server-nestjs:ci` et `nginx-strangler:ci` doivent être buildées localement avant le `docker compose up --no-build` (même pattern que `opencds-mockoon`)

Expand Down Expand Up @@ -134,7 +134,7 @@ location = /api/v1/system/health {

### Tâche 2.2 : Créer `apps/server-nestjs/Dockerfile` ✅

Multi-stage : `base` → `deps` → `build` → `prod`. `prisma generate --schema=src/prisma/schema` (dossier multi-fichiers). `USER node`, `HEALTHCHECK`, `EXPOSE 3001`.
Multi-stage : `base` → `deps` → `build` → `prod`. `pnpm --filter @cpn-console/database run generate` (schéma multi-fichiers). `USER node`, `HEALTHCHECK`, `EXPOSE 3001`.

### Tâche 2.3 : `apps/server-nestjs/.env.docker-example` ✅

Expand Down
20 changes: 8 additions & 12 deletions apps/server-nestjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,23 @@
"url": "https://github.com/cloud-pi-native/console"
},
"scripts": {
"prebuild": "pnpm --filter @cpn-console/database run generate",
"build": "nest build",
"db:generate": "prisma generate",
"db:migrate": "prisma migrate dev --name dso",
"db:reset": "prisma migrate reset",
"format": "eslint ./ --fix",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"prestart": "pnpm --filter @cpn-console/database run migrate",
"start": "nest start",
"start:debug": "nest start --debug --watch",
"start:dev": "nest start --watch",
"start:debug": "pnpm run start --debug --watch",
"start:dev": "pnpm run start --watch",
"start:prod": "node dist/main",
"pretest": "pnpm run db:generate",
"pretest": "pnpm --filter @cpn-console/database run generate",
"test": "vitest run",
"test:watch": "vitest",
"pretest:cov": "pnpm run db:generate",
"test:cov": "vitest run --coverage",
"test:debug": "vitest --inspect"
"test:cov": "pnpm run test --coverage",
"test:watch": "pnpm run test --watch"
},
"dependencies": {
"@cpn-console/argocd-plugin": "workspace:^",
"@cpn-console/database": "workspace:^",
"@cpn-console/gitlab-plugin": "workspace:^",
"@cpn-console/harbor-plugin": "workspace:^",
"@cpn-console/hooks": "workspace:^",
Expand Down Expand Up @@ -65,7 +63,6 @@
"@opentelemetry/sdk-metrics": "^2.5.1",
"@opentelemetry/sdk-node": "^0.212.0",
"@opentelemetry/sdk-trace-node": "^2.5.1",
"@prisma/client": "^6.19.2",
"@ts-rest/core": "^3.52.1",
"@ts-rest/fastify": "^3.52.1",
"@ts-rest/open-api": "^3.52.1",
Expand All @@ -76,7 +73,6 @@
"mustache": "^4.2.0",
"nestjs-pino": "^4.6.0",
"pino-http": "^11.0.0",
"prisma": "^6.19.2",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.2",
"undici": "^7.24.0",
Expand Down
23 changes: 0 additions & 23 deletions apps/server-nestjs/prisma.config.ts

This file was deleted.

2 changes: 1 addition & 1 deletion apps/server-nestjs/src/__mocks__/prisma.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { PrismaClient } from '@prisma/client'
import type { PrismaClient } from '@cpn-console/database'
import { beforeEach, vi } from 'vitest'
import { mockDeep, mockReset } from 'vitest-mock-extended'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Prisma } from '@prisma/client'
import type { Prisma } from '@cpn-console/database'
import { Inject, Injectable } from '@nestjs/common'
import { PrismaService } from '../infrastructure/database/prisma.service'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Prisma } from '@prisma/client'
import type { Prisma } from '@cpn-console/database'
import { Inject, Injectable } from '@nestjs/common'
import { PrismaService } from '../infrastructure/database/prisma.service'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ export class ConfigurationService {
? process.env.NEXUS_INTERNAL_URL
: process.env.NEXUS_URL

// sonarqube
sonarqubeUrl = process.env.SONARQUBE_URL
sonarqubeInternalUrl = process.env.SONARQUBE_INTERNAL_URL
sonarApiToken = process.env.SONAR_API_TOKEN

getInternalOrPublicGitlabUrl() {
return this.gitlabInternalUrl ?? this.gitlabUrl
}
Expand All @@ -106,6 +111,10 @@ export class ConfigurationService {
return this.nexusInternalUrl ?? this.nexusUrl
}

getInternalOrPublicSonarqubeUrl() {
return this.sonarqubeInternalUrl ?? this.sonarqubeUrl
}

NODE_ENV
= process.env.NODE_ENV === 'test'
? 'test'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { OnModuleDestroy, OnModuleInit } from '@nestjs/common'
import { PrismaClient } from '@cpn-console/database'
import { Injectable } from '@nestjs/common'
import { PrismaClient } from '@prisma/client'

@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit, OnModuleDestroy {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Prisma } from '@prisma/client'
import type { Prisma } from '@cpn-console/database'
import { Inject, Injectable } from '@nestjs/common'
import { PrismaService } from '../infrastructure/database/prisma.service'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Prisma } from '@prisma/client'
import type { Prisma } from '@cpn-console/database'
import { Inject, Injectable } from '@nestjs/common'
import { PrismaService } from '../infrastructure/database/prisma.service'
import { NEXUS_PLUGIN_NAME } from './nexus.constants'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Prisma } from '@prisma/client'
import type { Prisma } from '@cpn-console/database'
import { Inject, Injectable } from '@nestjs/common'
import { PrismaService } from '../infrastructure/database/prisma.service'
import { REGISTRY_PLUGIN_NAME } from './registry.constants'
Expand Down
Loading
Loading