diff --git a/apps/api/package.json b/apps/api/package.json index bac4595..186e0c8 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -7,10 +7,10 @@ "license": "UNLICENSED", "scripts": { "build": "nest build", - "start": "nest start", "dev": "nest start --exec \"node --env-file=.env\" --watch", - "start:debug": "nest start --debug --watch", - "start:prod": "node dist/main", + "start:old": "nest start --exec \"node --env-file=.env\"", + "start:debug": "nest start --debug --watch", + "start": "node --env-file=.env dist/src/main.js", "typecheck": "tsc --noEmit", "test": "jest", "test:watch": "jest --watch", @@ -32,6 +32,7 @@ "@nestjs/graphql": "^12.2.0", "@nestjs/passport": "^10.0.3", "@nestjs/platform-express": "^10.0.0", + "@nestjs/serve-static": "^4.0.2", "argon2": "^0.41.1", "cache-manager": "^6.1.0", "class-transformer": "^0.5.1", diff --git a/apps/api/src/app.module.ts b/apps/api/src/app.module.ts index 2eda15c..f2f2a67 100644 --- a/apps/api/src/app.module.ts +++ b/apps/api/src/app.module.ts @@ -4,6 +4,7 @@ import { Module } from "@nestjs/common"; import { ConfigModule } from "@nestjs/config"; import { APP_GUARD } from "@nestjs/core"; import { GraphQLModule } from "@nestjs/graphql"; +import { ServeStaticModule } from "@nestjs/serve-static"; import { Request, Response } from "express"; import { AppResolver } from "./app.resolver"; import { AppService } from "./app.service"; @@ -40,6 +41,10 @@ import { validate } from "./utils/env.validate"; database: String(process.env.POSTGRES_DB), }), AuthModule, + ServeStaticModule.forRoot({ + rootPath: join(__dirname, "../../..", "web", "dist"), + exclude: ["/api*", "/graphql*"], + }), ], providers: [ AppService, diff --git a/apps/web/package.json b/apps/web/package.json index 591beb4..6be708d 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -6,6 +6,7 @@ "scripts": { "dev": "vite", "build": "tsc -b && vite build", + "start": "pnpm run preview", "typecheck": "tsc -b --noEmit", "preview": "vite preview" }, diff --git a/docker-compose.yml b/docker-compose.yml index 432109e..086d338 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,37 +7,9 @@ services: - 5432:5432 env_file: - ./apps/api/.env - # environment: - # - POSTGRES_DB - # - POSTGRES_USER - # - POSTGRES_PASSWORD - - # db-test: - # image: postgres:14.1-alpine - # restart: always - # ports: - # - 5433:5432 - # environment: - # POSTGRES_DB: disworse-test - # POSTGRES_USER: postgres - # POSTGRES_PASSWORD: postgres - cache: image: redis container_name: cache restart: always ports: - 6379:6379 - - project: - image: node - working_dir: /app - ports: - - 3333:3333 - volumes: - - .:/app - command: sh -c "scripts/entrypoint.sh" - # command: cat "scripts/entrypoint.sh" - depends_on: - - cache - - pg diff --git a/package.json b/package.json index f3e6fa5..7be27a4 100644 --- a/package.json +++ b/package.json @@ -4,15 +4,22 @@ "scripts": { "preinstall": "npx only-allow pnpm", "build": "turbo build", - "dev": "turbo dev", + "build:web": "turbo build --filter web", + "build:api": "turbo build --filter api", + "dev": "pnpm run compose:up && turbo dev", + "dev:web": "turbo dev --filter web", + "dev:api": "pnpm run compose:up && turbo dev --filter api", + "start": "pnpm run compose:up && turbo build && turbo start --filter api", + "start:web": "pnpm run build:web && turbo start --filter web", + "start:api": "pnpm run compose:up && pnpm run build:api && turbo start --filter api", + "compose:up": "docker compose -f docker-compose.dev.yml up -d --build", + "compose:down": "docker compose down -v", "typecheck": "turbo typecheck", "lint": "biome check .", "lint:fix": "biome check . --write", "lint:fix:unsafe": "biome check . --write --unsafe", "prepare": "husky", - "commitlint": "commitlint --edit", - "compose:up": "docker compose -f docker-compose.dev.yml up -d --build", - "compose:down": "docker compose down -v" + "commitlint": "commitlint --edit" }, "lint-staged": { "**/*": ["biome check . --write"] diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f95f19a..7ab80f4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -59,6 +59,9 @@ importers: '@nestjs/platform-express': specifier: ^10.0.0 version: 10.4.4(@nestjs/common@10.4.4(class-transformer@0.5.1)(class-validator@0.14.1)(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.4) + '@nestjs/serve-static': + specifier: ^4.0.2 + version: 4.0.2(@nestjs/common@10.4.4(class-transformer@0.5.1)(class-validator@0.14.1)(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.4(@nestjs/common@10.4.4(class-transformer@0.5.1)(class-validator@0.14.1)(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.4)(reflect-metadata@0.2.2)(rxjs@7.8.1))(express@4.21.0) argon2: specifier: ^0.41.1 version: 0.41.1 @@ -1583,6 +1586,22 @@ packages: peerDependencies: typescript: '>=4.8.2' + '@nestjs/serve-static@4.0.2': + resolution: {integrity: sha512-cT0vdWN5ar7jDI2NKbhf4LcwJzU4vS5sVpMkVrHuyLcltbrz6JdGi1TfIMMatP2pNiq5Ie/uUdPSFDVaZX/URQ==} + peerDependencies: + '@fastify/static': ^6.5.0 || ^7.0.0 + '@nestjs/common': ^9.0.0 || ^10.0.0 + '@nestjs/core': ^9.0.0 || ^10.0.0 + express: ^4.18.1 + fastify: ^4.7.0 + peerDependenciesMeta: + '@fastify/static': + optional: true + express: + optional: true + fastify: + optional: true + '@nestjs/testing@10.4.4': resolution: {integrity: sha512-qRGFj51A5RM7JqA8pcyEwSLA3Y0dle/PAZ8oxP0suimoCusRY3Tk7wYqutZdCNj1ATb678SDaUZDHk2pwSv9/g==} peerDependencies: @@ -4243,6 +4262,9 @@ packages: path-to-regexp@0.1.10: resolution: {integrity: sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==} + path-to-regexp@0.2.5: + resolution: {integrity: sha512-l6qtdDPIkmAmzEO6egquYDfqQGPMRNGjYtrU13HAXb3YSRrt7HSb1sJY0pKp6o2bAa86tSB6iwaW2JbthPKr7Q==} + path-to-regexp@3.3.0: resolution: {integrity: sha512-qyCH421YQPS2WFDxDjftfc1ZR5WKQzVzqsp4n9M2kQhVOo/ByahFoUNJfl58kOcEGfQ//7weFTDhm+ss8Ecxgw==} @@ -6595,6 +6617,14 @@ snapshots: transitivePeerDependencies: - chokidar + '@nestjs/serve-static@4.0.2(@nestjs/common@10.4.4(class-transformer@0.5.1)(class-validator@0.14.1)(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.4(@nestjs/common@10.4.4(class-transformer@0.5.1)(class-validator@0.14.1)(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.4)(reflect-metadata@0.2.2)(rxjs@7.8.1))(express@4.21.0)': + dependencies: + '@nestjs/common': 10.4.4(class-transformer@0.5.1)(class-validator@0.14.1)(reflect-metadata@0.2.2)(rxjs@7.8.1) + '@nestjs/core': 10.4.4(@nestjs/common@10.4.4(class-transformer@0.5.1)(class-validator@0.14.1)(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.4)(reflect-metadata@0.2.2)(rxjs@7.8.1) + path-to-regexp: 0.2.5 + optionalDependencies: + express: 4.21.0 + '@nestjs/testing@10.4.4(@nestjs/common@10.4.4(class-transformer@0.5.1)(class-validator@0.14.1)(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.4(@nestjs/common@10.4.4(class-transformer@0.5.1)(class-validator@0.14.1)(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.4)(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/platform-express@10.4.4(@nestjs/common@10.4.4(class-transformer@0.5.1)(class-validator@0.14.1)(reflect-metadata@0.2.2)(rxjs@7.8.1))(@nestjs/core@10.4.4))': dependencies: '@nestjs/common': 10.4.4(class-transformer@0.5.1)(class-validator@0.14.1)(reflect-metadata@0.2.2)(rxjs@7.8.1) @@ -9410,6 +9440,8 @@ snapshots: path-to-regexp@0.1.10: {} + path-to-regexp@0.2.5: {} + path-to-regexp@3.3.0: {} path-type@4.0.0: {} diff --git a/scripts/entrypoint.sh b/scripts/entrypoint.sh deleted file mode 100644 index 15da5a1..0000000 --- a/scripts/entrypoint.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -npm i -g pnpm - -# Run the first command (e.g., database migrations or table push) -pnpm -F api db:push - -# Run the third command (e.g., start the backend) -pnpm -F api dev diff --git a/turbo.json b/turbo.json index 3a2237f..a1675bb 100644 --- a/turbo.json +++ b/turbo.json @@ -11,6 +11,11 @@ "cache": false, "persistent": true }, + "start": { + "dependsOn": ["^build"], + "inputs": ["$TURBO_DEFAULT$", ".env*"], + "outputs": ["dist/**"] + }, "typecheck": { "cache": false },