@sundaysf/cli-v2 1.0.1 → 1.0.3

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 (108) hide show
  1. package/README.md +178 -178
  2. package/dist/README.md +178 -178
  3. package/dist/bin/generators/class.js.map +1 -1
  4. package/dist/bin/generators/postman.js.map +1 -1
  5. package/dist/bin/index.js +1 -1
  6. package/dist/bin/index.js.map +1 -1
  7. package/dist/templates/backend/.claude/agents/knex-table-implementer.md +113 -113
  8. package/dist/templates/backend/.claude/agents/sundays-backend-builder.md +70 -70
  9. package/dist/templates/backend/.claude/settings.local.json +13 -13
  10. package/dist/templates/backend/.env.example +13 -13
  11. package/dist/templates/backend/.prettierignore +2 -2
  12. package/dist/templates/backend/.prettierrc +9 -9
  13. package/dist/templates/backend/CLAUDE.md +348 -348
  14. package/dist/templates/backend/Dockerfile +14 -14
  15. package/dist/templates/backend/README.md +18 -18
  16. package/dist/templates/backend/eslint.config.js +20 -20
  17. package/dist/templates/backend/src/app.ts +34 -34
  18. package/dist/templates/backend/src/common/config/origins/origins.config.ts +11 -11
  19. package/dist/templates/backend/src/common/utils/environment.resolver.ts +3 -3
  20. package/dist/templates/backend/src/common/utils/version.resolver.ts +4 -4
  21. package/dist/templates/backend/src/controllers/health/health.controller.ts +23 -23
  22. package/dist/templates/backend/src/middlewares/error/error.middleware.ts +21 -21
  23. package/dist/templates/backend/src/routes/health/health.router.ts +16 -16
  24. package/dist/templates/backend/src/routes/index.ts +57 -57
  25. package/dist/templates/backend/src/server.ts +16 -16
  26. package/dist/templates/backend/src/types.d.ts +10 -10
  27. package/dist/templates/backend/tsconfig.json +16 -16
  28. package/dist/templates/backend-db-sql/.claude/agents/knex-table-implementer.md +114 -114
  29. package/dist/templates/backend-db-sql/.claude/agents/sundays-backend-builder.md +70 -70
  30. package/dist/templates/backend-db-sql/.claude/settings.local.json +19 -19
  31. package/dist/templates/backend-db-sql/.env.example +13 -13
  32. package/dist/templates/backend-db-sql/.prettierignore +2 -2
  33. package/dist/templates/backend-db-sql/.prettierrc +9 -9
  34. package/dist/templates/backend-db-sql/CLAUDE.md +374 -374
  35. package/dist/templates/backend-db-sql/Dockerfile +17 -17
  36. package/dist/templates/backend-db-sql/README.md +34 -34
  37. package/dist/templates/backend-db-sql/db/knexfile.ts +33 -33
  38. package/dist/templates/backend-db-sql/db/migrations/001_create_sundays_package_version.ts +12 -12
  39. package/dist/templates/backend-db-sql/db/seeds/001_sundays_package_version_seed.ts +10 -10
  40. package/dist/templates/backend-db-sql/db/src/KnexConnection.ts +74 -74
  41. package/dist/templates/backend-db-sql/db/src/d.types.ts +18 -18
  42. package/dist/templates/backend-db-sql/db/src/dao/sundays-package-version/sundays-package-version.dao.ts +71 -71
  43. package/dist/templates/backend-db-sql/db/src/index.ts +9 -9
  44. package/dist/templates/backend-db-sql/db/src/interfaces/sundays-package-version/sundays-package-version.interfaces.ts +6 -6
  45. package/dist/templates/backend-db-sql/db/tsconfig.json +16 -16
  46. package/dist/templates/backend-db-sql/eslint.config.js +20 -20
  47. package/dist/templates/backend-db-sql/src/app.ts +34 -34
  48. package/dist/templates/backend-db-sql/src/common/config/origins/origins.config.ts +11 -11
  49. package/dist/templates/backend-db-sql/src/common/utils/environment.resolver.ts +3 -3
  50. package/dist/templates/backend-db-sql/src/common/utils/version.resolver.ts +4 -4
  51. package/dist/templates/backend-db-sql/src/controllers/health/health.controller.ts +23 -23
  52. package/dist/templates/backend-db-sql/src/middlewares/error/error.middleware.ts +21 -21
  53. package/dist/templates/backend-db-sql/src/routes/health/health.router.ts +16 -16
  54. package/dist/templates/backend-db-sql/src/routes/index.ts +57 -57
  55. package/dist/templates/backend-db-sql/src/server.ts +18 -18
  56. package/dist/templates/backend-db-sql/src/types.d.ts +10 -10
  57. package/dist/templates/backend-db-sql/tsconfig.json +16 -16
  58. package/dist/templates/backend-embedded-db-sql/.claude/agents/knex-table-implementer.md +116 -0
  59. package/dist/templates/backend-embedded-db-sql/.claude/agents/sundays-backend-builder.md +70 -0
  60. package/dist/templates/backend-embedded-db-sql/.claude/settings.local.json +18 -0
  61. package/dist/templates/backend-embedded-db-sql/.env.example +14 -0
  62. package/dist/templates/backend-embedded-db-sql/.prettierignore +3 -0
  63. package/dist/templates/backend-embedded-db-sql/.prettierrc +9 -0
  64. package/dist/templates/backend-embedded-db-sql/CLAUDE.md +371 -0
  65. package/dist/templates/backend-embedded-db-sql/Dockerfile +14 -0
  66. package/dist/templates/backend-embedded-db-sql/README.md +32 -0
  67. package/dist/templates/backend-embedded-db-sql/eslint.config.js +20 -0
  68. package/dist/templates/backend-embedded-db-sql/knexfile.ts +37 -0
  69. package/dist/templates/backend-embedded-db-sql/migrations/.gitkeep +0 -0
  70. package/dist/templates/backend-embedded-db-sql/migrations/001_create_sundays_package_version.ts +13 -0
  71. package/dist/templates/backend-embedded-db-sql/seeds/001_sundays_package_version_seed.ts +11 -0
  72. package/dist/templates/backend-embedded-db-sql/src/app.ts +35 -0
  73. package/dist/templates/backend-embedded-db-sql/src/common/config/origins/origins.config.ts +11 -0
  74. package/dist/templates/backend-embedded-db-sql/src/common/utils/environment.resolver.ts +4 -0
  75. package/dist/templates/backend-embedded-db-sql/src/common/utils/version.resolver.ts +5 -0
  76. package/dist/templates/backend-embedded-db-sql/src/controllers/health/health.controller.ts +24 -0
  77. package/dist/templates/backend-embedded-db-sql/src/db/KnexConnection.ts +74 -0
  78. package/dist/templates/backend-embedded-db-sql/src/db/d.types.ts +18 -0
  79. package/dist/templates/backend-embedded-db-sql/src/db/dao/sundays-package-version/sundays-package-version.dao.ts +71 -0
  80. package/dist/templates/backend-embedded-db-sql/src/db/index.ts +9 -0
  81. package/dist/templates/backend-embedded-db-sql/src/db/interfaces/sundays-package-version/sundays-package-version.interfaces.ts +6 -0
  82. package/dist/templates/backend-embedded-db-sql/src/middlewares/error/error.middleware.ts +21 -0
  83. package/dist/templates/backend-embedded-db-sql/src/routes/health/health.router.ts +17 -0
  84. package/dist/templates/backend-embedded-db-sql/src/routes/index.ts +57 -0
  85. package/dist/templates/backend-embedded-db-sql/src/server.ts +18 -0
  86. package/dist/templates/backend-embedded-db-sql/src/types.d.ts +10 -0
  87. package/dist/templates/backend-embedded-db-sql/tsconfig.json +16 -0
  88. package/dist/templates/db-sql/.claude/agents/knex-table-implementer.md +113 -113
  89. package/dist/templates/db-sql/.claude/agents/sundays-backend-builder.md +70 -70
  90. package/dist/templates/db-sql/.claude/settings.local.json +10 -10
  91. package/dist/templates/db-sql/.env.example +8 -8
  92. package/dist/templates/db-sql/CLAUDE.md +105 -105
  93. package/dist/templates/db-sql/knexfile.ts +33 -33
  94. package/dist/templates/db-sql/migrations/001_create_sundays_package_version.ts +12 -12
  95. package/dist/templates/db-sql/seeds/001_sundays_package_version_seed.ts +10 -10
  96. package/dist/templates/db-sql/src/KnexConnection.ts +74 -74
  97. package/dist/templates/db-sql/src/d.types.ts +18 -18
  98. package/dist/templates/db-sql/src/dao/sundays-package-version/sundays-package-version.dao.ts +71 -71
  99. package/dist/templates/db-sql/src/index.ts +9 -9
  100. package/dist/templates/db-sql/src/interfaces/sundays-package-version/sundays-package-version.interfaces.ts +6 -6
  101. package/dist/templates/db-sql/tsconfig.json +16 -16
  102. package/dist/templates/module/.claude/agents/knex-table-implementer.md +113 -113
  103. package/dist/templates/module/.claude/agents/sundays-backend-builder.md +70 -70
  104. package/dist/templates/module/.claude/settings.local.json +10 -10
  105. package/dist/templates/module/CLAUDE.md +158 -158
  106. package/dist/templates/module/src/index.ts +9 -9
  107. package/dist/templates/module/tsconfig.json +19 -19
  108. package/package.json +40 -40
@@ -1,35 +1,35 @@
1
- import dotenv from 'dotenv';
2
- import express, { type Express } from 'express';
3
- import logger from 'morgan';
4
- import cors from 'cors';
5
- import { IndexRouter } from './routes/index';
6
- import { errorMiddleware } from './middlewares/error/error.middleware';
7
- import { getAllowedOrigins } from './common/config/origins/origins.config';
8
- dotenv.config();
9
-
10
- const app: Express = express();
11
-
12
- app.use(
13
- logger('tiny', {
14
- skip: (req, _res) => {
15
- return req.originalUrl.startsWith('/api/health');
16
- },
17
- })
18
- );
19
-
20
- app.use(
21
- cors({
22
- origin: getAllowedOrigins(),
23
- credentials: true,
24
- allowedHeaders: ['Content-Type', 'Authorization'],
25
- })
26
- );
27
-
28
- app.use(express.urlencoded({ extended: true }));
29
- app.use(express.json());
30
-
31
- app.use('/api', new IndexRouter().router);
32
-
33
- app.use(errorMiddleware);
34
-
1
+ import dotenv from 'dotenv';
2
+ import express, { type Express } from 'express';
3
+ import logger from 'morgan';
4
+ import cors from 'cors';
5
+ import { IndexRouter } from './routes/index';
6
+ import { errorMiddleware } from './middlewares/error/error.middleware';
7
+ import { getAllowedOrigins } from './common/config/origins/origins.config';
8
+ dotenv.config();
9
+
10
+ const app: Express = express();
11
+
12
+ app.use(
13
+ logger('tiny', {
14
+ skip: (req, _res) => {
15
+ return req.originalUrl.startsWith('/api/health');
16
+ },
17
+ })
18
+ );
19
+
20
+ app.use(
21
+ cors({
22
+ origin: getAllowedOrigins(),
23
+ credentials: true,
24
+ allowedHeaders: ['Content-Type', 'Authorization'],
25
+ })
26
+ );
27
+
28
+ app.use(express.urlencoded({ extended: true }));
29
+ app.use(express.json());
30
+
31
+ app.use('/api', new IndexRouter().router);
32
+
33
+ app.use(errorMiddleware);
34
+
35
35
  export default app;
@@ -1,11 +1,11 @@
1
- export const getAllowedOrigins = (): string[] => {
2
- let origins: string = process.env.CORS_ALLOWED_ORIGINS || 'http://localhost:3098';
3
- origins = origins
4
- .split('\n')
5
- .join('')
6
- .split('\r')
7
- .join('')
8
- .split(' ')
9
- .join('');
10
- return origins.split(',');
11
- };
1
+ export const getAllowedOrigins = (): string[] => {
2
+ let origins: string = process.env.CORS_ALLOWED_ORIGINS || 'http://localhost:3098';
3
+ origins = origins
4
+ .split('\n')
5
+ .join('')
6
+ .split('\r')
7
+ .join('')
8
+ .split(' ')
9
+ .join('');
10
+ return origins.split(',');
11
+ };
@@ -1,4 +1,4 @@
1
- export const getServiceEnvironment = (): string => {
2
- const serEnv: string = process.env.ENVIRONMENT || 'undefined';
3
- return serEnv.charAt(0).toUpperCase() + serEnv.slice(1);
1
+ export const getServiceEnvironment = (): string => {
2
+ const serEnv: string = process.env.ENVIRONMENT || 'undefined';
3
+ return serEnv.charAt(0).toUpperCase() + serEnv.slice(1);
4
4
  };
@@ -1,5 +1,5 @@
1
- const pjson = require('../../../package.json');
2
-
3
- export const getServiceVersion = (): string => {
4
- return pjson['version'];
1
+ const pjson = require('../../../package.json');
2
+
3
+ export const getServiceVersion = (): string => {
4
+ return pjson['version'];
5
5
  };
@@ -1,24 +1,24 @@
1
- import { NextFunction, Request, Response } from 'express';
2
- import { getServiceVersion } from '../../common/utils/version.resolver';
3
- import { getServiceEnvironment } from '../../common/utils/environment.resolver';
4
-
5
- export class HealthController {
6
- public async getHealthStatus(
7
- _req: Request,
8
- res: Response,
9
- next: NextFunction
10
- ): Promise<void> {
11
- try {
12
- const version: string = await getServiceVersion();
13
- const environment: string = await getServiceEnvironment();
14
- res.status(200).json({
15
- success: true,
16
- health: 'Up!',
17
- version,
18
- environment,
19
- });
20
- } catch (err: any) {
21
- next(err);
22
- }
23
- }
1
+ import { NextFunction, Request, Response } from 'express';
2
+ import { getServiceVersion } from '../../common/utils/version.resolver';
3
+ import { getServiceEnvironment } from '../../common/utils/environment.resolver';
4
+
5
+ export class HealthController {
6
+ public async getHealthStatus(
7
+ _req: Request,
8
+ res: Response,
9
+ next: NextFunction
10
+ ): Promise<void> {
11
+ try {
12
+ const version: string = await getServiceVersion();
13
+ const environment: string = await getServiceEnvironment();
14
+ res.status(200).json({
15
+ success: true,
16
+ health: 'Up!',
17
+ version,
18
+ environment,
19
+ });
20
+ } catch (err: any) {
21
+ next(err);
22
+ }
23
+ }
24
24
  }
@@ -1,21 +1,21 @@
1
- import { NextFunction, Response, Request } from 'express';
2
- export const errorMiddleware = (
3
- err: any,
4
- req: Request | any,
5
- res: Response,
6
- _next: NextFunction
7
- ) => {
8
- console.error(err);
9
- const statusError: number =
10
- err.statusError ||
11
- err.statusCode ||
12
- err.status ||
13
- req.statusCode ||
14
- req.statusError ||
15
- 500;
16
- const isProduction = process.env.ENVIRONMENT === 'production';
17
- res.status(statusError).json({
18
- success: false,
19
- message: isProduction && statusError === 500 ? 'Internal server error' : err.message,
20
- });
21
- };
1
+ import { NextFunction, Response, Request } from 'express';
2
+ export const errorMiddleware = (
3
+ err: any,
4
+ req: Request | any,
5
+ res: Response,
6
+ _next: NextFunction
7
+ ) => {
8
+ console.error(err);
9
+ const statusError: number =
10
+ err.statusError ||
11
+ err.statusCode ||
12
+ err.status ||
13
+ req.statusCode ||
14
+ req.statusError ||
15
+ 500;
16
+ const isProduction = process.env.ENVIRONMENT === 'production';
17
+ res.status(statusError).json({
18
+ success: false,
19
+ message: isProduction && statusError === 500 ? 'Internal server error' : err.message,
20
+ });
21
+ };
@@ -1,17 +1,17 @@
1
- import { Router } from 'express';
2
- import { HealthController } from '../../controllers/health/health.controller';
3
-
4
- export class HealthRouter {
5
- public router: Router = Router();
6
- private readonly healthController: HealthController = new HealthController();
7
- constructor() {
8
- this.initRoutes();
9
- }
10
-
11
- private initRoutes(): void {
12
- this.router.get(
13
- '/',
14
- this.healthController.getHealthStatus.bind(this.healthController)
15
- );
16
- }
1
+ import { Router } from 'express';
2
+ import { HealthController } from '../../controllers/health/health.controller';
3
+
4
+ export class HealthRouter {
5
+ public router: Router = Router();
6
+ private readonly healthController: HealthController = new HealthController();
7
+ constructor() {
8
+ this.initRoutes();
9
+ }
10
+
11
+ private initRoutes(): void {
12
+ this.router.get(
13
+ '/',
14
+ this.healthController.getHealthStatus.bind(this.healthController)
15
+ );
16
+ }
17
17
  }
@@ -1,57 +1,57 @@
1
- import { Router } from 'express';
2
- import fs from 'fs';
3
- import path from 'path';
4
-
5
- export class IndexRouter {
6
- private _router: Router;
7
-
8
- constructor() {
9
- this._router = Router();
10
- this.loadRoutes();
11
- }
12
-
13
- private loadRoutes(): void {
14
- const routesPath = path.join(__dirname);
15
-
16
- const folders = fs.readdirSync(routesPath).filter(file =>
17
- fs.statSync(path.join(routesPath, file)).isDirectory()
18
- );
19
-
20
- folders.forEach(folder => {
21
- const baseName = `${folder}.router`;
22
- const tsPath = path.join(routesPath, folder, `${baseName}.ts`);
23
- const jsPath = path.join(routesPath, folder, `${baseName}.js`);
24
-
25
- let filePath = '';
26
- if (fs.existsSync(tsPath)) {
27
- filePath = tsPath;
28
- } else if (fs.existsSync(jsPath)) {
29
- filePath = jsPath;
30
- } else {
31
- console.warn(`[⚠] No route file found for: ${folder}`);
32
- return;
33
- }
34
-
35
- try {
36
- const routeModule = require(filePath);
37
- const RouterClass =
38
- routeModule.default || Object.values(routeModule).find((e) => typeof e === 'function');
39
-
40
- if (RouterClass) {
41
- const instance = new (RouterClass as any)();
42
- this._router.use(`/${folder}`, instance.router);
43
- console.log(`[✔] Route mounted: /${folder} → ${path.basename(filePath)}`);
44
- } else {
45
- console.warn(`[⚠] No class exported in: ${filePath}`);
46
- }
47
- } catch (err) {
48
- console.error(`[❌] Failed to load router at: ${filePath}`);
49
- console.error(err);
50
- }
51
- });
52
- }
53
-
54
- public get router(): Router {
55
- return this._router;
56
- }
57
- }
1
+ import { Router } from 'express';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+
5
+ export class IndexRouter {
6
+ private _router: Router;
7
+
8
+ constructor() {
9
+ this._router = Router();
10
+ this.loadRoutes();
11
+ }
12
+
13
+ private loadRoutes(): void {
14
+ const routesPath = path.join(__dirname);
15
+
16
+ const folders = fs.readdirSync(routesPath).filter(file =>
17
+ fs.statSync(path.join(routesPath, file)).isDirectory()
18
+ );
19
+
20
+ folders.forEach(folder => {
21
+ const baseName = `${folder}.router`;
22
+ const tsPath = path.join(routesPath, folder, `${baseName}.ts`);
23
+ const jsPath = path.join(routesPath, folder, `${baseName}.js`);
24
+
25
+ let filePath = '';
26
+ if (fs.existsSync(tsPath)) {
27
+ filePath = tsPath;
28
+ } else if (fs.existsSync(jsPath)) {
29
+ filePath = jsPath;
30
+ } else {
31
+ console.warn(`[⚠] No route file found for: ${folder}`);
32
+ return;
33
+ }
34
+
35
+ try {
36
+ const routeModule = require(filePath);
37
+ const RouterClass =
38
+ routeModule.default || Object.values(routeModule).find((e) => typeof e === 'function');
39
+
40
+ if (RouterClass) {
41
+ const instance = new (RouterClass as any)();
42
+ this._router.use(`/${folder}`, instance.router);
43
+ console.log(`[✔] Route mounted: /${folder} → ${path.basename(filePath)}`);
44
+ } else {
45
+ console.warn(`[⚠] No class exported in: ${filePath}`);
46
+ }
47
+ } catch (err) {
48
+ console.error(`[❌] Failed to load router at: ${filePath}`);
49
+ console.error(err);
50
+ }
51
+ });
52
+ }
53
+
54
+ public get router(): Router {
55
+ return this._router;
56
+ }
57
+ }
@@ -1,18 +1,18 @@
1
- import dotenv from 'dotenv';
2
- dotenv.config();
3
- import KnexManager from '../db/src/KnexConnection';
4
-
5
- const envPort: string = process.env.PORT || '3005';
6
-
7
- if (isNaN(parseInt(envPort))) {
8
- throw new Error('The port must to be a number');
9
- }
10
-
11
- const PORT: number = parseInt(envPort);
12
-
13
- (async () => {
14
- await KnexManager.connect();
15
- })().then(async () => {
16
- const { default: app } = await import('./app');
17
- app.listen(PORT, () => console.info(`Server up and running on port ${PORT}`));
18
- });
1
+ import dotenv from 'dotenv';
2
+ dotenv.config();
3
+ import KnexManager from '../db/src/KnexConnection';
4
+
5
+ const envPort: string = process.env.PORT || '3005';
6
+
7
+ if (isNaN(parseInt(envPort))) {
8
+ throw new Error('The port must to be a number');
9
+ }
10
+
11
+ const PORT: number = parseInt(envPort);
12
+
13
+ (async () => {
14
+ await KnexManager.connect();
15
+ })().then(async () => {
16
+ const { default: app } = await import('./app');
17
+ app.listen(PORT, () => console.info(`Server up and running on port ${PORT}`));
18
+ });
@@ -1,10 +1,10 @@
1
- import { Request, Response, NextFunction } from 'express';
2
-
3
- export interface IBaseController {
4
- getAll(req: Request, res: Response, next: NextFunction): Promise<void>;
5
- getByUuid(req: Request, res: Response, next: NextFunction): Promise<void>;
6
- create(req: Request, res: Response, next: NextFunction): Promise<void>;
7
- update(req: Request, res: Response, next: NextFunction): Promise<void>;
8
- patch(req: Request, res: Response, next: NextFunction): Promise<void>;
9
- delete(req: Request, res: Response, next: NextFunction): Promise<void>;
10
- }
1
+ import { Request, Response, NextFunction } from 'express';
2
+
3
+ export interface IBaseController {
4
+ getAll(req: Request, res: Response, next: NextFunction): Promise<void>;
5
+ getByUuid(req: Request, res: Response, next: NextFunction): Promise<void>;
6
+ create(req: Request, res: Response, next: NextFunction): Promise<void>;
7
+ update(req: Request, res: Response, next: NextFunction): Promise<void>;
8
+ patch(req: Request, res: Response, next: NextFunction): Promise<void>;
9
+ delete(req: Request, res: Response, next: NextFunction): Promise<void>;
10
+ }
@@ -1,16 +1,16 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "commonjs",
5
- "rootDir": "./src",
6
- "outDir": "./dist",
7
- "resolveJsonModule": true,
8
- "esModuleInterop": true,
9
- "forceConsistentCasingInFileNames": true,
10
- "strict": true,
11
- "noUnusedLocals": true,
12
- "skipLibCheck": true
13
- },
14
- "include": ["src/**/*"],
15
- "exclude": ["node_modules", "dist", "db"]
16
- }
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "commonjs",
5
+ "rootDir": "./src",
6
+ "outDir": "./dist",
7
+ "resolveJsonModule": true,
8
+ "esModuleInterop": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "strict": true,
11
+ "noUnusedLocals": true,
12
+ "skipLibCheck": true
13
+ },
14
+ "include": ["src/**/*"],
15
+ "exclude": ["node_modules", "dist", "db"]
16
+ }
@@ -0,0 +1,116 @@
1
+ ---
2
+ name: knex-table-implementer
3
+ description: Use this agent when you need to create new database table implementations in the Knex project, including migrations, DAOs, interfaces, and exports. This agent should be triggered when: 1) A new database table needs to be added to the system, 2) You need to implement the complete data access layer for a new entity, 3) You want to ensure consistency with the existing project structure and patterns. Examples: <example>Context: User needs to add a new 'product' table to the database. user: "I need to add a product table with id, name, price, and categoryId fields" assistant: "I'll use the knex-table-implementer agent to create the complete implementation for the product table including migration, DAO, interfaces, and exports" <commentary>Since the user needs a new table implementation in the Knex project, use the Task tool to launch the knex-table-implementer agent.</commentary></example> <example>Context: User wants to add a user management system. user: "Create a users table with authentication fields" assistant: "Let me use the knex-table-implementer agent to create the full users table implementation following the project patterns" <commentary>The user is requesting a new table implementation, so the knex-table-implementer agent should be used via the Task tool.</commentary></example>
4
+ model: sonnet
5
+ color: red
6
+ ---
7
+
8
+ You are an expert Knex.js database architect specializing in implementing consistent, production-ready database table structures following established project patterns.
9
+
10
+ **Your Core Responsibilities:**
11
+
12
+ You will create complete table implementations in the `src/db/` module by:
13
+ 1. Creating database migrations in the `migrations/` directory using the project's migration patterns
14
+ 2. Implementing DAO classes following the established DAO pattern
15
+ 3. Defining TypeScript interfaces for the entities
16
+ 4. Ensuring all exports are properly added to src/db/index.ts
17
+
18
+ **Implementation Workflow:**
19
+
20
+ 1. **Migration Creation**:
21
+ - Inform the user to run `npm run db:make-migration` to generate the migration file
22
+ - Write the migration with all database properties in camelCase
23
+ - Include proper up() and down() methods
24
+ - Follow the existing migration patterns in the project
25
+
26
+ 2. **DAO Implementation**:
27
+ - Create the DAO file at `src/db/dao/{entityName}/{entityName}.dao.ts`
28
+ - Extend from IBaseDAO interface
29
+ - Implement standard CRUD operations (getById, getAll with pagination, create, update, delete)
30
+ - Use KnexManager.getConnection() for database connections
31
+ - For related entities, use PostgreSQL's to_jsonb() function for joins
32
+ - Follow the exact pattern from existing DAOs like SundaysPackageVersionDAO
33
+
34
+ 3. **Interface Definition**:
35
+ - Create the interface file at `src/db/interfaces/{entityName}/{entityName}.interfaces.ts`
36
+ - Define the main entity interface with all properties
37
+ - Include any related entity interfaces if needed
38
+ - Ensure TypeScript types are properly defined
39
+
40
+ 4. **Export Configuration**:
41
+ - Add the new DAO export to src/db/index.ts
42
+ - Add the new interface export to src/db/index.ts
43
+ - Maintain alphabetical ordering in exports when possible
44
+
45
+ **Critical Standards You Must Follow**:
46
+
47
+ - **Naming Conventions**:
48
+ - Database columns: camelCase (e.g., createdAt, userId)
49
+ - Table names: snake_case or lowercase
50
+ - Class names: PascalCase with DAO suffix
51
+ - Interface names: Start with 'I' prefix
52
+
53
+ - **DAO Pattern Requirements**:
54
+ - Always implement IBaseDAO<T> interface
55
+ - Include pagination using IDataPaginator
56
+ - Use async/await for all database operations
57
+ - Return null for not found scenarios
58
+ - Use leftJoin with to_jsonb() for related entities
59
+
60
+ - **Code Structure**:
61
+ - One DAO class per file
62
+ - One interface file per entity
63
+ - Keep related logic together
64
+ - Use the singleton KnexManager for connections
65
+
66
+ **Example Patterns to Follow**:
67
+
68
+ For DAO methods with joins:
69
+ ```typescript
70
+ async getById(id: number): Promise<IEntity | null> {
71
+ const result = await this._knex("entity as e")
72
+ .leftJoin("related as r", "e.relatedId", "r.id")
73
+ .select("e.*", this._knex.raw("to_jsonb(r.*) as related"))
74
+ .where("e.id", id)
75
+ .first();
76
+ return result || null;
77
+ }
78
+ ```
79
+
80
+ For paginated results:
81
+ ```typescript
82
+ async getAll(limit: number, offset: number): Promise<IDataPaginator<IEntity>> {
83
+ const query = this._knex("entity");
84
+ const total = await query.clone().count("* as count").first();
85
+ const data = await query.clone().limit(limit).offset(offset).orderBy("id", "desc");
86
+ return {
87
+ data,
88
+ total: parseInt(total?.count as string) || 0,
89
+ limit,
90
+ offset
91
+ };
92
+ }
93
+ ```
94
+
95
+ **Quality Checks**:
96
+
97
+ Before completing any implementation, verify:
98
+ 1. Migration file uses camelCase for all properties
99
+ 2. DAO follows the exact structure of existing DAOs
100
+ 3. Interface properly types all entity properties
101
+ 4. All new exports are added to src/db/index.ts
102
+ 5. File paths follow the convention exactly (all under `src/db/`)
103
+ 6. No unnecessary files are created
104
+ 7. Code is consistent with existing patterns
105
+
106
+ **Important Reminders**:
107
+ - Only edit existing files when possible
108
+ - Never create documentation files unless explicitly requested
109
+ - Follow the CLAUDE.md instructions precisely
110
+ - Maintain consistency with the existing codebase structure
111
+ - Always use the established patterns from sundays-package-version as reference
112
+ - All database files live under the `src/db/` directory in this project
113
+ - Migrations live at the project root in `migrations/`
114
+ - Seeds live at the project root in `seeds/`
115
+
116
+ When you receive a request, first analyze the entity structure needed, then systematically create each component following the established patterns. If any clarification is needed about field types or relationships, ask before proceeding.
@@ -0,0 +1,70 @@
1
+ ---
2
+ name: sundays-backend-builder
3
+ description: Use this agent when you need to create or modify backend components in a Sundays Framework project. This includes creating new controllers, routers, services, implementing CRUD operations, or ensuring existing code follows the framework's strict architectural patterns. <example>Context: User needs to create a new API endpoint for managing products. user: 'I need to create a products API with full CRUD operations' assistant: 'I'll use the sundays-backend-builder agent to create the products API following the Sundays Framework standards' <commentary>Since the user needs to create backend components following Sundays Framework patterns, use the sundays-backend-builder agent to ensure proper structure and implementation.</commentary></example> <example>Context: User wants to add pagination to an existing controller. user: 'Add pagination to the orders controller getAll method' assistant: 'Let me use the sundays-backend-builder agent to implement proper pagination using IBasePaginator' <commentary>The user needs to modify a controller to follow Sundays Framework pagination patterns, so the sundays-backend-builder agent should be used.</commentary></example> <example>Context: User needs to fix a controller that doesn't follow standards. user: 'The customer controller isn't following our standards, can you fix it?' assistant: 'I'll use the sundays-backend-builder agent to refactor the customer controller to match our Sundays Framework standards' <commentary>Since the controller needs to be refactored to follow framework standards, the sundays-backend-builder agent is appropriate.</commentary></example>
4
+ model: sonnet
5
+ color: blue
6
+ ---
7
+
8
+ You are an expert backend developer specializing in the Sundays Framework architecture. Your mission is to build and maintain backend components that strictly adhere to the framework's established patterns and conventions.
9
+
10
+ **Core Responsibilities:**
11
+
12
+ 1. **Component Creation**: When creating new backend components, ALWAYS use `npm run create:controller` to scaffold the initial structure. This ensures consistency across the codebase.
13
+
14
+ 2. **Strict Structure Adherence**: You must follow these exact directory structures without deviation:
15
+ - Routes: `routes/<name>/<name>.router.ts`
16
+ - Controllers: `controllers/<name>/<name>.controller.ts`
17
+ - Services: `services/<name>/<name>.service.ts`
18
+ - DTOs: `dto/input/<entity>/<entity>.create.dto.ts` and `dto/input/<entity>/<entity>.update.dto.ts`
19
+
20
+ 3. **Interface Implementation**:
21
+ - ALL controllers MUST implement `IBaseController`
22
+ - ALL paginated getAll methods MUST use `IDataPaginator` (not IBasePaginator)
23
+ - ALWAYS use `paginationHelper` from `@sundaysf/utils` to extract page and limit from request
24
+
25
+ 4. **DAO/Service Pattern**:
26
+ - Initialize DAOs as private class members: `private _<entity>DAO: <Entity>DAO = new <Entity>DAO()`
27
+ - Follow the same pattern for services when applicable
28
+ - Use underscore prefix for private members
29
+
30
+ 5. **Method Implementation Standards**:
31
+ - **getAll**: Return paginated results using `IDataPaginator`, extract pagination with `paginationHelper(req)`
32
+ - **getByUuid**: Use UUID in params, convert to ID for DAO operations
33
+ - **create**: Validate with DTOs, generate UUID with `uuidv4()` in controller
34
+ - **update**: Get entity by UUID first to find ID, then update using DAO
35
+ - **delete**: Get entity by UUID first to find ID, then delete using DAO
36
+
37
+ 6. **Response Format**: ALL responses must follow:
38
+ ```json
39
+ {
40
+ "success": boolean,
41
+ "data": {...} // or "message": string
42
+ }
43
+ ```
44
+ Note: `IDataPaginator` already includes these fields, so don't double-wrap paginated responses.
45
+
46
+ 7. **Router Binding**: ALWAYS use `.bind(this._<entity>Controller)` when assigning controller methods to routes to maintain proper context.
47
+
48
+ 8. **Quality Checks**:
49
+ - Verify all imports are correct and from the right packages
50
+ - Ensure TypeScript types are properly defined
51
+ - Check that error handling uses `next(err)` pattern
52
+ - Validate that DTOs properly sanitize input data
53
+ - Confirm UUID generation happens in controller, not DTO or client-side
54
+
55
+ **Working Process**:
56
+
57
+ 1. When creating new components, first run `npm run create:controller` command
58
+ 2. Analyze existing similar components in the project for pattern reference
59
+ 3. Implement following the exact structure found in existing code
60
+ 4. Ensure all naming conventions match (camelCase for variables, PascalCase for classes)
61
+ 5. Test that all CRUD operations follow the established patterns
62
+
63
+ **Critical Rules**:
64
+ - NEVER deviate from the established folder structure
65
+ - NEVER create custom patterns - follow existing examples exactly
66
+ - ALWAYS check existing implementations before creating new ones
67
+ - ALWAYS maintain consistency with the project's CLAUDE.md guidelines
68
+ - Be extremely meticulous about structure - it must be perfect
69
+
70
+ Your code must be production-ready, following all Sundays Framework conventions to the letter. Every component you create or modify should seamlessly integrate with the existing architecture without requiring any adjustments to other parts of the system.
@@ -0,0 +1,18 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(cat:*)",
5
+ "Bash(npm run create:controller:*)",
6
+ "Bash(mkdir:*)",
7
+ "Bash(npm install:*)",
8
+ "Bash(npm run build:*)",
9
+ "Bash(npm run format:*)",
10
+ "Bash(npm run db:migrate:*)",
11
+ "Bash(npm run db:rollback:*)",
12
+ "Bash(npm run db:seed:*)",
13
+ "Bash(npm run db:make-migration:*)"
14
+ ],
15
+ "deny": [],
16
+ "ask": []
17
+ }
18
+ }