stackkit 0.2.8 → 0.3.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 (77) hide show
  1. package/README.md +4 -0
  2. package/bin/stackkit.js +8 -5
  3. package/dist/cli/add.js +4 -9
  4. package/dist/cli/create.js +4 -9
  5. package/dist/cli/doctor.js +11 -32
  6. package/dist/lib/constants.js +3 -4
  7. package/dist/lib/conversion/js-conversion.js +20 -16
  8. package/dist/lib/discovery/installed-detection.js +28 -38
  9. package/dist/lib/discovery/module-discovery.d.ts +0 -15
  10. package/dist/lib/discovery/module-discovery.js +15 -50
  11. package/dist/lib/framework/framework-utils.d.ts +4 -5
  12. package/dist/lib/framework/framework-utils.js +38 -49
  13. package/dist/lib/fs/files.js +1 -1
  14. package/dist/lib/generation/code-generator.d.ts +13 -19
  15. package/dist/lib/generation/code-generator.js +159 -175
  16. package/dist/lib/generation/generator-utils.js +3 -15
  17. package/dist/lib/project/detect.js +11 -19
  18. package/dist/lib/utils/fs-helpers.d.ts +1 -1
  19. package/modules/auth/authjs/generator.json +16 -16
  20. package/modules/auth/better-auth/files/express/middlewares/authorize.ts +178 -40
  21. package/modules/auth/better-auth/files/express/modules/auth/auth.controller.ts +264 -0
  22. package/modules/auth/better-auth/files/express/modules/auth/auth.route.ts +27 -0
  23. package/modules/auth/better-auth/files/express/modules/auth/auth.service.ts +537 -0
  24. package/modules/auth/better-auth/files/express/modules/auth/auth.type.ts +33 -0
  25. package/modules/auth/better-auth/files/express/templates/google-redirect.ejs +91 -0
  26. package/modules/auth/better-auth/files/express/templates/otp.ejs +87 -0
  27. package/modules/auth/better-auth/files/express/types/express.d.ts +6 -8
  28. package/modules/auth/better-auth/files/express/utils/cookie.ts +19 -0
  29. package/modules/auth/better-auth/files/express/utils/jwt.ts +34 -0
  30. package/modules/auth/better-auth/files/express/utils/token.ts +66 -0
  31. package/modules/auth/better-auth/files/nextjs/api/auth/[...all]/route.ts +1 -1
  32. package/modules/auth/better-auth/files/nextjs/lib/auth/auth-guards.ts +11 -1
  33. package/modules/auth/better-auth/files/nextjs/templates/email-otp.tsx +74 -0
  34. package/modules/auth/better-auth/files/shared/config/env.ts +117 -0
  35. package/modules/auth/better-auth/files/shared/lib/auth-client.ts +1 -1
  36. package/modules/auth/better-auth/files/shared/lib/auth.ts +167 -79
  37. package/modules/auth/better-auth/files/shared/mongoose/auth/constants.ts +11 -0
  38. package/modules/auth/better-auth/files/shared/mongoose/auth/helper.ts +51 -0
  39. package/modules/auth/better-auth/files/shared/prisma/schema.prisma +22 -11
  40. package/modules/auth/better-auth/files/shared/utils/email.ts +70 -0
  41. package/modules/auth/better-auth/generator.json +162 -80
  42. package/modules/database/mongoose/files/lib/mongoose.ts +28 -3
  43. package/modules/database/mongoose/generator.json +18 -18
  44. package/modules/database/prisma/generator.json +44 -44
  45. package/package.json +2 -2
  46. package/templates/express/env.example +3 -2
  47. package/templates/express/eslint.config.mjs +7 -0
  48. package/templates/express/node_modules/.bin/acorn +17 -0
  49. package/templates/express/node_modules/.bin/eslint +17 -0
  50. package/templates/express/node_modules/.bin/tsc +17 -0
  51. package/templates/express/node_modules/.bin/tsserver +17 -0
  52. package/templates/express/node_modules/.bin/tsx +17 -0
  53. package/templates/express/package.json +12 -6
  54. package/templates/express/src/app.ts +15 -7
  55. package/templates/express/src/config/cors.ts +8 -7
  56. package/templates/express/src/config/env.ts +28 -5
  57. package/templates/express/src/config/logger.ts +2 -2
  58. package/templates/express/src/config/rate-limit.ts +2 -2
  59. package/templates/express/src/modules/health/health.controller.ts +13 -11
  60. package/templates/express/src/routes/index.ts +1 -6
  61. package/templates/express/src/server.ts +12 -12
  62. package/templates/express/src/shared/errors/app-error.ts +16 -0
  63. package/templates/express/src/shared/middlewares/error.middleware.ts +154 -12
  64. package/templates/express/src/shared/middlewares/not-found.middleware.ts +2 -1
  65. package/templates/express/src/shared/utils/catch-async.ts +11 -0
  66. package/templates/express/src/shared/utils/pagination.ts +6 -1
  67. package/templates/express/src/shared/utils/send-response.ts +25 -0
  68. package/templates/nextjs/lib/env.ts +19 -8
  69. package/modules/auth/better-auth/files/shared/lib/email/email-service.ts +0 -33
  70. package/modules/auth/better-auth/files/shared/lib/email/email-templates.ts +0 -89
  71. package/templates/express/eslint.config.cjs +0 -42
  72. package/templates/express/src/config/helmet.ts +0 -5
  73. package/templates/express/src/modules/health/health.service.ts +0 -6
  74. package/templates/express/src/shared/errors/error-codes.ts +0 -9
  75. package/templates/express/src/shared/logger/logger.ts +0 -20
  76. package/templates/express/src/shared/utils/async-handler.ts +0 -9
  77. package/templates/express/src/shared/utils/response.ts +0 -9
@@ -1,89 +0,0 @@
1
- export const getVerificationEmailTemplate = (user: { name?: string; email: string }, url: string) => {
2
- const html = `
3
- <!DOCTYPE html>
4
- <html lang="en">
5
- <head>
6
- <meta charset="UTF-8">
7
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
8
- <title>Verify Your Email</title>
9
- <style>
10
- body { font-family: Arial, sans-serif; line-height: 1.6; color: #000; max-width: 600px; margin: 0 auto; padding: 20px; background-color: #fff; }
11
- .header { padding: 20px; text-align: center; border-bottom: 1px solid #000; }
12
- .content { padding: 20px; }
13
- .button { display: inline-block; background-color: #fff; color: #000; padding: 10px 20px; text-decoration: none; border: 1px solid #000; border-radius: 5px; margin: 20px 0; }
14
- .footer { font-size: 12px; color: #000; text-align: center; margin-top: 20px; border-top: 1px solid #000; padding-top: 20px; }
15
- </style>
16
- </head>
17
- <body>
18
- <div class="header">
19
- <h1>Verify Your Email Address</h1>
20
- </div>
21
- <div class="content">
22
- <p>Hi ${user.name || user.email},</p>
23
- <p>Thank you for signing up. Please verify your email address to complete your registration.</p>
24
- <a href="${url}" class="button">Verify Email</a>
25
- <p>If the button doesn't work, copy and paste this link: <a href="${url}">${url}</a></p>
26
- <p>This link expires in 24 hours.</p>
27
- </div>
28
- <div class="footer">
29
- <p>If you didn't create an account, ignore this email.</p>
30
- </div>
31
- </body>
32
- </html>
33
- `;
34
-
35
- const text = `Hi ${user.name || user.email},
36
-
37
- Thank you for signing up. Please verify your email address by clicking this link: ${url}
38
-
39
- This link expires in 24 hours.
40
-
41
- If you didn't create an account, ignore this email.`;
42
-
43
- return { html, text };
44
- };
45
-
46
- export const getPasswordResetEmailTemplate = (user: { name?: string; email: string }, url: string) => {
47
- const html = `
48
- <!DOCTYPE html>
49
- <html lang="en">
50
- <head>
51
- <meta charset="UTF-8">
52
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
53
- <title>Reset Your Password</title>
54
- <style>
55
- body { font-family: Arial, sans-serif; line-height: 1.6; color: #000; max-width: 600px; margin: 0 auto; padding: 20px; background-color: #fff; }
56
- .header { padding: 20px; text-align: center; border-bottom: 1px solid #000; }
57
- .content { padding: 20px; }
58
- .button { display: inline-block; background-color: #fff; color: #000; padding: 10px 20px; text-decoration: none; border: 1px solid #000; border-radius: 5px; margin: 20px 0; }
59
- .footer { font-size: 12px; color: #000; text-align: center; margin-top: 20px; border-top: 1px solid #000; padding-top: 20px; }
60
- </style>
61
- </head>
62
- <body>
63
- <div class="header">
64
- <h1>Reset Your Password</h1>
65
- </div>
66
- <div class="content">
67
- <p>Hi ${user.name || user.email},</p>
68
- <p>You requested a password reset. Click the link below to reset your password.</p>
69
- <a href="${url}" class="button">Reset Password</a>
70
- <p>If the button doesn't work, copy and paste this link: <a href="${url}">${url}</a></p>
71
- <p>This link expires in 1 hour.</p>
72
- </div>
73
- <div class="footer">
74
- <p>If you didn't request this, ignore this email.</p>
75
- </div>
76
- </body>
77
- </html>
78
- `;
79
-
80
- const text = `Hi ${user.name || user.email},
81
-
82
- You requested a password reset. Click this link to reset your password: ${url}
83
-
84
- This link expires in 1 hour.
85
-
86
- If you didn't request this, ignore this email.`;
87
-
88
- return { html, text };
89
- };
@@ -1,42 +0,0 @@
1
- module.exports = [
2
- // Global ignores
3
- {
4
- ignores: ['**/node_modules/**', '**/dist/**', '.env'],
5
- },
6
-
7
- // TypeScript files
8
- {
9
- files: ['**/*.ts', '**/*.tsx'],
10
- languageOptions: {
11
- parser: require('@typescript-eslint/parser'),
12
- parserOptions: {
13
- project: './tsconfig.json',
14
- ecmaVersion: 'latest',
15
- sourceType: 'module',
16
- },
17
- },
18
- plugins: {
19
- '@typescript-eslint': require('@typescript-eslint/eslint-plugin'),
20
- },
21
- rules: {
22
- 'prefer-const': 'error',
23
- 'no-console': 'off',
24
- eqeqeq: ['error', 'always'],
25
- curly: ['error', 'multi-line'],
26
- 'no-implicit-coercion': ['warn', { allow: ['!!'] }],
27
- '@typescript-eslint/no-unused-vars': ['warn', { argsIgnorePattern: '^(?:_|next)$' }],
28
- '@typescript-eslint/explicit-module-boundary-types': 'off',
29
- '@typescript-eslint/no-explicit-any': 'off',
30
- },
31
- },
32
-
33
- // JavaScript files
34
- {
35
- files: ['**/*.js'],
36
- languageOptions: {
37
- ecmaVersion: 'latest',
38
- sourceType: 'module',
39
- },
40
- rules: {},
41
- },
42
- ];
@@ -1,5 +0,0 @@
1
- import createHelmet from "helmet";
2
-
3
- const helmet = createHelmet();
4
-
5
- export { helmet };
@@ -1,6 +0,0 @@
1
- // Demo service - placeholder for future use
2
- // Add your service logic here when needed
3
-
4
- export const healthServices = {
5
- // placeholder
6
- };
@@ -1,9 +0,0 @@
1
- const ERROR_CODES = {
2
- VALIDATION: "VALIDATION_ERROR",
3
- NOT_FOUND: "NOT_FOUND",
4
- UNAUTHORIZED: "UNAUTHORIZED",
5
- FORBIDDEN: "FORBIDDEN",
6
- INTERNAL: "INTERNAL_ERROR",
7
- } as const;
8
-
9
- export default ERROR_CODES;
@@ -1,20 +0,0 @@
1
- function ts() {
2
- return new Date().toISOString();
3
- }
4
-
5
- export const info = (msg: string, meta?: any) => {
6
- console.log(`${ts()} INFO: ${msg}` + (meta ? ` ${JSON.stringify(meta)}` : ""));
7
- };
8
- export const warn = (msg: string, meta?: any) => {
9
- console.warn(`${ts()} WARN: ${msg}` + (meta ? ` ${JSON.stringify(meta)}` : ""));
10
- };
11
- export const error = (msg: string, meta?: any) => {
12
- console.error(`${ts()} ERROR: ${msg}` + (meta ? ` ${JSON.stringify(meta)}` : ""));
13
- };
14
- export const debug = (msg: string, meta?: any) => {
15
- if (process.env.NODE_ENV !== "production") {
16
- console.debug(`${ts()} DEBUG: ${msg}` + (meta ? ` ${JSON.stringify(meta)}` : ""));
17
- }
18
- };
19
-
20
- export default { info, warn, error, debug };
@@ -1,9 +0,0 @@
1
- import { NextFunction, Request, Response } from "express";
2
-
3
- export default function asyncHandler(
4
- fn: (req: Request, res: Response, next: NextFunction) => Promise<any>,
5
- ) {
6
- return (req: Request, res: Response, next: NextFunction) => {
7
- fn(req, res, next).catch(next);
8
- };
9
- }
@@ -1,9 +0,0 @@
1
- import { Response } from "express";
2
-
3
- export function success(res: Response, data: any, message = "Success", meta?: any) {
4
- return res.json({ success: true, message, data, meta });
5
- }
6
-
7
- export function fail(res: Response, status = 500, message = "Error", details?: any) {
8
- return res.status(status).json({ success: false, message, details });
9
- }