better-ts-stack 0.1.0 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -6
- package/dist/builder/configGenerator.d.ts.map +1 -1
- package/dist/builder/configGenerator.js +26 -23
- package/dist/builder/configGenerator.js.map +1 -1
- package/dist/builder/dependencyInstaller.d.ts.map +1 -1
- package/dist/builder/dependencyInstaller.js +1 -10
- package/dist/builder/dependencyInstaller.js.map +1 -1
- package/dist/builder/index.d.ts.map +1 -1
- package/dist/builder/index.js +3 -7
- package/dist/builder/index.js.map +1 -1
- package/dist/builder/templateContext.d.ts +1 -1
- package/dist/builder/templateContext.d.ts.map +1 -1
- package/dist/builder/templateContext.js +0 -2
- package/dist/builder/templateContext.js.map +1 -1
- package/dist/modules/registry.d.ts.map +1 -1
- package/dist/modules/registry.js +2 -5
- package/dist/modules/registry.js.map +1 -1
- package/dist/output/nextSteps.d.ts.map +1 -1
- package/dist/output/nextSteps.js +7 -34
- package/dist/output/nextSteps.js.map +1 -1
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +3 -14
- package/dist/prompts/index.js.map +1 -1
- package/dist/prompts/stack.d.ts +3 -0
- package/dist/prompts/stack.d.ts.map +1 -0
- package/dist/prompts/stack.js +72 -0
- package/dist/prompts/stack.js.map +1 -0
- package/dist/types/index.d.ts +4 -7
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -9
- package/dist/types/index.js.map +1 -1
- package/dist/validators/index.d.ts +1 -1
- package/dist/validators/index.d.ts.map +1 -1
- package/dist/validators/index.js +1 -1
- package/package.json +12 -12
- package/templates/backend/express/config.json +44 -42
- package/templates/backend/express/eslint.config.mjs +40 -31
- package/templates/backend/express/src/index.ts +61 -46
- package/templates/backend/express/src/routes/health.ts +12 -12
- package/templates/backend/express/tsconfig.json +25 -23
- package/templates/frontend/nextjs/app/globals.css +89 -99
- package/templates/frontend/nextjs/app/page.tsx.hbs +9 -10
- package/templates/frontend/nextjs/config.json +33 -27
- package/templates/frontend/nextjs/eslint.config.mjs +11 -11
- package/templates/frontend/nextjs/proxy.ts.hbs +9 -8
- package/templates/frontend/nextjs/tsconfig.json +34 -21
- package/templates/modules/auth/express/config.json +26 -1
- package/templates/modules/auth/express/src/routes/auth.ts.hbs +1 -1
- package/templates/modules/auth/express/src/services/userStore.ts.hbs +95 -107
- package/templates/modules/auth/nextjs/config.json +6 -6
- package/templates/modules/auth/nextjs/lib/auth.ts.hbs +34 -32
- package/templates/modules/docker/.dockerignore +14 -13
- package/templates/modules/docker/Dockerfile.hbs +80 -70
- package/templates/modules/docker/config.json +19 -16
- package/templates/modules/docker/docker-compose.yml.hbs +9 -9
- package/templates/modules/drizzle/express/config.json +27 -0
- package/templates/modules/drizzle/express/drizzle.config.ts +13 -0
- package/templates/modules/drizzle/express/src/lib/db.ts +13 -0
- package/templates/modules/drizzle/express/src/lib/schema.ts +10 -0
- package/templates/modules/drizzle/nextjs/config.json +27 -19
- package/templates/modules/drizzle/nextjs/lib/db.ts +3 -1
- package/templates/modules/drizzle/nextjs/lib/schema.ts.hbs +84 -84
- package/templates/modules/mongoose/config.json +16 -16
- package/templates/modules/mongoose/src/lib/db.ts.hbs +0 -13
- package/templates/modules/mongoose/src/models/User.ts +48 -47
- package/templates/modules/prisma/express/config.json +27 -21
- package/templates/modules/prisma/express/prisma/schema.prisma +3 -2
- package/templates/modules/prisma/express/prisma.config.ts +12 -13
- package/templates/modules/prisma/express/src/lib/prisma.ts +24 -37
- package/templates/modules/prisma/nextjs/config.json +28 -23
- package/templates/modules/prisma/nextjs/prisma/schema.prisma.hbs +91 -90
- package/dist/prompts/backend/index.d.ts +0 -3
- package/dist/prompts/backend/index.d.ts.map +0 -1
- package/dist/prompts/backend/index.js +0 -128
- package/dist/prompts/backend/index.js.map +0 -1
- package/dist/prompts/frontend/index.d.ts +0 -3
- package/dist/prompts/frontend/index.d.ts.map +0 -1
- package/dist/prompts/frontend/index.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E,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE;QACP,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;QACnC,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;QACnC,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC;KACpC,CAAC;CACH;AAGD,eAAO,MAAM,sBAAsB;;;;;;IAGlC,CAAC;AAEF,eAAO,MAAM,uBAAuB;;;;;;;;IAGnC,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;GAEpC,CAAC;AAGF,eAAO,MAAM,mBAAmB;;;;;;;;;IAI/B,CAAC;AAGF,eAAO,MAAM,iBAAiB;;;GAE7B,CAAC;AAGF,eAAO,MAAM,oBAAoB;;;;;;IAGhC,CAAC;AAGF,eAAO,MAAM,eAAe;;;;;;;;;;;;IAK3B,CAAC;AAEF,eAAO,MAAM,qBAAqB;;;;;;;;;IAIjC,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;IAGvB,CAAC"}
|
package/dist/types/index.js
CHANGED
|
@@ -2,16 +2,8 @@
|
|
|
2
2
|
// Core type definitions for the CLI builder
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.authOptions = exports.packageManagerOptions = exports.databaseOptions = exports.postgresqlOrmOptions = exports.mongodbOrmOptions = exports.databaseTypeOptions = exports.frontendFrameworkOptions = exports.backendFrameworkOptions = exports.applicationTypeOptions = void 0;
|
|
5
|
-
exports.isValidOrmOption = isValidOrmOption;
|
|
6
5
|
exports.deriveDatabase = deriveDatabase;
|
|
7
6
|
exports.buildError = buildError;
|
|
8
|
-
/** Type guard to validate OrmOption values */
|
|
9
|
-
function isValidOrmOption(value) {
|
|
10
|
-
return (value === "prisma" ||
|
|
11
|
-
value === "mongoose" ||
|
|
12
|
-
value === "drizzle" ||
|
|
13
|
-
value === "none");
|
|
14
|
-
}
|
|
15
7
|
/**
|
|
16
8
|
* Derives the database option from database type and ORM selection.
|
|
17
9
|
* Returns "none" if either is "none", otherwise returns the ORM which
|
|
@@ -54,7 +46,6 @@ exports.databaseTypeOptions = [
|
|
|
54
46
|
];
|
|
55
47
|
// ORM options for MongoDB
|
|
56
48
|
exports.mongodbOrmOptions = [
|
|
57
|
-
{ value: "prisma", label: "Prisma (Type-safe ORM)" },
|
|
58
49
|
{ value: "mongoose", label: "Mongoose (MongoDB ODM)" },
|
|
59
50
|
];
|
|
60
51
|
// ORM options for PostgreSQL
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA,4CAA4C;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";AAAA,4CAA4C;;;AAmE5C,wCAUC;AA6CD,gCAaC;AAzED;;;;GAIG;AACH,SAAgB,cAAc,CAC5B,YAA0B,EAC1B,GAAc;IAEd,IAAI,YAAY,KAAK,MAAM,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;QAC9C,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,+DAA+D;IAC/D,4CAA4C;IAC5C,OAAO,GAAG,CAAC;AACb,CAAC;AA4CD,kCAAkC;AAClC,SAAgB,UAAU,CACxB,cAAuB,EACvB,IAAY,EACZ,OAAgB,EAChB,WAAmB,CAAC;IAEpB,MAAM,OAAO,GACX,cAAc,YAAY,KAAK;QAC7B,CAAC,CAAC,cAAc,CAAC,OAAO;QACxB,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAC7B,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,KAAK,O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AC1C,QAAA,eAAe,GAAG;IAC7B,EAAE,KAAK,EAAE,MAAe,EAAE,KAAK,EAAE,4BAA4B,EAAE;IAC/D,EAAE,KAAK,EAAE,QAAiB,EAAE,KAAK,EAAE,wBAAwB,EAAE;IAC7D,EAAE,KAAK,EAAE,UAAmB,EAAE,KAAK,EAAE,iCAAiC,EAAE;IACxE,EAAE,KAAK,EAAE,SAAkB,EAAE,KAAK,EAAE,2BAA2B,EAAE;CAClE,CAAC;AAEW,QAAA,qBAAqB,GAAG;IACnC,EAAE,KAAK,EAAE,KAAc,EAAE,KAAK,EAAE,KAAK,EAAE;IACvC,EAAE,KAAK,EAAE,MAAe,EAAE,KAAK,EAAE,MAAM,EAAE;IACzC,EAAE,KAAK,EAAE,KAAc,EAAE,KAAK,EAAE,KAAK,EAAE;CACxC,CAAC;AAEW,QAAA,WAAW,GAAG;IACzB,EAAE,KAAK,EAAE,KAAc,EAAE,KAAK,EAAE,IAAI,EAAE;IACtC,EAAE,KAAK,EAAE,IAAa,EAAE,KAAK,EAAE,KAAK,EAAE;CACvC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const projectNameSchema: z.
|
|
2
|
+
export declare const projectNameSchema: z.ZodString;
|
|
3
3
|
export declare function validateProjectName(name: string): string | undefined;
|
|
4
4
|
export declare function validateDirectoryEmpty(dirPath: string): Promise<string | null>;
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validators/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/validators/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,iBAAiB,aAc3B,CAAC;AAGJ,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAUpE;AAGD,wBAAsB,sBAAsB,CAAC,OAAO,EAAE,MAAM,0BAgB3D"}
|
package/dist/validators/index.js
CHANGED
|
@@ -53,7 +53,7 @@ function validateProjectName(name) {
|
|
|
53
53
|
return undefined;
|
|
54
54
|
}
|
|
55
55
|
// Return the first error message
|
|
56
|
-
const firstError = result.error.
|
|
56
|
+
const firstError = result.error.issues[0];
|
|
57
57
|
return firstError.message;
|
|
58
58
|
}
|
|
59
59
|
// Ensures a directory is empty or does not exist before starting build
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-ts-stack",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "A powerful CLI tool that generates fully configured TypeScript projects with backend, frontend, database integration, Docker support, and more--all through an interactive setup.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -43,24 +43,24 @@
|
|
|
43
43
|
"type:check": "tsc --noEmit"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@clack/prompts": "^
|
|
47
|
-
"consola": "^3.2
|
|
48
|
-
"fs-extra": "^11.
|
|
49
|
-
"handlebars": "^4.7.
|
|
50
|
-
"zod": "^
|
|
46
|
+
"@clack/prompts": "^1.7.0",
|
|
47
|
+
"consola": "^3.4.2",
|
|
48
|
+
"fs-extra": "^11.4.0",
|
|
49
|
+
"handlebars": "^4.7.9",
|
|
50
|
+
"zod": "^4.5.4"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@better-ts-stack/eslint-config": "*",
|
|
54
54
|
"@better-ts-stack/prettier-config": "*",
|
|
55
55
|
"@types/fs-extra": "^11.0.4",
|
|
56
|
-
"@types/node": "^
|
|
57
|
-
"eslint": "^
|
|
58
|
-
"prettier": "^3.
|
|
59
|
-
"tsx": "^4.
|
|
60
|
-
"typescript": "^
|
|
56
|
+
"@types/node": "^24.13.3",
|
|
57
|
+
"eslint": "^10.10.0",
|
|
58
|
+
"prettier": "^3.9.6",
|
|
59
|
+
"tsx": "^4.23.13",
|
|
60
|
+
"typescript": "^6.0.3"
|
|
61
61
|
},
|
|
62
62
|
"engines": {
|
|
63
|
-
"node": ">=
|
|
63
|
+
"node": ">=24.0.0"
|
|
64
64
|
},
|
|
65
65
|
"prettier": "@better-ts-stack/prettier-config"
|
|
66
66
|
}
|
|
@@ -1,42 +1,44 @@
|
|
|
1
|
-
{
|
|
2
|
-
"id": "express",
|
|
3
|
-
"name": "Express Base",
|
|
4
|
-
"description": "Base Express server with TypeScript, middleware, and best practices",
|
|
5
|
-
"type": "base",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "{{#if (eq packageManager 'bun')}}bun --watch src/index.ts{{else}}tsx watch src/index.ts{{/if}}",
|
|
8
|
-
"build": "tsc",
|
|
9
|
-
"start": "{{runner}} dist/index.js",
|
|
10
|
-
"lint": "eslint src",
|
|
11
|
-
"lint:fix": "eslint src --fix",
|
|
12
|
-
"format": "prettier --write \"src/**/*.ts\"",
|
|
13
|
-
"type:check": "tsc --noEmit"
|
|
14
|
-
},
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"express": "^
|
|
17
|
-
"dotenv": "^
|
|
18
|
-
"cors": "^2.8.
|
|
19
|
-
"helmet": "^
|
|
20
|
-
"morgan": "^1.
|
|
21
|
-
},
|
|
22
|
-
"devDependencies": {
|
|
23
|
-
"@eslint/js": "^
|
|
24
|
-
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
25
|
-
"@types/cors": "^2.8.
|
|
26
|
-
"@types/express": "^
|
|
27
|
-
"@types/morgan": "^1.9.
|
|
28
|
-
"@types/node": "^
|
|
29
|
-
"eslint": "^
|
|
30
|
-
"eslint-config-prettier": "^10.1.8",
|
|
31
|
-
"prettier": "^3.
|
|
32
|
-
"prettier-plugin-tailwindcss": "^0.
|
|
33
|
-
"tsx": "^4.
|
|
34
|
-
"typescript": "^
|
|
35
|
-
"typescript-eslint": "^8.
|
|
36
|
-
},
|
|
37
|
-
"envVars": {
|
|
38
|
-
"NODE_ENV": "development",
|
|
39
|
-
"PORT": "3000"
|
|
40
|
-
},
|
|
41
|
-
"templateFiles": [
|
|
42
|
-
|
|
1
|
+
{
|
|
2
|
+
"id": "express",
|
|
3
|
+
"name": "Express Base",
|
|
4
|
+
"description": "Base Express server with TypeScript, middleware, and best practices",
|
|
5
|
+
"type": "base",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "{{#if (eq packageManager 'bun')}}bun --watch src/index.ts{{else}}tsx watch src/index.ts{{/if}}",
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"start": "{{runner}} dist/index.js",
|
|
10
|
+
"lint": "eslint src",
|
|
11
|
+
"lint:fix": "eslint src --fix",
|
|
12
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
13
|
+
"type:check": "tsc --noEmit"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"express": "^5.2.1",
|
|
17
|
+
"dotenv": "^17.4.2",
|
|
18
|
+
"cors": "^2.8.6",
|
|
19
|
+
"helmet": "^8.3.0",
|
|
20
|
+
"morgan": "^1.12.0"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@eslint/js": "^10.0.1",
|
|
24
|
+
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
25
|
+
"@types/cors": "^2.8.19",
|
|
26
|
+
"@types/express": "^5.0.6",
|
|
27
|
+
"@types/morgan": "^1.9.10",
|
|
28
|
+
"@types/node": "^24.13.3",
|
|
29
|
+
"eslint": "^10.10.0",
|
|
30
|
+
"eslint-config-prettier": "^10.1.8",
|
|
31
|
+
"prettier": "^3.9.6",
|
|
32
|
+
"prettier-plugin-tailwindcss": "^0.8.1",
|
|
33
|
+
"tsx": "^4.23.13",
|
|
34
|
+
"typescript": "^6.0.3",
|
|
35
|
+
"typescript-eslint": "^8.69.0"
|
|
36
|
+
},
|
|
37
|
+
"envVars": {
|
|
38
|
+
"NODE_ENV": "development",
|
|
39
|
+
"PORT": "3000"
|
|
40
|
+
},
|
|
41
|
+
"templateFiles": [
|
|
42
|
+
"src/index.ts"
|
|
43
|
+
]
|
|
44
|
+
}
|
|
@@ -1,31 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import tseslint from
|
|
5
|
-
|
|
6
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
-
const __dirname = path.dirname(__filename);
|
|
8
|
-
|
|
9
|
-
export default tseslint.config(
|
|
10
|
-
{
|
|
11
|
-
ignores: [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import eslint from "@eslint/js";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import tseslint from "typescript-eslint";
|
|
5
|
+
|
|
6
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
7
|
+
const __dirname = path.dirname(__filename);
|
|
8
|
+
|
|
9
|
+
export default tseslint.config(
|
|
10
|
+
{
|
|
11
|
+
ignores: [
|
|
12
|
+
"dist",
|
|
13
|
+
"node_modules",
|
|
14
|
+
"templates/**/*",
|
|
15
|
+
"bin/**/*",
|
|
16
|
+
"src/generated/**",
|
|
17
|
+
],
|
|
18
|
+
},
|
|
19
|
+
eslint.configs.recommended,
|
|
20
|
+
...tseslint.configs.recommended,
|
|
21
|
+
...tseslint.configs.recommendedTypeChecked,
|
|
22
|
+
{
|
|
23
|
+
languageOptions: {
|
|
24
|
+
parserOptions: {
|
|
25
|
+
project: "./tsconfig.eslint.json",
|
|
26
|
+
tsconfigRootDir: __dirname,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
rules: {
|
|
30
|
+
"@typescript-eslint/explicit-function-return-type": "off",
|
|
31
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
32
|
+
"@typescript-eslint/no-unused-vars": [
|
|
33
|
+
"error",
|
|
34
|
+
{ argsIgnorePattern: "^_" },
|
|
35
|
+
],
|
|
36
|
+
"@typescript-eslint/no-floating-promises": "error",
|
|
37
|
+
"no-console": "off",
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
);
|
|
@@ -1,46 +1,61 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
app.use(
|
|
21
|
-
app.use(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
app.use(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
import 'dotenv/config';
|
|
2
|
+
import express, { Express, Request, Response, NextFunction } from 'express';
|
|
3
|
+
import cors from 'cors';
|
|
4
|
+
import helmet from 'helmet';
|
|
5
|
+
import morgan from 'morgan';
|
|
6
|
+
{{#if (eq database 'mongoose')}}
|
|
7
|
+
import { connectDB } from './lib/db';
|
|
8
|
+
{{/if}}
|
|
9
|
+
import healthRouter from './routes/health';
|
|
10
|
+
{{#if useAuth}}
|
|
11
|
+
import authRouter from './routes/auth';
|
|
12
|
+
{{/if}}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
const app: Express = express();
|
|
17
|
+
const port = process.env.PORT || 3000;
|
|
18
|
+
|
|
19
|
+
// Middleware
|
|
20
|
+
app.use(helmet());
|
|
21
|
+
app.use(cors());
|
|
22
|
+
app.use(morgan('dev'));
|
|
23
|
+
app.use(express.json());
|
|
24
|
+
app.use(express.urlencoded({ extended: true }));
|
|
25
|
+
|
|
26
|
+
// Routes
|
|
27
|
+
app.use('/health', healthRouter);
|
|
28
|
+
{{#if useAuth}}
|
|
29
|
+
app.use('/auth', authRouter);
|
|
30
|
+
{{/if}}
|
|
31
|
+
|
|
32
|
+
// 404 handler
|
|
33
|
+
app.use((_req: Request, res: Response) => {
|
|
34
|
+
res.status(404).json({ error: 'Not Found' });
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// Error handler
|
|
38
|
+
app.use((err: Error, _req: Request, res: Response, _next: NextFunction) => {
|
|
39
|
+
console.error(err.stack);
|
|
40
|
+
res.status(500).json({ error: 'Internal Server Error' });
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
{{#if (eq database 'mongoose')}}
|
|
44
|
+
void awaitDatabase().catch((error: unknown) => {
|
|
45
|
+
console.error(error);
|
|
46
|
+
process.exitCode = 1;
|
|
47
|
+
});
|
|
48
|
+
async function awaitDatabase(): Promise<void> {
|
|
49
|
+
await connectDB();
|
|
50
|
+
app.listen(port);
|
|
51
|
+
}
|
|
52
|
+
{{else}}
|
|
53
|
+
app.listen(port, () => {
|
|
54
|
+
console.log(`Server is running on http://localhost:${port}
|
|
55
|
+
Health: http://localhost:${port}/health
|
|
56
|
+
`);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
{{/if}}
|
|
60
|
+
|
|
61
|
+
export default app;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const router = Router();
|
|
4
|
-
|
|
5
|
-
router.get(
|
|
6
|
-
res.status(200).json({
|
|
7
|
-
status:
|
|
8
|
-
timestamp: new Date().toISOString(),
|
|
9
|
-
});
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
export default router;
|
|
1
|
+
import { Request, Response, Router } from "express";
|
|
2
|
+
|
|
3
|
+
const router: Router = Router();
|
|
4
|
+
|
|
5
|
+
router.get("/", (_req: Request, res: Response) => {
|
|
6
|
+
res.status(200).json({
|
|
7
|
+
status: "ok",
|
|
8
|
+
timestamp: new Date().toISOString(),
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
export default router;
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2020",
|
|
4
|
-
"module": "
|
|
5
|
-
"lib": ["ES2020"],
|
|
6
|
-
"outDir": "./dist",
|
|
7
|
-
"rootDir": "./src",
|
|
8
|
-
"strict": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"skipLibCheck": true,
|
|
11
|
-
"forceConsistentCasingInFileNames": true,
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"declaration": true,
|
|
14
|
-
"declarationMap": true,
|
|
15
|
-
"sourceMap": true,
|
|
16
|
-
"noUnusedLocals": true,
|
|
17
|
-
"noUnusedParameters": true,
|
|
18
|
-
"noImplicitReturns": true,
|
|
19
|
-
"noFallthroughCasesInSwitch": true
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2020",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"lib": ["ES2020"],
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"declaration": true,
|
|
14
|
+
"declarationMap": true,
|
|
15
|
+
"sourceMap": true,
|
|
16
|
+
"noUnusedLocals": true,
|
|
17
|
+
"noUnusedParameters": true,
|
|
18
|
+
"noImplicitReturns": true,
|
|
19
|
+
"noFallthroughCasesInSwitch": true,
|
|
20
|
+
"moduleResolution": "NodeNext",
|
|
21
|
+
"types": ["node"]
|
|
22
|
+
},
|
|
23
|
+
"include": ["src/**/*"],
|
|
24
|
+
"exclude": ["node_modules", "dist"]
|
|
25
|
+
}
|