-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
447b1b6
commit 8825e93
Showing
3 changed files
with
135 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,84 @@ | ||
{ | ||
"name": "node_project_template", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"description": "Typescript & Express template", | ||
"author": "@ocamilomontealegre", | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "swc ./src -d dist --strip-leading-paths", | ||
"clean": "rm -rf dist", | ||
"start": "node dist/main.js", | ||
"start:dev": "nodemon", | ||
"lint": "eslint src", | ||
"lint:fix": "npx lint --fix", | ||
"lint:verbose": "npx lint --debug", | ||
"check:ts": "npx tsc --noEmit", | ||
"check:verbose": "npx tsc --noEmit --diagnostics", | ||
"format": "npx prettier --write '**/*.{js,ts,json,yml}'", | ||
"test:unit": "vitest --config test/config/vitest.config.unit.ts --no-watch", | ||
"test:e2e": "vitest --config test/config/vitest.config.e2e.ts --no-watch --silent", | ||
"test:c": "vitest --config test/config/vitest.config.ts --coverage --no-watch --silent", | ||
"test:co": "open ./coverage/index.html", | ||
"test": "npm-run-all --parallel test:unit test:e2e", | ||
"prepare": "husky || true", | ||
"dependencies": "npx knip --dependencies", | ||
"npkill": "npx npkill" | ||
}, | ||
"keywords": [ | ||
"typescript", | ||
"express", | ||
"template" | ||
], | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@commitlint/cli": "^19.5.0", | ||
"@commitlint/config-conventional": "^19.5.0", | ||
"@commitlint/types": "^19.5.0", | ||
"@eslint/js": "^9.13.0", | ||
"@swc/cli": "0.4.1-nightly.20240914", | ||
"@swc/core": "^1.7.42", | ||
"@types/cors": "^2.8.17", | ||
"@types/eslint__js": "^8.42.3", | ||
"@types/express": "^4.17.21", | ||
"@types/node": "^22.8.6", | ||
"@types/supertest": "^6.0.2", | ||
"@types/swagger-jsdoc": "^6.0.4", | ||
"@types/swagger-ui-express": "^4.1.7", | ||
"@typescript-eslint/parser": "^8.12.2", | ||
"@vitest/coverage-v8": "^2.1.4", | ||
"@vitest/eslint-plugin": "^1.1.7", | ||
"cross-env": "^7.0.3", | ||
"eslint": "^9.14.0", | ||
"globals": "^15.11.0", | ||
"husky": "^9.1.6", | ||
"lint-staged": "^15.2.10", | ||
"nodemon": "^3.1.7", | ||
"npm-run-all": "^4.1.5", | ||
"supertest": "^7.0.0", | ||
"swagger-jsdoc": "^6.2.8", | ||
"swagger-ui-express": "^5.0.1", | ||
"typescript": "^5.6.3", | ||
"typescript-eslint": "^8.12.2", | ||
"vite-tsconfig-paths": "^5.0.1", | ||
"vitest": "^2.1.4" | ||
}, | ||
"dependencies": { | ||
"@chiguitech/node-common": "^0.0.1", | ||
"@cspell/eslint-plugin": "^8.15.5", | ||
"@typescript-eslint/eslint-plugin": "^8.12.2", | ||
"class-transformer": "^0.5.1", | ||
"class-validator": "^0.14.1", | ||
"cors": "^2.8.5", | ||
"dotenv": "^16.4.5", | ||
"express": "^4.21.1", | ||
"helmet": "^8.0.0", | ||
"http-status-codes": "2.3.0", | ||
"inversify": "^6.0.3", | ||
"inversify-express-utils": "^6.4.7", | ||
"reflect-metadata": "^0.2.2", | ||
"winston": "^3.15.0", | ||
"zod": "^3.23.8" | ||
} | ||
} | ||
{ | ||
"name": "node_project_template", | ||
"version": "1.0.0", | ||
"type": "module", | ||
"description": "Typescript & Express template", | ||
"author": "@ocamilomontealegre", | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "swc ./src -d dist --strip-leading-paths", | ||
"clean": "rm -rf dist", | ||
"start": "node dist/main.js", | ||
"start:dev": "nodemon", | ||
"lint": "eslint src", | ||
"lint:fix": "npx lint --fix", | ||
"lint:verbose": "npx lint --debug", | ||
"check:ts": "npx tsc --noEmit", | ||
"check:verbose": "npx tsc --noEmit --diagnostics", | ||
"format": "npx prettier --write '**/*.{js,ts,json,yml}'", | ||
"test:unit": "vitest --config test/config/vitest.config.unit.ts --no-watch", | ||
"test:e2e": "vitest --config test/config/vitest.config.e2e.ts --no-watch --silent", | ||
"test:c": "vitest --config test/config/vitest.config.ts --coverage --no-watch --silent", | ||
"test:co": "open ./coverage/index.html", | ||
"test": "npm-run-all --parallel test:unit test:e2e", | ||
"prepare": "husky || true", | ||
"dependencies": "npx knip --dependencies", | ||
"npkill": "npx npkill" | ||
}, | ||
"keywords": [ | ||
"typescript", | ||
"express", | ||
"template" | ||
], | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@commitlint/cli": "^19.5.0", | ||
"@commitlint/config-conventional": "^19.5.0", | ||
"@commitlint/types": "^19.5.0", | ||
"@eslint/js": "^9.13.0", | ||
"@swc/cli": "0.4.1-nightly.20240914", | ||
"@swc/core": "^1.7.42", | ||
"@types/cors": "^2.8.17", | ||
"@types/eslint__js": "^8.42.3", | ||
"@types/express": "^4.17.21", | ||
"@types/node": "^22.8.6", | ||
"@types/supertest": "^6.0.2", | ||
"@types/swagger-jsdoc": "^6.0.4", | ||
"@types/swagger-ui-express": "^4.1.7", | ||
"@typescript-eslint/parser": "^8.12.2", | ||
"@vitest/coverage-v8": "^2.1.4", | ||
"@vitest/eslint-plugin": "^1.1.7", | ||
"cross-env": "^7.0.3", | ||
"eslint": "^9.14.0", | ||
"globals": "^15.11.0", | ||
"husky": "^9.1.6", | ||
"lint-staged": "^15.2.10", | ||
"nodemon": "^3.1.7", | ||
"npm-run-all": "^4.1.5", | ||
"supertest": "^7.0.0", | ||
"swagger-jsdoc": "^6.2.8", | ||
"swagger-ui-express": "^5.0.1", | ||
"typescript": "^5.6.3", | ||
"typescript-eslint": "^8.12.2", | ||
"vite-tsconfig-paths": "^5.0.1", | ||
"vitest": "^2.1.4" | ||
}, | ||
"dependencies": { | ||
"@chiguitech/node-common": "^0.0.1", | ||
"@cspell/eslint-plugin": "^8.15.5", | ||
"@typescript-eslint/eslint-plugin": "^8.12.2", | ||
"class-transformer": "^0.5.1", | ||
"class-validator": "^0.14.1", | ||
"cors": "^2.8.5", | ||
"dotenv": "^16.4.5", | ||
"express": "^4.21.1", | ||
"helmet": "^8.0.0", | ||
"http-status-codes": "2.3.0", | ||
"inversify": "^6.0.3", | ||
"inversify-express-utils": "^6.4.7", | ||
"reflect-metadata": "^0.2.2", | ||
"tsx": "4.19.2", | ||
"winston": "^3.15.0", | ||
"zod": "^3.23.8" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
import { fileURLToPath } from "node:url"; | ||
import { dirname } from "node:path"; | ||
|
||
export class FileUtils { | ||
public static readonly getCurrentDirectory = (metaURL: string): string => { | ||
/* eslint @typescript-eslint/naming-convention: "off" */ | ||
const __filename = fileURLToPath(metaURL); | ||
return dirname(__filename); | ||
}; | ||
} | ||
import { fileURLToPath } from "node:url"; | ||
import { dirname, basename } from "node:path"; | ||
|
||
export class FileUtils { | ||
public static readonly getCurrentDirectory = (metaURL: string): string => { | ||
/* eslint-disable-next-line @typescript-eslint/naming-convention */ | ||
const __filename = fileURLToPath(metaURL); | ||
return dirname(__filename); | ||
}; | ||
|
||
public static readonly getFilenme = (metaURL: string): string => { | ||
/* eslint-disable-next-line @typescript-eslint/naming-convention */ | ||
const __filename = fileURLToPath(metaURL); | ||
return basename(__filename); | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,34 @@ | ||
import "reflect-metadata"; | ||
import "dotenv/config"; | ||
import { AppBuilder } from "@app/builder/app.builder"; | ||
import { Logger } from "@common/logger/logger.config"; | ||
import { UncaughtExceptionFilter } from "@common/exception-filters"; | ||
import { appConfig, nodeConfig } from "@common/env"; | ||
import type { Application } from "express"; | ||
|
||
const startServer = (app: Application, port: number): void => { | ||
const server = app.listen(port, () => | ||
new Logger().info( | ||
`Server listening on http://localhost:${port}/${appConfig.appGlobalPrefix}/${appConfig.appVersion}`, | ||
"🚀", | ||
), | ||
); | ||
new UncaughtExceptionFilter(server).initialize(); | ||
}; | ||
|
||
const bootstrap = (): void => { | ||
const app = new AppBuilder(nodeConfig, appConfig) | ||
.useJSonParser() | ||
.useHelmet() | ||
.useCors() | ||
.useHttpInterceptor() | ||
.configureOpenAPI() | ||
.setupRouters() | ||
.useErrorHandler() | ||
.build(); | ||
|
||
startServer(app, nodeConfig.port); | ||
}; | ||
|
||
bootstrap(); | ||
import "reflect-metadata"; | ||
import "dotenv/config"; | ||
import { AppBuilder } from "@app/builder/app.builder"; | ||
import { Logger } from "@common/logger/logger.config"; | ||
import { UncaughtExceptionFilter } from "@common/exception-filters"; | ||
import { appConfig, nodeConfig } from "@common/env"; | ||
import type { Application } from "express"; | ||
|
||
const startServer = (app: Application, port: number): void => { | ||
const server = app.listen(port, () => | ||
new Logger().info( | ||
`Server listening on http://localhost:${port}/${appConfig.appGlobalPrefix}/${appConfig.appVersion}`, | ||
"🚀", | ||
), | ||
); | ||
new UncaughtExceptionFilter(server).initialize(); | ||
}; | ||
|
||
const bootstrap = (): void => { | ||
const app = new AppBuilder(nodeConfig, appConfig) | ||
.useJSonParser() | ||
.useHelmet() | ||
.useCors() | ||
.useHttpInterceptor() | ||
.configureOpenAPI() | ||
.setupRouters() | ||
.useErrorHandler() | ||
.build(); | ||
|
||
startServer(app, nodeConfig.port); | ||
}; | ||
|
||
bootstrap(); | ||
|