better-ts-stack 2.0.2 → 2.1.1

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.
Files changed (68) hide show
  1. package/README.md +114 -113
  2. package/dist/args.js +27 -20
  3. package/dist/builder/buildPlanner.js +1 -1
  4. package/dist/builder/configGenerator.js +4 -6
  5. package/dist/builder/index.js +15 -3
  6. package/dist/builder/moduleSelector.js +6 -2
  7. package/dist/builder/readmeGenerator.js +107 -0
  8. package/dist/builder/templateContext.js +53 -0
  9. package/dist/index.js +7 -1
  10. package/dist/output/nextSteps.js +23 -22
  11. package/dist/prompts/index.js +5 -2
  12. package/dist/prompts/stack.js +23 -2
  13. package/dist/types/index.js +2 -0
  14. package/dist/ui/messages.js +3 -1
  15. package/dist/validators/index.js +5 -2
  16. package/package.json +3 -3
  17. package/templates/backend/express/config.json +42 -40
  18. package/templates/backend/express/gitignore +3 -0
  19. package/templates/backend/express/src/env.ts.hbs +39 -0
  20. package/templates/backend/express/src/index.ts.hbs +111 -75
  21. package/templates/backend/nestjs/config.json +43 -41
  22. package/templates/backend/nestjs/gitignore +3 -0
  23. package/templates/backend/nestjs/src/app.module.ts.hbs +13 -0
  24. package/templates/backend/nestjs/src/env.ts.hbs +39 -0
  25. package/templates/backend/nestjs/src/health/{health.controller.ts → health.controller.ts.hbs} +8 -0
  26. package/templates/backend/nestjs/src/main.ts +3 -2
  27. package/templates/frontend/nextjs/app/page.tsx.hbs +98 -97
  28. package/templates/frontend/nextjs/config.json +12 -14
  29. package/templates/frontend/nextjs/gitignore +3 -0
  30. package/templates/frontend/tanstack/config.json +16 -16
  31. package/templates/frontend/tanstack/gitignore +3 -0
  32. package/templates/frontend/tanstack/src/routes/index.tsx.hbs +102 -101
  33. package/templates/frontend/tanstack/vite.config.ts +23 -14
  34. package/templates/modules/auth/express/config.json +20 -20
  35. package/templates/modules/auth/express/src/middleware/requireAuth.ts.hbs +1 -2
  36. package/templates/modules/auth/express/src/routes/auth.ts.hbs +27 -19
  37. package/templates/modules/auth/nestjs/config.json +20 -20
  38. package/templates/modules/auth/nestjs/src/auth/{auth.controller.ts → auth.controller.ts.hbs} +15 -0
  39. package/templates/modules/auth/nextjs/config.json +4 -4
  40. package/templates/{frontend/nextjs/proxy.ts.hbs → modules/auth/nextjs/proxy.ts} +1 -8
  41. package/templates/modules/auth/tanstack/config.json +4 -4
  42. package/templates/modules/auth/tanstack/src/components/auth/sign-in-form.tsx +132 -134
  43. package/templates/modules/auth/tanstack/src/components/auth/sign-out-button.tsx +46 -48
  44. package/templates/modules/auth/tanstack/src/components/auth/sign-up-form.tsx +150 -152
  45. package/templates/modules/ci/.github/workflows/ci.yml.hbs +43 -0
  46. package/templates/modules/ci/config.json +10 -0
  47. package/templates/modules/docker/.dockerignore +2 -0
  48. package/templates/modules/docker/Dockerfile.hbs +147 -136
  49. package/templates/modules/docker/docker-compose.yml.hbs +97 -2
  50. package/templates/modules/drizzle/express/config.json +3 -3
  51. package/templates/modules/drizzle/nestjs/config.json +3 -3
  52. package/templates/modules/drizzle/nextjs/config.json +3 -3
  53. package/templates/modules/drizzle/tanstack/config.json +3 -3
  54. package/templates/modules/mongoose/express/config.json +2 -2
  55. package/templates/modules/mongoose/nestjs/config.json +1 -1
  56. package/templates/modules/mongoose/nextjs/config.json +2 -2
  57. package/templates/modules/mongoose/tanstack/config.json +2 -2
  58. package/templates/modules/prisma/express/config.json +4 -4
  59. package/templates/modules/prisma/express/prisma.config.ts +4 -2
  60. package/templates/modules/prisma/nestjs/config.json +4 -4
  61. package/templates/modules/prisma/nestjs/prisma.config.ts +4 -2
  62. package/templates/modules/prisma/nextjs/config.json +4 -4
  63. package/templates/modules/prisma/nextjs/prisma.config.ts +4 -2
  64. package/templates/modules/prisma/tanstack/config.json +4 -4
  65. package/templates/modules/prisma/tanstack/prisma.config.ts +4 -2
  66. package/templates/modules/rate-limit/express/config.json +12 -0
  67. package/templates/modules/rate-limit/express/src/middleware/rateLimit.ts +23 -0
  68. package/templates/modules/rate-limit/nestjs/config.json +12 -0
@@ -1,5 +1,5 @@
1
1
  import "dotenv/config";
2
- import { defineConfig, env } from "prisma/config";
2
+ import { defineConfig } from "prisma/config";
3
3
 
4
4
  export default defineConfig({
5
5
  schema: "prisma/schema.prisma",
@@ -7,6 +7,8 @@ export default defineConfig({
7
7
  path: "prisma/migrations",
8
8
  },
9
9
  datasource: {
10
- url: env("DATABASE_URL"),
10
+ // prisma generate needs no URL, so a build without .env (CI, a host) works.
11
+ // Commands that connect report the empty URL
12
+ url: process.env.DATABASE_URL ?? "",
11
13
  },
12
14
  });
@@ -0,0 +1,12 @@
1
+ {
2
+ "id": "rate-limit",
3
+ "name": "Rate limiting",
4
+ "description": "Per-IP request limits for Express with express-rate-limit",
5
+ "type": "feature",
6
+ "dependencies": {
7
+ "express-rate-limit": "^8.7.2"
8
+ },
9
+ "devDependencies": {},
10
+ "scripts": {},
11
+ "envVars": {}
12
+ }
@@ -0,0 +1,23 @@
1
+ import { rateLimit } from "express-rate-limit";
2
+
3
+ // Limits count requests per client IP. Behind a reverse proxy or load
4
+ // balancer, set app.set("trust proxy", 1) so the real client IP is used.
5
+ const FIFTEEN_MINUTES = 15 * 60 * 1000;
6
+
7
+ // Every route: 100 requests per IP in 15 minutes. The health check is left out
8
+ // because Docker and load balancers call it on a schedule
9
+ export const apiLimiter = rateLimit({
10
+ windowMs: FIFTEEN_MINUTES,
11
+ limit: 100,
12
+ standardHeaders: "draft-8",
13
+ legacyHeaders: false,
14
+ skip: (req) => req.path === "/health",
15
+ });
16
+
17
+ // Sign-up and login: 10 attempts per IP in 15 minutes, against password guessing
18
+ export const authLimiter = rateLimit({
19
+ windowMs: FIFTEEN_MINUTES,
20
+ limit: 10,
21
+ standardHeaders: "draft-8",
22
+ legacyHeaders: false,
23
+ });
@@ -0,0 +1,12 @@
1
+ {
2
+ "id": "rate-limit",
3
+ "name": "Rate limiting",
4
+ "description": "Per-IP request limits for NestJS with @nestjs/throttler",
5
+ "type": "feature",
6
+ "dependencies": {
7
+ "@nestjs/throttler": "^6.7.1"
8
+ },
9
+ "devDependencies": {},
10
+ "scripts": {},
11
+ "envVars": {}
12
+ }