next and nest

This commit is contained in:
Emmanuel Rojas committed 2026-09-22 14:08:17 -05:00
1 parent 55f69fbbb4
commit 90125aede9
30 files changed
+3754 -344

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
import eslint from '@eslint/js';
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';
import globals from 'globals';
import tseslint from 'typescript-eslint';
export default tseslint.config(
{
ignores: ['dist/**'],
},
eslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
eslintPluginPrettierRecommended,
{
languageOptions: {
globals: {
...globals.node,
},
sourceType: 'commonjs',
parserOptions: {
projectService: true,
tsconfigRootDir: import.meta.dirname,
},
},
},
{
rules: {
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-floating-promises': 'warn',
'@typescript-eslint/no-unsafe-argument': 'warn',
},
},
);
+8
View File
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"deleteOutDir": true
}
}
+35
View File
@@ -0,0 +1,35 @@
{
"name": "@pdv/api",
"version": "0.1.0",
"private": true,
"scripts": {
"build": "nest build",
"start": "nest start",
"start:dev": "nest start --watch",
"start:prod": "node dist/main.js",
"lint": "eslint \"{src,test}/**/*.ts\" --fix"
},
"dependencies": {
"@nestjs/common": "^12.0.3",
"@nestjs/core": "^12.0.3",
"@nestjs/platform-express": "^12.0.3",
"next": "^16.3.5",
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.2"
},
"devDependencies": {
"@eslint/js": "^9.39.5",
"@nestjs/cli": "^12.0.3",
"@nestjs/schematics": "^12.0.0",
"@nestjs/testing": "^12.0.3",
"@types/express": "^5.0.6",
"@types/node": "^20.19.43",
"eslint": "^9.39.5",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-prettier": "^5.5.6",
"globals": "^14.0.0",
"prettier": "^3.9.8",
"typescript": "^6.0.3",
"typescript-eslint": "^8.70.0"
}
}
+12
View File
@@ -0,0 +1,12 @@
import { Controller, Get } from "@nestjs/common";
import { AppService } from "./app.service";
@Controller()
export class AppController {
constructor(private readonly appService: AppService) {}
@Get("health")
getHealth() {
return this.appService.getHealth();
}
}
+10
View File
@@ -0,0 +1,10 @@
import { Module } from "@nestjs/common";
import { AppController } from "./app.controller";
import { AppService } from "./app.service";
@Module({
imports: [],
controllers: [AppController],
providers: [AppService],
})
export class AppModule {}
+8
View File
@@ -0,0 +1,8 @@
import { Injectable } from "@nestjs/common";
@Injectable()
export class AppService {
getHealth() {
return { status: "ok" };
}
}
+35
View File
@@ -0,0 +1,35 @@
import "reflect-metadata";
import path from "node:path";
import { NestFactory } from "@nestjs/core";
import type { NestExpressApplication } from "@nestjs/platform-express";
import next from "next";
import { AppModule } from "./app.module";
async function bootstrap() {
const dev = process.env.NODE_ENV !== "production";
const port = Number(process.env.PORT ?? 3000);
// apps/api siempre corre compilado desde dist/, por lo que apps/web
// queda dos niveles arriba tanto en desarrollo como en producción.
const nextApp = next({ dev, dir: path.join(__dirname, "../../web") });
const handleNextRequest = nextApp.getRequestHandler();
await nextApp.prepare();
const app = await NestFactory.create<NestExpressApplication>(AppModule);
app.setGlobalPrefix("api");
// Se inicializa antes de registrar el catch-all para que las rutas de
// Nest queden montadas primero y Next solo reciba lo que Nest no maneja.
await app.init();
app
.getHttpAdapter()
.getInstance()
.all(/.*/, (req, res) => handleNextRequest(req, res));
await app.listen(port);
console.log(
`> Servidor listo en http://localhost:${port} (${dev ? "development" : "production"})`,
);
}
void bootstrap();
+4
View File
@@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
}
+21
View File
@@ -0,0 +1,21 @@
{
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "ES2023",
"sourceMap": true,
"outDir": "./dist",
"rootDir": "./src",
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": true,
"forceConsistentCasingInFileNames": true,
"noImplicitAny": true,
"strictBindCallApply": true,
"noFallthroughCasesInSwitch": true
}
}