better-ts-stack 2.0.1 → 2.1.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.
Files changed (46) hide show
  1. package/README.md +114 -113
  2. package/dist/args.js +24 -20
  3. package/dist/builder/buildPlanner.js +1 -1
  4. package/dist/builder/configGenerator.js +1 -5
  5. package/dist/builder/index.js +15 -3
  6. package/dist/builder/moduleSelector.js +4 -2
  7. package/dist/builder/readmeGenerator.js +101 -0
  8. package/dist/builder/templateContext.js +30 -0
  9. package/dist/index.js +7 -1
  10. package/dist/output/nextSteps.js +22 -23
  11. package/dist/prompts/index.js +2 -1
  12. package/dist/prompts/stack.js +21 -2
  13. package/dist/types/index.js +2 -1
  14. package/dist/ui/messages.js +2 -1
  15. package/dist/validators/index.js +5 -2
  16. package/package.json +1 -1
  17. package/templates/backend/express/config.json +42 -40
  18. package/templates/backend/express/src/env.ts.hbs +39 -0
  19. package/templates/backend/express/src/index.ts.hbs +111 -75
  20. package/templates/backend/nestjs/config.json +43 -41
  21. package/templates/backend/nestjs/src/app.module.ts.hbs +13 -0
  22. package/templates/backend/nestjs/src/env.ts.hbs +39 -0
  23. package/templates/backend/nestjs/src/main.ts +3 -2
  24. package/templates/frontend/nextjs/app/page.tsx.hbs +98 -97
  25. package/templates/frontend/tanstack/config.json +45 -45
  26. package/templates/frontend/tanstack/src/routes/index.tsx.hbs +102 -101
  27. package/templates/frontend/tanstack/vite.config.ts +22 -14
  28. package/templates/modules/auth/express/config.json +20 -20
  29. package/templates/modules/auth/express/src/routes/auth.ts.hbs +27 -19
  30. package/templates/modules/auth/nestjs/config.json +20 -20
  31. package/templates/modules/auth/nestjs/src/auth/{auth.controller.ts → auth.controller.ts.hbs} +15 -0
  32. package/templates/modules/auth/nextjs/lib/auth-schema.ts +1 -1
  33. package/templates/modules/auth/tanstack/src/components/auth/sign-in-form.tsx +132 -134
  34. package/templates/modules/auth/tanstack/src/components/auth/sign-out-button.tsx +46 -48
  35. package/templates/modules/auth/tanstack/src/components/auth/sign-up-form.tsx +150 -152
  36. package/templates/modules/auth/tanstack/src/lib/auth-schema.ts +38 -38
  37. package/templates/modules/docker/.dockerignore +1 -0
  38. package/templates/modules/docker/Dockerfile.hbs +147 -136
  39. package/templates/modules/docker/docker-compose.yml.hbs +96 -1
  40. package/templates/modules/drizzle/express/src/lib/schema.ts +3 -1
  41. package/templates/modules/drizzle/nestjs/src/database/schema.ts +3 -1
  42. package/templates/modules/drizzle/nextjs/lib/schema.ts.hbs +11 -5
  43. package/templates/modules/drizzle/tanstack/src/lib/schema.ts.hbs +90 -84
  44. package/templates/modules/rate-limit/express/config.json +12 -0
  45. package/templates/modules/rate-limit/express/src/middleware/rateLimit.ts +21 -0
  46. package/templates/modules/rate-limit/nestjs/config.json +12 -0
@@ -0,0 +1,21 @@
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
8
+ export const apiLimiter = rateLimit({
9
+ windowMs: FIFTEEN_MINUTES,
10
+ limit: 100,
11
+ standardHeaders: "draft-8",
12
+ legacyHeaders: false,
13
+ });
14
+
15
+ // Sign-up and login: 10 attempts per IP in 15 minutes, against password guessing
16
+ export const authLimiter = rateLimit({
17
+ windowMs: FIFTEEN_MINUTES,
18
+ limit: 10,
19
+ standardHeaders: "draft-8",
20
+ legacyHeaders: false,
21
+ });
@@ -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
+ }