better-ts-stack 1.1.3 → 2.0.0
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 +113 -82
- package/dist/args.d.ts +12 -0
- package/dist/args.d.ts.map +1 -0
- package/dist/args.js +90 -0
- package/dist/args.js.map +1 -0
- package/dist/builder/configGenerator.d.ts +1 -0
- package/dist/builder/configGenerator.d.ts.map +1 -1
- package/dist/builder/configGenerator.js +46 -6
- package/dist/builder/configGenerator.js.map +1 -1
- package/dist/builder/dependencyInstaller.d.ts.map +1 -1
- package/dist/builder/dependencyInstaller.js +8 -14
- package/dist/builder/dependencyInstaller.js.map +1 -1
- package/dist/builder/gitInitializer.d.ts.map +1 -1
- package/dist/builder/gitInitializer.js +8 -41
- package/dist/builder/gitInitializer.js.map +1 -1
- package/dist/builder/index.d.ts.map +1 -1
- package/dist/builder/index.js +27 -63
- package/dist/builder/index.js.map +1 -1
- package/dist/builder/moduleSelector.d.ts +1 -4
- package/dist/builder/moduleSelector.d.ts.map +1 -1
- package/dist/builder/moduleSelector.js +11 -15
- package/dist/builder/moduleSelector.js.map +1 -1
- package/dist/builder/templateContext.d.ts +2 -17
- package/dist/builder/templateContext.d.ts.map +1 -1
- package/dist/builder/templateContext.js +6 -5
- package/dist/builder/templateContext.js.map +1 -1
- package/dist/index.js +45 -20
- package/dist/index.js.map +1 -1
- package/dist/output/nextSteps.d.ts +1 -2
- package/dist/output/nextSteps.d.ts.map +1 -1
- package/dist/output/nextSteps.js +10 -19
- package/dist/output/nextSteps.js.map +1 -1
- package/dist/prompts/index.d.ts +3 -3
- package/dist/prompts/index.d.ts.map +1 -1
- package/dist/prompts/index.js +22 -58
- package/dist/prompts/index.js.map +1 -1
- package/dist/prompts/stack.d.ts +3 -2
- package/dist/prompts/stack.d.ts.map +1 -1
- package/dist/prompts/stack.js +81 -70
- package/dist/prompts/stack.js.map +1 -1
- package/dist/types/index.d.ts +20 -42
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +40 -38
- package/dist/types/index.js.map +1 -1
- package/dist/ui/index.d.ts +3 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +19 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/messages.d.ts +9 -0
- package/dist/ui/messages.d.ts.map +1 -0
- package/dist/ui/messages.js +100 -0
- package/dist/ui/messages.js.map +1 -0
- package/dist/ui/prompts.d.ts +20 -0
- package/dist/ui/prompts.d.ts.map +1 -0
- package/dist/ui/prompts.js +71 -0
- package/dist/ui/prompts.js.map +1 -0
- package/dist/ui/theme.d.ts +9 -0
- package/dist/ui/theme.d.ts.map +1 -0
- package/dist/ui/theme.js +24 -0
- package/dist/ui/theme.js.map +1 -0
- package/dist/validators/index.d.ts +1 -0
- package/dist/validators/index.d.ts.map +1 -1
- package/dist/validators/index.js +6 -0
- package/dist/validators/index.js.map +1 -1
- package/package.json +70 -66
- package/templates/backend/express/config.json +44 -44
- package/templates/backend/express/eslint.config.mjs +40 -40
- package/templates/backend/express/gitignore +36 -36
- package/templates/backend/express/src/index.ts +76 -76
- package/templates/backend/express/src/routes/health.ts +12 -12
- package/templates/backend/express/tsconfig.json +25 -25
- package/templates/backend/nestjs/.prettierignore +52 -0
- package/templates/backend/nestjs/.prettierrc +16 -0
- package/templates/backend/nestjs/config.json +44 -0
- package/templates/backend/nestjs/eslint.config.mjs +40 -0
- package/templates/backend/nestjs/gitignore +36 -0
- package/templates/backend/nestjs/nest-cli.json +9 -0
- package/templates/backend/nestjs/src/app.module.ts.hbs +34 -0
- package/templates/backend/nestjs/src/health/health.controller.ts +12 -0
- package/templates/backend/nestjs/src/main.ts +23 -0
- package/templates/backend/nestjs/tsconfig.eslint.json +9 -0
- package/templates/backend/nestjs/tsconfig.json +25 -0
- package/templates/frontend/nextjs/app/layout.tsx +13 -13
- package/templates/frontend/nextjs/app/page.tsx.hbs +97 -97
- package/templates/frontend/nextjs/components/ui/button.tsx +51 -51
- package/templates/frontend/nextjs/components/ui/card.tsx +60 -60
- package/templates/frontend/nextjs/components/ui/field.tsx +67 -67
- package/templates/frontend/nextjs/components/ui/input.tsx +18 -18
- package/templates/frontend/nextjs/components.json +19 -19
- package/templates/frontend/nextjs/config.json +38 -38
- package/templates/frontend/nextjs/eslint.config.mjs +11 -11
- package/templates/frontend/nextjs/gitignore +42 -42
- package/templates/frontend/nextjs/lib/utils.ts +6 -6
- package/templates/frontend/nextjs/next.config.ts.hbs +12 -12
- package/templates/frontend/nextjs/proxy.ts.hbs +24 -24
- package/templates/frontend/nextjs/tsconfig.json +34 -34
- package/templates/frontend/tanstack/config.json +48 -48
- package/templates/frontend/tanstack/src/routeTree.gen.ts +68 -68
- package/templates/frontend/tanstack/src/styles/app.css +85 -85
- package/templates/modules/auth/express/config.json +27 -26
- package/templates/modules/auth/express/src/controllers/authController.ts.hbs +116 -130
- package/templates/modules/auth/express/src/middleware/requireAuth.ts.hbs +26 -26
- package/templates/modules/auth/express/src/services/userStore.ts.hbs +117 -117
- package/templates/modules/auth/nestjs/config.json +24 -0
- package/templates/modules/auth/nestjs/src/auth/auth.controller.ts +46 -0
- package/templates/modules/auth/nestjs/src/auth/auth.guard.ts +36 -0
- package/templates/modules/auth/nestjs/src/auth/auth.module.ts.hbs +22 -0
- package/templates/modules/auth/nestjs/src/auth/auth.schemas.ts +35 -0
- package/templates/modules/auth/nestjs/src/auth/auth.service.ts +70 -0
- package/templates/modules/auth/nestjs/src/auth/jwt.ts +27 -0
- package/templates/modules/auth/nestjs/src/auth/users.service.ts.hbs +144 -0
- package/templates/modules/auth/nestjs/src/auth/zod-validation.pipe.ts +16 -0
- package/templates/modules/auth/nextjs/app/dashboard/page.tsx +96 -96
- package/templates/modules/auth/nextjs/app/sign-in/page.tsx +35 -35
- package/templates/modules/auth/nextjs/app/sign-up/page.tsx +35 -35
- package/templates/modules/auth/nextjs/components/auth/sign-in-form.tsx +132 -132
- package/templates/modules/auth/nextjs/components/auth/sign-out-button.tsx +50 -50
- package/templates/modules/auth/nextjs/components/auth/sign-up-form.tsx +152 -152
- package/templates/modules/auth/nextjs/config.json +31 -31
- package/templates/modules/auth/nextjs/lib/auth-schema.ts +39 -39
- package/templates/modules/auth/nextjs/lib/auth.ts.hbs +37 -37
- package/templates/modules/auth/tanstack/src/lib/auth-functions.ts +4 -4
- package/templates/modules/auth/tanstack/src/routeTree.gen.ts +140 -140
- package/templates/modules/docker/.dockerignore +14 -14
- package/templates/modules/docker/Dockerfile.hbs +137 -130
- package/templates/modules/docker/config.json +19 -19
- package/templates/modules/docker/docker-compose.yml.hbs +9 -9
- package/templates/modules/drizzle/express/config.json +27 -27
- package/templates/modules/drizzle/express/drizzle.config.ts +13 -13
- package/templates/modules/drizzle/express/src/lib/db.ts +13 -13
- package/templates/modules/drizzle/express/src/lib/schema.ts +10 -10
- package/templates/modules/drizzle/nestjs/config.json +27 -0
- package/templates/modules/drizzle/nestjs/drizzle.config.ts +13 -0
- package/templates/modules/drizzle/nestjs/src/database/database.module.ts +30 -0
- package/templates/modules/drizzle/nestjs/src/database/schema.ts +10 -0
- package/templates/modules/drizzle/nextjs/config.json +29 -29
- package/templates/modules/drizzle/nextjs/lib/db.ts +13 -13
- package/templates/modules/drizzle/nextjs/lib/schema.ts.hbs +84 -84
- package/templates/modules/mongoose/express/config.json +16 -16
- package/templates/modules/mongoose/nestjs/config.json +16 -0
- package/templates/modules/mongoose/nestjs/src/users/user.schema.ts +21 -0
- package/templates/modules/mongoose/nextjs/config.json +16 -16
- package/templates/modules/mongoose/nextjs/lib/db.ts +36 -36
- package/templates/modules/mongoose/tanstack/config.json +17 -17
- package/templates/modules/mongoose/tanstack/src/lib/db.ts +37 -37
- package/templates/modules/prisma/express/config.json +28 -28
- package/templates/modules/prisma/express/prisma/schema.prisma +1 -1
- package/templates/modules/prisma/express/prisma.config.ts +12 -12
- package/templates/modules/prisma/express/src/lib/prisma.ts +24 -24
- package/templates/modules/prisma/nestjs/config.json +28 -0
- package/templates/modules/prisma/nestjs/prisma/schema.prisma +23 -0
- package/templates/modules/prisma/nestjs/prisma.config.ts +12 -0
- package/templates/modules/prisma/nestjs/src/prisma/prisma.module.ts +11 -0
- package/templates/modules/prisma/nestjs/src/prisma/prisma.service.ts +17 -0
- package/templates/modules/prisma/nextjs/config.json +29 -29
- package/templates/modules/prisma/nextjs/prisma/schema.prisma.hbs +91 -91
- package/templates/modules/prisma/tanstack/config.json +5 -5
- package/dist/intro.d.ts +0 -2
- package/dist/intro.d.ts.map +0 -1
- package/dist/intro.js +0 -27
- package/dist/intro.js.map +0 -1
- package/templates/backend/express/.eslintrc.js +0 -24
|
@@ -1,76 +1,76 @@
|
|
|
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(
|
|
39
|
-
(
|
|
40
|
-
err: Error & { status?: number; statusCode?: number; expose?: boolean },
|
|
41
|
-
_req: Request,
|
|
42
|
-
res: Response,
|
|
43
|
-
_next: NextFunction,
|
|
44
|
-
) => {
|
|
45
|
-
// Middleware such as express.json() sets 4xx statuses (bad JSON, body too large)
|
|
46
|
-
const status = err.status ?? err.statusCode ?? 500;
|
|
47
|
-
|
|
48
|
-
if (status >= 400 && status < 500) {
|
|
49
|
-
res.status(status).json({ error: err.expose ? err.message : 'Bad Request' });
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
console.error(err.stack);
|
|
54
|
-
res.status(500).json({ error: 'Internal Server Error' });
|
|
55
|
-
},
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
{{#if (eq database 'mongoose')}}
|
|
59
|
-
void awaitDatabase().catch((error: unknown) => {
|
|
60
|
-
console.error(error);
|
|
61
|
-
process.exitCode = 1;
|
|
62
|
-
});
|
|
63
|
-
async function awaitDatabase(): Promise<void> {
|
|
64
|
-
await connectDB();
|
|
65
|
-
app.listen(port);
|
|
66
|
-
}
|
|
67
|
-
{{else}}
|
|
68
|
-
app.listen(port, () => {
|
|
69
|
-
console.log(`Server is running on http://localhost:${port}
|
|
70
|
-
Health: http://localhost:${port}/health
|
|
71
|
-
`);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
{{/if}}
|
|
75
|
-
|
|
76
|
-
export default app;
|
|
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(
|
|
39
|
+
(
|
|
40
|
+
err: Error & { status?: number; statusCode?: number; expose?: boolean },
|
|
41
|
+
_req: Request,
|
|
42
|
+
res: Response,
|
|
43
|
+
_next: NextFunction,
|
|
44
|
+
) => {
|
|
45
|
+
// Middleware such as express.json() sets 4xx statuses (bad JSON, body too large)
|
|
46
|
+
const status = err.status ?? err.statusCode ?? 500;
|
|
47
|
+
|
|
48
|
+
if (status >= 400 && status < 500) {
|
|
49
|
+
res.status(status).json({ error: err.expose ? err.message : 'Bad Request' });
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
console.error(err.stack);
|
|
54
|
+
res.status(500).json({ error: 'Internal Server Error' });
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
{{#if (eq database 'mongoose')}}
|
|
59
|
+
void awaitDatabase().catch((error: unknown) => {
|
|
60
|
+
console.error(error);
|
|
61
|
+
process.exitCode = 1;
|
|
62
|
+
});
|
|
63
|
+
async function awaitDatabase(): Promise<void> {
|
|
64
|
+
await connectDB();
|
|
65
|
+
app.listen(port);
|
|
66
|
+
}
|
|
67
|
+
{{else}}
|
|
68
|
+
app.listen(port, () => {
|
|
69
|
+
console.log(`Server is running on http://localhost:${port}
|
|
70
|
+
Health: http://localhost:${port}/health
|
|
71
|
+
`);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
{{/if}}
|
|
75
|
+
|
|
76
|
+
export default app;
|
|
@@ -1,12 +1,12 @@
|
|
|
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
|
+
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,25 +1,25 @@
|
|
|
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
|
-
}
|
|
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
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Dependencies
|
|
2
|
+
node_modules
|
|
3
|
+
**/node_modules
|
|
4
|
+
|
|
5
|
+
# Build outputs
|
|
6
|
+
.next
|
|
7
|
+
out
|
|
8
|
+
dist
|
|
9
|
+
build
|
|
10
|
+
**/dist
|
|
11
|
+
**/.next
|
|
12
|
+
**/out
|
|
13
|
+
**/build
|
|
14
|
+
|
|
15
|
+
# Generated files
|
|
16
|
+
*.min.js
|
|
17
|
+
*.min.css
|
|
18
|
+
coverage
|
|
19
|
+
.nyc_output
|
|
20
|
+
|
|
21
|
+
# Lock files
|
|
22
|
+
package-lock.json
|
|
23
|
+
yarn.lock
|
|
24
|
+
pnpm-lock.yaml
|
|
25
|
+
bun.lock
|
|
26
|
+
|
|
27
|
+
# Logs
|
|
28
|
+
*.log
|
|
29
|
+
npm-debug.log*
|
|
30
|
+
yarn-debug.log*
|
|
31
|
+
yarn-error.log*
|
|
32
|
+
|
|
33
|
+
# Environment files
|
|
34
|
+
.env
|
|
35
|
+
.env.local
|
|
36
|
+
.env.*.local
|
|
37
|
+
|
|
38
|
+
# IDE
|
|
39
|
+
.vscode
|
|
40
|
+
.idea
|
|
41
|
+
*.swp
|
|
42
|
+
*.swo
|
|
43
|
+
*~
|
|
44
|
+
|
|
45
|
+
# OS
|
|
46
|
+
.DS_Store
|
|
47
|
+
Thumbs.db
|
|
48
|
+
|
|
49
|
+
# Templates (do not format generated/scaffold content)
|
|
50
|
+
templates
|
|
51
|
+
**/templates/**
|
|
52
|
+
*.hbs
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"semi": true,
|
|
3
|
+
"trailingComma": "es5",
|
|
4
|
+
"singleQuote": false,
|
|
5
|
+
"printWidth": 80,
|
|
6
|
+
"tabWidth": 2,
|
|
7
|
+
"useTabs": false,
|
|
8
|
+
"arrowParens": "always",
|
|
9
|
+
"endOfLine": "lf",
|
|
10
|
+
"plugins": ["@trivago/prettier-plugin-sort-imports"],
|
|
11
|
+
"importOrder": ["<THIRD_PARTY_MODULES>", "^[./]"],
|
|
12
|
+
"importOrderSeparation": true,
|
|
13
|
+
"importOrderSortSpecifiers": true,
|
|
14
|
+
"importOrderCaseInsensitive": true,
|
|
15
|
+
"importOrderParserPlugins": ["typescript", "decorators-legacy"]
|
|
16
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "nestjs",
|
|
3
|
+
"name": "NestJS Base",
|
|
4
|
+
"description": "Base NestJS server with TypeScript, security headers, and a health check",
|
|
5
|
+
"type": "base",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "cross-env NODE_ENV=development nest start --watch",
|
|
8
|
+
"build": "nest build",
|
|
9
|
+
"start": "cross-env NODE_ENV=production {{runner}} dist/main.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
|
+
"@nestjs/common": "^12.1.2",
|
|
17
|
+
"@nestjs/core": "^12.1.2",
|
|
18
|
+
"@nestjs/platform-express": "^12.1.2",
|
|
19
|
+
"cross-env": "^10.1.0",
|
|
20
|
+
"dotenv": "^17.4.2",
|
|
21
|
+
"helmet": "^8.3.0",
|
|
22
|
+
"reflect-metadata": "^0.2.2",
|
|
23
|
+
"rxjs": "^7.8.2"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@eslint/js": "^10.0.1",
|
|
27
|
+
"@nestjs/cli": "^12.0.8",
|
|
28
|
+
"@nestjs/schematics": "^12.0.6",
|
|
29
|
+
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
30
|
+
"@types/express": "^5.0.6",
|
|
31
|
+
"@types/node": "^24.13.3",
|
|
32
|
+
"eslint": "^10.10.0",
|
|
33
|
+
"eslint-config-prettier": "^10.1.8",
|
|
34
|
+
"prettier": "^3.9.6",
|
|
35
|
+
"typescript": "^6.0.3",
|
|
36
|
+
"typescript-eslint": "^8.69.0"
|
|
37
|
+
},
|
|
38
|
+
"envVars": {
|
|
39
|
+
"PORT": "3000"
|
|
40
|
+
},
|
|
41
|
+
"templateFiles": [
|
|
42
|
+
"src/app.module.ts.hbs"
|
|
43
|
+
]
|
|
44
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
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
|
+
);
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Dependencies
|
|
2
|
+
node_modules/
|
|
3
|
+
|
|
4
|
+
# Build output
|
|
5
|
+
dist/
|
|
6
|
+
build/
|
|
7
|
+
|
|
8
|
+
# Environment variables
|
|
9
|
+
.env
|
|
10
|
+
.env.local
|
|
11
|
+
.env.*.local
|
|
12
|
+
|
|
13
|
+
# Logs
|
|
14
|
+
logs/
|
|
15
|
+
*.log
|
|
16
|
+
npm-debug.log*
|
|
17
|
+
yarn-debug.log*
|
|
18
|
+
yarn-error.log*
|
|
19
|
+
|
|
20
|
+
# IDE
|
|
21
|
+
.vscode/
|
|
22
|
+
.idea/
|
|
23
|
+
*.swp
|
|
24
|
+
*.swo
|
|
25
|
+
*~
|
|
26
|
+
|
|
27
|
+
# OS
|
|
28
|
+
.DS_Store
|
|
29
|
+
Thumbs.db
|
|
30
|
+
|
|
31
|
+
# Testing
|
|
32
|
+
coverage/
|
|
33
|
+
.nyc_output/
|
|
34
|
+
|
|
35
|
+
# Misc
|
|
36
|
+
*.tsbuildinfo
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Module } from "@nestjs/common";
|
|
2
|
+
{{#if (eq database 'mongoose')}}
|
|
3
|
+
import { MongooseModule } from "@nestjs/mongoose";
|
|
4
|
+
{{/if}}
|
|
5
|
+
|
|
6
|
+
{{#if useAuth}}
|
|
7
|
+
import { AuthModule } from "./auth/auth.module.js";
|
|
8
|
+
{{/if}}
|
|
9
|
+
{{#if (eq database 'drizzle')}}
|
|
10
|
+
import { DatabaseModule } from "./database/database.module.js";
|
|
11
|
+
{{/if}}
|
|
12
|
+
import { HealthController } from "./health/health.controller.js";
|
|
13
|
+
{{#if (eq database 'prisma')}}
|
|
14
|
+
import { PrismaModule } from "./prisma/prisma.module.js";
|
|
15
|
+
{{/if}}
|
|
16
|
+
|
|
17
|
+
@Module({
|
|
18
|
+
imports: [
|
|
19
|
+
{{#if (eq database 'prisma')}}
|
|
20
|
+
PrismaModule,
|
|
21
|
+
{{/if}}
|
|
22
|
+
{{#if (eq database 'drizzle')}}
|
|
23
|
+
DatabaseModule,
|
|
24
|
+
{{/if}}
|
|
25
|
+
{{#if (eq database 'mongoose')}}
|
|
26
|
+
MongooseModule.forRoot(process.env.MONGODB_URI!),
|
|
27
|
+
{{/if}}
|
|
28
|
+
{{#if useAuth}}
|
|
29
|
+
AuthModule,
|
|
30
|
+
{{/if}}
|
|
31
|
+
],
|
|
32
|
+
controllers: [HealthController],
|
|
33
|
+
})
|
|
34
|
+
export class AppModule {}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { NestFactory } from "@nestjs/core";
|
|
2
|
+
// Loads .env before app.module.js reads process.env
|
|
3
|
+
import "dotenv/config";
|
|
4
|
+
import helmet from "helmet";
|
|
5
|
+
|
|
6
|
+
import { AppModule } from "./app.module.js";
|
|
7
|
+
|
|
8
|
+
async function bootstrap(): Promise<void> {
|
|
9
|
+
const app = await NestFactory.create(AppModule);
|
|
10
|
+
const port = process.env.PORT ?? 3000;
|
|
11
|
+
|
|
12
|
+
app.use(helmet());
|
|
13
|
+
app.enableCors();
|
|
14
|
+
// Lets modules close database connections when the process is stopped
|
|
15
|
+
app.enableShutdownHooks();
|
|
16
|
+
|
|
17
|
+
await app.listen(port);
|
|
18
|
+
console.log(`Server is running on http://localhost:${port}
|
|
19
|
+
Health: http://localhost:${port}/health
|
|
20
|
+
`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
void bootstrap();
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2023",
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"moduleResolution": "NodeNext",
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"rootDir": "./src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"strictPropertyInitialization": false,
|
|
10
|
+
"esModuleInterop": true,
|
|
11
|
+
"isolatedModules": true,
|
|
12
|
+
"experimentalDecorators": true,
|
|
13
|
+
"emitDecoratorMetadata": true,
|
|
14
|
+
"skipLibCheck": true,
|
|
15
|
+
"forceConsistentCasingInFileNames": true,
|
|
16
|
+
"sourceMap": true,
|
|
17
|
+
"noUnusedLocals": true,
|
|
18
|
+
"noUnusedParameters": true,
|
|
19
|
+
"noImplicitReturns": true,
|
|
20
|
+
"noFallthroughCasesInSwitch": true,
|
|
21
|
+
"types": ["node"]
|
|
22
|
+
},
|
|
23
|
+
"include": ["src/**/*"],
|
|
24
|
+
"exclude": ["node_modules", "dist"]
|
|
25
|
+
}
|
|
@@ -12,10 +12,10 @@ const geistMono = Geist_Mono({
|
|
|
12
12
|
subsets: ["latin"],
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
-
export const metadata: Metadata = {
|
|
16
|
-
title: "better-ts-stack starter",
|
|
17
|
-
description: "Generated with better-ts-stack",
|
|
18
|
-
};
|
|
15
|
+
export const metadata: Metadata = {
|
|
16
|
+
title: "better-ts-stack starter",
|
|
17
|
+
description: "Generated with better-ts-stack",
|
|
18
|
+
};
|
|
19
19
|
|
|
20
20
|
export default function RootLayout({
|
|
21
21
|
children,
|
|
@@ -23,12 +23,12 @@ export default function RootLayout({
|
|
|
23
23
|
children: React.ReactNode;
|
|
24
24
|
}>) {
|
|
25
25
|
return (
|
|
26
|
-
<html lang="en">
|
|
27
|
-
<body
|
|
28
|
-
className={`${geistSans.variable} ${geistMono.variable} bg-background text-foreground antialiased`}
|
|
29
|
-
>
|
|
30
|
-
{children}
|
|
31
|
-
</body>
|
|
32
|
-
</html>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
26
|
+
<html lang="en">
|
|
27
|
+
<body
|
|
28
|
+
className={`${geistSans.variable} ${geistMono.variable} bg-background text-foreground antialiased`}
|
|
29
|
+
>
|
|
30
|
+
{children}
|
|
31
|
+
</body>
|
|
32
|
+
</html>
|
|
33
|
+
);
|
|
34
|
+
}
|