@sundaysf/cli-v2 0.0.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 (46) hide show
  1. package/README.md +178 -0
  2. package/dist/README.md +178 -0
  3. package/dist/bin/generators/class.js +2 -0
  4. package/dist/bin/generators/class.js.map +1 -0
  5. package/dist/bin/generators/postman.js +2 -0
  6. package/dist/bin/generators/postman.js.map +1 -0
  7. package/dist/bin/index.js +3 -0
  8. package/dist/bin/index.js.map +1 -0
  9. package/dist/templates/backend/.claude/agents/sundays-backend-builder.md +70 -0
  10. package/dist/templates/backend/.claude/settings.local.json +14 -0
  11. package/dist/templates/backend/.env.example +13 -0
  12. package/dist/templates/backend/.prettierignore +3 -0
  13. package/dist/templates/backend/.prettierrc +9 -0
  14. package/dist/templates/backend/CLAUDE.md +348 -0
  15. package/dist/templates/backend/Dockerfile +14 -0
  16. package/dist/templates/backend/README.md +18 -0
  17. package/dist/templates/backend/eslint.config.js +20 -0
  18. package/dist/templates/backend/src/app.ts +35 -0
  19. package/dist/templates/backend/src/common/config/origins/origins.config.ts +11 -0
  20. package/dist/templates/backend/src/common/utils/environment.resolver.ts +4 -0
  21. package/dist/templates/backend/src/common/utils/version.resolver.ts +5 -0
  22. package/dist/templates/backend/src/controllers/health/health.controller.ts +24 -0
  23. package/dist/templates/backend/src/middlewares/error/error.middleware.ts +21 -0
  24. package/dist/templates/backend/src/routes/health/health.router.ts +17 -0
  25. package/dist/templates/backend/src/routes/index.ts +57 -0
  26. package/dist/templates/backend/src/server.ts +16 -0
  27. package/dist/templates/backend/src/types.d.ts +10 -0
  28. package/dist/templates/backend/tsconfig.json +16 -0
  29. package/dist/templates/db-sql/.claude/agents/knex-table-implementer.md +113 -0
  30. package/dist/templates/db-sql/.claude/settings.local.json +11 -0
  31. package/dist/templates/db-sql/.env.example +8 -0
  32. package/dist/templates/db-sql/CLAUDE.md +106 -0
  33. package/dist/templates/db-sql/knexfile.ts +33 -0
  34. package/dist/templates/db-sql/migrations/.gitkeep +0 -0
  35. package/dist/templates/db-sql/migrations/001_create_sundays_package_version.ts +13 -0
  36. package/dist/templates/db-sql/seeds/001_sundays_package_version_seed.ts +11 -0
  37. package/dist/templates/db-sql/src/KnexConnection.ts +74 -0
  38. package/dist/templates/db-sql/src/d.types.ts +18 -0
  39. package/dist/templates/db-sql/src/dao/sundays-package-version/sundays-package-version.dao.ts +71 -0
  40. package/dist/templates/db-sql/src/index.ts +9 -0
  41. package/dist/templates/db-sql/src/interfaces/sundays-package-version/sundays-package-version.interfaces.ts +6 -0
  42. package/dist/templates/db-sql/tsconfig.json +16 -0
  43. package/dist/templates/module/CLAUDE.md +159 -0
  44. package/dist/templates/module/src/index.ts +9 -0
  45. package/dist/templates/module/tsconfig.json +19 -0
  46. package/package.json +40 -0
package/README.md ADDED
@@ -0,0 +1,178 @@
1
+ # 🚀 Sundays Framework - The Backend Architect's Dream
2
+
3
+ > *"Why waste weekdays struggling with boilerplate when you can build like it's Sunday?"* - Paul Sundays
4
+
5
+ Welcome to **Sundays Framework**, where backend development meets architectural elegance. Created by Paul Sundays, your personal backend architect, this framework transforms the way you build scalable, production-ready applications.
6
+
7
+ ## 🌟 Why Sundays Framework?
8
+
9
+ In a world of complex setups and endless configurations, Sundays Framework stands as your beacon of simplicity and power. We believe that great architecture shouldn't require a PhD to implement. That's why we've crafted every line of code with love, ensuring you spend less time configuring and more time creating.
10
+
11
+ ### ✨ Features That Make Every Day Feel Like Sunday
12
+
13
+ - **🏗️ Zero-Config Architecture**: Start building in seconds, not hours
14
+ - **🎯 Type-Safe Everything**: TypeScript-first approach for bulletproof code
15
+ - **⚡ Lightning Fast Setup**: From zero to API in under 60 seconds
16
+ - **🔧 Smart Code Generation**: Controllers, routes, and DAOs created automagically
17
+ - **📦 Production-Ready**: Docker, migrations, and best practices out of the box
18
+ - **🎨 Clean Code Philosophy**: Because beautiful code is maintainable code
19
+
20
+ ## 🎯 Quick Start - Your Sunday Begins Now
21
+
22
+ Paul Sundays here! Let me guide you through the smoothest setup experience you've ever had. Choose your adventure:
23
+
24
+ ### 🏃‍♂️ Backend API Template
25
+ ```bash
26
+ npx @sundaysf/cli --init --backend
27
+ ```
28
+ *Perfect for REST APIs, microservices, and full-stack backends*
29
+
30
+ ### 🗄️ Database SQL Module
31
+ ```bash
32
+ npx @sundaysf/cli --init --db-sql
33
+ ```
34
+ *Ideal for database layers with Knex.js, migrations, and seeds*
35
+
36
+ ### 📦 Basic Module Template
37
+ ```bash
38
+ npx @sundaysf/cli --init --module
39
+ ```
40
+ *Great for npm packages and shared libraries*
41
+
42
+ > **Pro tip from Paul**: Each template comes pre-configured with everything you need. No more "how do I structure this?" moments!
43
+ ## ⚙️ Configuration - Set It and Forget It
44
+
45
+ After initialization, you'll find a `.env.example` file. Simply:
46
+
47
+ ```bash
48
+ cp .env.example .env
49
+ ```
50
+
51
+ Customize your environment variables, and you're ready to rock! The framework handles the rest with sensible defaults.
52
+
53
+ ## 🎨 Magic Controller Generation
54
+
55
+ Watch as Paul Sundays works his magic! Need a new feature? Let's create a controller with all CRUD operations in seconds:
56
+
57
+ ```bash
58
+ npm run create:controller
59
+ ```
60
+
61
+ ### What You Get:
62
+ - ✅ **Full CRUD Operations**: GET, GET by UUID, CREATE, UPDATE, DELETE
63
+ - ✅ **Type-Safe Routes**: Automatically generated with proper TypeScript types
64
+ - ✅ **Postman Collection**: API documentation generated on the fly
65
+ - ✅ **Best Practices**: Error handling, validation, and clean architecture
66
+
67
+ > **Paul's Secret**: Each controller follows the same battle-tested patterns I've refined over years of Sunday coding sessions!
68
+
69
+ ## 🛠️ Development Commands - Your Sunday Toolkit
70
+
71
+ ### 🔥 Development Mode
72
+ ```bash
73
+ npm run start:dev
74
+ ```
75
+ *Hot-reloading enabled! Code like the wind, see changes instantly.*
76
+
77
+ ### 🏗️ Build for Production
78
+ ```bash
79
+ npm run build
80
+ ```
81
+ *TypeScript → JavaScript transformation with optimization magic.*
82
+
83
+ ### 🚀 Production Server
84
+ ```bash
85
+ npm run start
86
+ ```
87
+ *Battle-tested, production-ready, and blazing fast.*
88
+
89
+ ### 🗄️ Database Commands (db-sql template)
90
+ ```bash
91
+ npm run migrate:create # Create a new migration
92
+ npm run migrate:deploy # Run pending migrations
93
+ npm run seed:create # Create a new seed file
94
+ npm run seed:run # Populate your database
95
+ ```
96
+
97
+ ### 🎯 Code Quality
98
+ ```bash
99
+ npm run format # Prettier auto-formatting
100
+ npm run lint # ESLint code analysis
101
+ npm test # Run your test suite
102
+ ```
103
+
104
+ ## 🐳 Docker Support - Ship It Like a Pro
105
+
106
+ Paul Sundays believes in shipping with confidence. That's why every backend template includes a production-ready Dockerfile!
107
+
108
+ ### 📦 Build Your Container
109
+ ```bash
110
+ docker build -t my-sunday-api .
111
+ ```
112
+
113
+ ### 🚢 Launch to the Cloud
114
+ ```bash
115
+ docker run -p 3098:3098 my-sunday-api
116
+ ```
117
+
118
+ ### 🎯 Docker Compose Ready
119
+ ```yaml
120
+ version: '3.8'
121
+ services:
122
+ api:
123
+ build: .
124
+ ports:
125
+ - "3098:3098"
126
+ environment:
127
+ - NODE_ENV=production
128
+ volumes:
129
+ - ./logs:/app/logs
130
+ ```
131
+
132
+ ## 🏗️ Project Structure - Organized Like Sunday Brunch
133
+
134
+ ```
135
+ your-project/
136
+ ├── src/
137
+ │ ├── controllers/ # Your business logic lives here
138
+ │ ├── routes/ # RESTful route definitions
139
+ │ ├── services/ # Reusable service layer
140
+ │ ├── middlewares/ # Express middleware magic
141
+ │ ├── dao/ # Data Access Objects (db-sql)
142
+ │ └── interfaces/ # TypeScript interfaces
143
+ ├── migrations/ # Database evolution scripts
144
+ ├── seeds/ # Sample data for development
145
+ ├── dist/ # Compiled production code
146
+ └── postman.json # Auto-generated API docs
147
+ ```
148
+
149
+ ## 🎓 Philosophy - The Sunday Way
150
+
151
+ **"Code on Sundays, Deploy on Mondays"**
152
+
153
+ We believe that:
154
+ - 🌟 **Simplicity is the ultimate sophistication**
155
+ - 🎯 **Convention over configuration saves lives**
156
+ - 🚀 **Developer experience is user experience**
157
+ - 💪 **Great frameworks empower, not constrain**
158
+
159
+ ## 🤝 Join the Sunday Revolution
160
+
161
+ Created with ❤️ by Paul Sundays, your backend architect who believes every developer deserves tools that spark joy.
162
+
163
+ ### 🌐 Connect with Paul
164
+ - 📧 Feedback: Create an issue and let's make Sundays even better!
165
+ - 🐛 Found a bug? You've discovered a weekday trying to sneak in!
166
+ - 💡 Have an idea? Sunday brainstorming sessions are the best!
167
+
168
+ ## 📜 License
169
+
170
+ MIT License - Because Sundays are meant to be free!
171
+
172
+ ---
173
+
174
+ *Remember: When you code with Sundays Framework, every day feels like the weekend. Now go build something amazing!*
175
+
176
+ **Happy Sunday Coding! 🎉**
177
+
178
+ *- Paul Sundays, Your Backend Architect*
package/dist/README.md ADDED
@@ -0,0 +1,178 @@
1
+ # 🚀 Sundays Framework - The Backend Architect's Dream
2
+
3
+ > *"Why waste weekdays struggling with boilerplate when you can build like it's Sunday?"* - Paul Sundays
4
+
5
+ Welcome to **Sundays Framework**, where backend development meets architectural elegance. Created by Paul Sundays, your personal backend architect, this framework transforms the way you build scalable, production-ready applications.
6
+
7
+ ## 🌟 Why Sundays Framework?
8
+
9
+ In a world of complex setups and endless configurations, Sundays Framework stands as your beacon of simplicity and power. We believe that great architecture shouldn't require a PhD to implement. That's why we've crafted every line of code with love, ensuring you spend less time configuring and more time creating.
10
+
11
+ ### ✨ Features That Make Every Day Feel Like Sunday
12
+
13
+ - **🏗️ Zero-Config Architecture**: Start building in seconds, not hours
14
+ - **🎯 Type-Safe Everything**: TypeScript-first approach for bulletproof code
15
+ - **⚡ Lightning Fast Setup**: From zero to API in under 60 seconds
16
+ - **🔧 Smart Code Generation**: Controllers, routes, and DAOs created automagically
17
+ - **📦 Production-Ready**: Docker, migrations, and best practices out of the box
18
+ - **🎨 Clean Code Philosophy**: Because beautiful code is maintainable code
19
+
20
+ ## 🎯 Quick Start - Your Sunday Begins Now
21
+
22
+ Paul Sundays here! Let me guide you through the smoothest setup experience you've ever had. Choose your adventure:
23
+
24
+ ### 🏃‍♂️ Backend API Template
25
+ ```bash
26
+ npx @sundaysf/cli --init --backend
27
+ ```
28
+ *Perfect for REST APIs, microservices, and full-stack backends*
29
+
30
+ ### 🗄️ Database SQL Module
31
+ ```bash
32
+ npx @sundaysf/cli --init --db-sql
33
+ ```
34
+ *Ideal for database layers with Knex.js, migrations, and seeds*
35
+
36
+ ### 📦 Basic Module Template
37
+ ```bash
38
+ npx @sundaysf/cli --init --module
39
+ ```
40
+ *Great for npm packages and shared libraries*
41
+
42
+ > **Pro tip from Paul**: Each template comes pre-configured with everything you need. No more "how do I structure this?" moments!
43
+ ## ⚙️ Configuration - Set It and Forget It
44
+
45
+ After initialization, you'll find a `.env.example` file. Simply:
46
+
47
+ ```bash
48
+ cp .env.example .env
49
+ ```
50
+
51
+ Customize your environment variables, and you're ready to rock! The framework handles the rest with sensible defaults.
52
+
53
+ ## 🎨 Magic Controller Generation
54
+
55
+ Watch as Paul Sundays works his magic! Need a new feature? Let's create a controller with all CRUD operations in seconds:
56
+
57
+ ```bash
58
+ npm run create:controller
59
+ ```
60
+
61
+ ### What You Get:
62
+ - ✅ **Full CRUD Operations**: GET, GET by UUID, CREATE, UPDATE, DELETE
63
+ - ✅ **Type-Safe Routes**: Automatically generated with proper TypeScript types
64
+ - ✅ **Postman Collection**: API documentation generated on the fly
65
+ - ✅ **Best Practices**: Error handling, validation, and clean architecture
66
+
67
+ > **Paul's Secret**: Each controller follows the same battle-tested patterns I've refined over years of Sunday coding sessions!
68
+
69
+ ## 🛠️ Development Commands - Your Sunday Toolkit
70
+
71
+ ### 🔥 Development Mode
72
+ ```bash
73
+ npm run start:dev
74
+ ```
75
+ *Hot-reloading enabled! Code like the wind, see changes instantly.*
76
+
77
+ ### 🏗️ Build for Production
78
+ ```bash
79
+ npm run build
80
+ ```
81
+ *TypeScript → JavaScript transformation with optimization magic.*
82
+
83
+ ### 🚀 Production Server
84
+ ```bash
85
+ npm run start
86
+ ```
87
+ *Battle-tested, production-ready, and blazing fast.*
88
+
89
+ ### 🗄️ Database Commands (db-sql template)
90
+ ```bash
91
+ npm run migrate:create # Create a new migration
92
+ npm run migrate:deploy # Run pending migrations
93
+ npm run seed:create # Create a new seed file
94
+ npm run seed:run # Populate your database
95
+ ```
96
+
97
+ ### 🎯 Code Quality
98
+ ```bash
99
+ npm run format # Prettier auto-formatting
100
+ npm run lint # ESLint code analysis
101
+ npm test # Run your test suite
102
+ ```
103
+
104
+ ## 🐳 Docker Support - Ship It Like a Pro
105
+
106
+ Paul Sundays believes in shipping with confidence. That's why every backend template includes a production-ready Dockerfile!
107
+
108
+ ### 📦 Build Your Container
109
+ ```bash
110
+ docker build -t my-sunday-api .
111
+ ```
112
+
113
+ ### 🚢 Launch to the Cloud
114
+ ```bash
115
+ docker run -p 3098:3098 my-sunday-api
116
+ ```
117
+
118
+ ### 🎯 Docker Compose Ready
119
+ ```yaml
120
+ version: '3.8'
121
+ services:
122
+ api:
123
+ build: .
124
+ ports:
125
+ - "3098:3098"
126
+ environment:
127
+ - NODE_ENV=production
128
+ volumes:
129
+ - ./logs:/app/logs
130
+ ```
131
+
132
+ ## 🏗️ Project Structure - Organized Like Sunday Brunch
133
+
134
+ ```
135
+ your-project/
136
+ ├── src/
137
+ │ ├── controllers/ # Your business logic lives here
138
+ │ ├── routes/ # RESTful route definitions
139
+ │ ├── services/ # Reusable service layer
140
+ │ ├── middlewares/ # Express middleware magic
141
+ │ ├── dao/ # Data Access Objects (db-sql)
142
+ │ └── interfaces/ # TypeScript interfaces
143
+ ├── migrations/ # Database evolution scripts
144
+ ├── seeds/ # Sample data for development
145
+ ├── dist/ # Compiled production code
146
+ └── postman.json # Auto-generated API docs
147
+ ```
148
+
149
+ ## 🎓 Philosophy - The Sunday Way
150
+
151
+ **"Code on Sundays, Deploy on Mondays"**
152
+
153
+ We believe that:
154
+ - 🌟 **Simplicity is the ultimate sophistication**
155
+ - 🎯 **Convention over configuration saves lives**
156
+ - 🚀 **Developer experience is user experience**
157
+ - 💪 **Great frameworks empower, not constrain**
158
+
159
+ ## 🤝 Join the Sunday Revolution
160
+
161
+ Created with ❤️ by Paul Sundays, your backend architect who believes every developer deserves tools that spark joy.
162
+
163
+ ### 🌐 Connect with Paul
164
+ - 📧 Feedback: Create an issue and let's make Sundays even better!
165
+ - 🐛 Found a bug? You've discovered a weekday trying to sneak in!
166
+ - 💡 Have an idea? Sunday brainstorming sessions are the best!
167
+
168
+ ## 📜 License
169
+
170
+ MIT License - Because Sundays are meant to be free!
171
+
172
+ ---
173
+
174
+ *Remember: When you code with Sundays Framework, every day feels like the weekend. Now go build something amazing!*
175
+
176
+ **Happy Sunday Coding! 🎉**
177
+
178
+ *- Paul Sundays, Your Backend Architect*
@@ -0,0 +1,2 @@
1
+ export const generateController=n=>`\n import { Request, Response, NextFunction } from 'express';\n import { IBaseController } from '../../types';\n\n export class ${n} implements IBaseController{\n\n public async getAll(req: Request, res: Response, next: NextFunction): Promise<void>{\n try{\n // TODO: implement\n res.status(200).json({ success: true, data: [] });\n }catch(err: unknown){\n next(err);\n }\n }\n\n public async getByUuid(req: Request, res: Response, next: NextFunction): Promise<void>{\n try{\n const { uuid } = req.params;\n // TODO: implement\n res.status(200).json({ success: true, data: null });\n }catch(err: unknown){\n next(err);\n }\n }\n\n public async update(req: Request, res: Response, next: NextFunction): Promise<void>{\n try{\n const { uuid } = req.params;\n // TODO: implement\n res.status(200).json({ success: true, data: null });\n }catch(err: unknown){\n next(err);\n }\n }\n\n public async patch(req: Request, res: Response, next: NextFunction): Promise<void>{\n try{\n const { uuid } = req.params;\n // TODO: implement\n res.status(200).json({ success: true, data: null });\n }catch(err: unknown){\n next(err);\n }\n }\n\n public async create(req: Request, res: Response, next: NextFunction): Promise<void>{\n try{\n // TODO: implement\n res.status(201).json({ success: true, data: null });\n }catch(err: unknown){\n next(err);\n }\n }\n\n public async delete(req: Request, res: Response, next: NextFunction): Promise<void>{\n try{\n const { uuid } = req.params;\n // TODO: implement\n res.status(200).json({ success: true, data: null });\n }catch(err: unknown){\n next(err);\n }\n }\n }\n\n `;export const generateRouter=(n,e,t)=>`\n import { Router } from 'express';\n import { ${e} } from '../../controllers/${t}/${t}.controller';\n\n export class ${n}{\n private _router: Router;\n private _${t}Controller = new ${e}();\n constructor(){\n this._router = Router();\n this.initRoutes();\n }\n private initRoutes(): void {\n this._router.get("/", this._${t}Controller.getAll.bind(this._${t}Controller));\n this._router.get("/:uuid", this._${t}Controller.getByUuid.bind(this._${t}Controller));\n this._router.put("/:uuid", this._${t}Controller.update.bind(this._${t}Controller));\n this._router.patch("/:uuid", this._${t}Controller.patch.bind(this._${t}Controller));\n this._router.post("/", this._${t}Controller.create.bind(this._${t}Controller));\n this._router.delete("/:uuid", this._${t}Controller.delete.bind(this._${t}Controller));\n }\n public get router(): Router {\n return this._router;\n }\n }\n\n `;
2
+ //# sourceMappingURL=class.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class.js","names":["generateController","className","generateRouter","controllerClassName","controllerDirectoryName"],"sources":["bin/generators/class.js"],"mappings":"OAAO,MAAMA,mBAAsBC,GACV,wJAIFA,gwEAwEhB,MAAMC,eAAiB,CAACD,EAAWE,EAAqBC,IACtC,iEAEND,+BAAiDC,KAA2BA,0CAExEH,kEAEAG,qBAA2CD,wNAMpBC,iCAAuDA,oEAClDA,oCAA0DA,oEAC1DA,iCAAuDA,sEACrDA,gCAAsDA,gEAC5DA,iCAAuDA,uEAChDA,iCAAuDA","ignoreList":[],"sourcesContent":["export const generateController = (className) => {\r\n const classContent = `\r\n import { Request, Response, NextFunction } from 'express';\r\n import { IBaseController } from '../../types';\r\n\r\n export class ${className} implements IBaseController{\r\n\r\n public async getAll(req: Request, res: Response, next: NextFunction): Promise<void>{\r\n try{\r\n // TODO: implement\r\n res.status(200).json({ success: true, data: [] });\r\n }catch(err: unknown){\r\n next(err);\r\n }\r\n }\r\n\r\n public async getByUuid(req: Request, res: Response, next: NextFunction): Promise<void>{\r\n try{\r\n const { uuid } = req.params;\r\n // TODO: implement\r\n res.status(200).json({ success: true, data: null });\r\n }catch(err: unknown){\r\n next(err);\r\n }\r\n }\r\n\r\n public async update(req: Request, res: Response, next: NextFunction): Promise<void>{\r\n try{\r\n const { uuid } = req.params;\r\n // TODO: implement\r\n res.status(200).json({ success: true, data: null });\r\n }catch(err: unknown){\r\n next(err);\r\n }\r\n }\r\n\r\n public async patch(req: Request, res: Response, next: NextFunction): Promise<void>{\r\n try{\r\n const { uuid } = req.params;\r\n // TODO: implement\r\n res.status(200).json({ success: true, data: null });\r\n }catch(err: unknown){\r\n next(err);\r\n }\r\n }\r\n\r\n public async create(req: Request, res: Response, next: NextFunction): Promise<void>{\r\n try{\r\n // TODO: implement\r\n res.status(201).json({ success: true, data: null });\r\n }catch(err: unknown){\r\n next(err);\r\n }\r\n }\r\n\r\n public async delete(req: Request, res: Response, next: NextFunction): Promise<void>{\r\n try{\r\n const { uuid } = req.params;\r\n // TODO: implement\r\n res.status(200).json({ success: true, data: null });\r\n }catch(err: unknown){\r\n next(err);\r\n }\r\n }\r\n }\r\n\r\n `\r\n return classContent;\r\n}\r\n\r\n/**\r\n *\r\n * @param {String} className\r\n * @param {String} controllerClassName\r\n * @param {String} controllerDirectoryName\r\n * @returns {String}\r\n */\r\nexport const generateRouter = (className, controllerClassName, controllerDirectoryName) => {\r\n const classContent = `\r\n import { Router } from 'express';\r\n import { ${controllerClassName} } from '../../controllers/${controllerDirectoryName}/${controllerDirectoryName}.controller';\r\n\r\n export class ${className}{\r\n private _router: Router;\r\n private _${controllerDirectoryName}Controller = new ${controllerClassName}();\r\n constructor(){\r\n this._router = Router();\r\n this.initRoutes();\r\n }\r\n private initRoutes(): void {\r\n this._router.get(\"/\", this._${controllerDirectoryName}Controller.getAll.bind(this._${controllerDirectoryName}Controller));\r\n this._router.get(\"/:uuid\", this._${controllerDirectoryName}Controller.getByUuid.bind(this._${controllerDirectoryName}Controller));\r\n this._router.put(\"/:uuid\", this._${controllerDirectoryName}Controller.update.bind(this._${controllerDirectoryName}Controller));\r\n this._router.patch(\"/:uuid\", this._${controllerDirectoryName}Controller.patch.bind(this._${controllerDirectoryName}Controller));\r\n this._router.post(\"/\", this._${controllerDirectoryName}Controller.create.bind(this._${controllerDirectoryName}Controller));\r\n this._router.delete(\"/:uuid\", this._${controllerDirectoryName}Controller.delete.bind(this._${controllerDirectoryName}Controller));\r\n }\r\n public get router(): Router {\r\n return this._router;\r\n }\r\n }\r\n\r\n `\r\n return classContent;\r\n}\r\n"]}
@@ -0,0 +1,2 @@
1
+ import{toCamel}from"ts-case-convert";import{v4 as uuidv4}from"uuid";export const generateBasePostman=e=>{const t={};return t.info={_postman_id:uuidv4(),name:e,schema:"https://schema.getpostman.com/json/collection/v2.1.0/collection.json"},t.item=[],t.event=[{listen:"prerequest",script:{type:"text/javascript",packages:{},exec:[""]}},{listen:"test",script:{type:"text/javascript",packages:{},exec:[""]}}],t.variable=[{key:`${toCamel(e)}BackendHost`,value:"http://localhost:<PORT>",type:"string"},{key:`${toCamel(e)}BearerToken`,value:"<token>",type:"string"}],t};export const getItemFormatted=(e,t)=>{const a={type:"bearer",bearer:[{key:"token",value:`{{${toCamel(t)}BearerToken}}`,type:"string"}]},r=(a="",r=[])=>{const o=`{{${toCamel(t)}BackendHost}}/api/${e}${a}`,s=["api",e];a&&s.push(a.replace("/",""));const n={raw:o,host:[`{{${toCamel(t)}BackendHost}}`],path:s};return r.length>0&&(n.variable=r),n},o=[{key:"uuid",value:"<uuid>"}],s={mode:"raw",raw:"{}",options:{raw:{language:"json"}}};return{name:e,item:[{name:"GET ALL",request:{auth:a,method:"GET",header:[],url:r()},response:[]},{name:"GET BY UUID",request:{auth:a,method:"GET",header:[],url:r("/:uuid",o)},response:[]},{name:"CREATE",request:{auth:a,method:"POST",header:[],body:s,url:r()},response:[]},{name:"UPDATE",request:{auth:a,method:"PUT",header:[],body:s,url:r("/:uuid",o)},response:[]},{name:"PATCH",request:{auth:a,method:"PATCH",header:[],body:s,url:r("/:uuid",o)},response:[]},{name:"DELETE",request:{auth:a,method:"DELETE",header:[],url:r("/:uuid",o)},response:[]}]}};
2
+ //# sourceMappingURL=postman.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postman.js","names":["toCamel","uuidv4","generateBasePostman","projectName","baseData","info","_postman_id","name","schema","item","event","listen","script","type","packages","exec","variable","key","value","getItemFormatted","controllerDirectoryName","authBearer","bearer","makeUrl","pathSuffix","variables","raw","pathParts","push","replace","url","host","path","length","uuidVariable","jsonBody","mode","options","language","request","auth","method","header","response","body"],"sources":["bin/generators/postman.js"],"mappings":"OAASA,YAAe,+BACTC,WAAc,cAEtB,MAAMC,oBAAuBC,IAChC,MAAMC,EAAW,CAAC,EAyClB,OAxCAA,EAASC,KAAO,CACZC,YAAaL,SACbM,KAAMJ,EACNK,OAAQ,wEAEZJ,EAASK,KAAO,GAChBL,EAASM,MAAQ,CACb,CACIC,OAAU,aACVC,OAAU,CACNC,KAAQ,kBACRC,SAAY,CAAC,EACbC,KAAQ,CACJ,MAIZ,CACIJ,OAAU,OACVC,OAAU,CACNC,KAAQ,kBACRC,SAAY,CAAC,EACbC,KAAQ,CACJ,OAKhBX,EAASY,SAAW,CAChB,CACIC,IAAO,GAAGjB,QAAQG,gBAClBe,MAAS,0BACTL,KAAQ,UAEZ,CACII,IAAO,GAAGjB,QAAQG,gBAClBe,MAAS,UACTL,KAAQ,WAGTT,CAAQ,SASZ,MAAMe,iBAAmB,CAACC,EAAyBjB,KACtD,MAAMkB,EAAa,CACfR,KAAQ,SACRS,OAAU,CACN,CACIL,IAAO,QACPC,MAAS,KAAKlB,QAAQG,kBACtBU,KAAQ,YAKdU,EAAU,CAACC,EAAa,GAAIC,EAAY,MAC1C,MAAMC,EAAM,KAAK1B,QAAQG,uBAAiCiB,IAA0BI,IAC9EG,EAAY,CAAC,MAAOP,GACtBI,GAAYG,EAAUC,KAAKJ,EAAWK,QAAQ,IAAK,KAEvD,MAAMC,EAAM,CACRJ,MACAK,KAAQ,CAAC,KAAK/B,QAAQG,mBACtB6B,KAAQL,GAGZ,OADIF,EAAUQ,OAAS,IAAGH,EAAId,SAAWS,GAClCK,CAAG,EAGRI,EAAe,CAAC,CAAEjB,IAAO,OAAQC,MAAS,WAC1CiB,EAAW,CACbC,KAAQ,MACRV,IAAO,KACPW,QAAW,CAAEX,IAAO,CAAEY,SAAY,UAGtC,MAAO,CACH/B,KAAQa,EACRX,KAAQ,CACJ,CACIF,KAAQ,UACRgC,QAAW,CACPC,KAAQnB,EACRoB,OAAU,MACVC,OAAU,GACVZ,IAAOP,KAEXoB,SAAY,IAEhB,CACIpC,KAAQ,cACRgC,QAAW,CACPC,KAAQnB,EACRoB,OAAU,MACVC,OAAU,GACVZ,IAAOP,EAAQ,SAAUW,IAE7BS,SAAY,IAEhB,CACIpC,KAAQ,SACRgC,QAAW,CACPC,KAAQnB,EACRoB,OAAU,OACVC,OAAU,GACVE,KAAQT,EACRL,IAAOP,KAEXoB,SAAY,IAEhB,CACIpC,KAAQ,SACRgC,QAAW,CACPC,KAAQnB,EACRoB,OAAU,MACVC,OAAU,GACVE,KAAQT,EACRL,IAAOP,EAAQ,SAAUW,IAE7BS,SAAY,IAEhB,CACIpC,KAAQ,QACRgC,QAAW,CACPC,KAAQnB,EACRoB,OAAU,QACVC,OAAU,GACVE,KAAQT,EACRL,IAAOP,EAAQ,SAAUW,IAE7BS,SAAY,IAEhB,CACIpC,KAAQ,SACRgC,QAAW,CACPC,KAAQnB,EACRoB,OAAU,SACVC,OAAU,GACVZ,IAAOP,EAAQ,SAAUW,IAE7BS,SAAY,KAGxB","ignoreList":[],"sourcesContent":["import { toCamel } from 'ts-case-convert';\r\nimport { v4 as uuidv4 } from 'uuid';\r\n\r\nexport const generateBasePostman = (projectName) => {\r\n const baseData = {}\r\n baseData.info = {\r\n _postman_id: uuidv4(),\r\n name: projectName,\r\n schema: \"https://schema.getpostman.com/json/collection/v2.1.0/collection.json\"\r\n };\r\n baseData.item = [];\r\n baseData.event = [\r\n {\r\n \"listen\": \"prerequest\",\r\n \"script\": {\r\n \"type\": \"text/javascript\",\r\n \"packages\": {},\r\n \"exec\": [\r\n \"\"\r\n ]\r\n }\r\n },\r\n {\r\n \"listen\": \"test\",\r\n \"script\": {\r\n \"type\": \"text/javascript\",\r\n \"packages\": {},\r\n \"exec\": [\r\n \"\"\r\n ]\r\n }\r\n }\r\n ];\r\n baseData.variable = [\r\n {\r\n \"key\": `${toCamel(projectName)}BackendHost`,\r\n \"value\": \"http://localhost:<PORT>\",\r\n \"type\": \"string\"\r\n },\r\n {\r\n \"key\": `${toCamel(projectName)}BearerToken`,\r\n \"value\": \"<token>\",\r\n \"type\": \"string\"\r\n }\r\n ];\r\n return baseData;\r\n}\r\n\r\n/**\r\n *\r\n * @param {String} controllerDirectoryName\r\n * @param {String} projectName\r\n * @returns {Object}\r\n */\r\nexport const getItemFormatted = (controllerDirectoryName, projectName) => {\r\n const authBearer = {\r\n \"type\": \"bearer\",\r\n \"bearer\": [\r\n {\r\n \"key\": \"token\",\r\n \"value\": `{{${toCamel(projectName)}BearerToken}}`,\r\n \"type\": \"string\"\r\n }\r\n ]\r\n };\r\n\r\n const makeUrl = (pathSuffix = '', variables = []) => {\r\n const raw = `{{${toCamel(projectName)}BackendHost}}/api/${controllerDirectoryName}${pathSuffix}`;\r\n const pathParts = [\"api\", controllerDirectoryName];\r\n if (pathSuffix) pathParts.push(pathSuffix.replace('/', ''));\r\n\r\n const url = {\r\n raw,\r\n \"host\": [`{{${toCamel(projectName)}BackendHost}}`],\r\n \"path\": pathParts\r\n };\r\n if (variables.length > 0) url.variable = variables;\r\n return url;\r\n };\r\n\r\n const uuidVariable = [{ \"key\": \"uuid\", \"value\": \"<uuid>\" }];\r\n const jsonBody = {\r\n \"mode\": \"raw\",\r\n \"raw\": \"{}\",\r\n \"options\": { \"raw\": { \"language\": \"json\" } }\r\n };\r\n\r\n return {\r\n \"name\": controllerDirectoryName,\r\n \"item\": [\r\n {\r\n \"name\": \"GET ALL\",\r\n \"request\": {\r\n \"auth\": authBearer,\r\n \"method\": \"GET\",\r\n \"header\": [],\r\n \"url\": makeUrl()\r\n },\r\n \"response\": []\r\n },\r\n {\r\n \"name\": \"GET BY UUID\",\r\n \"request\": {\r\n \"auth\": authBearer,\r\n \"method\": \"GET\",\r\n \"header\": [],\r\n \"url\": makeUrl(\"/:uuid\", uuidVariable)\r\n },\r\n \"response\": []\r\n },\r\n {\r\n \"name\": \"CREATE\",\r\n \"request\": {\r\n \"auth\": authBearer,\r\n \"method\": \"POST\",\r\n \"header\": [],\r\n \"body\": jsonBody,\r\n \"url\": makeUrl()\r\n },\r\n \"response\": []\r\n },\r\n {\r\n \"name\": \"UPDATE\",\r\n \"request\": {\r\n \"auth\": authBearer,\r\n \"method\": \"PUT\",\r\n \"header\": [],\r\n \"body\": jsonBody,\r\n \"url\": makeUrl(\"/:uuid\", uuidVariable)\r\n },\r\n \"response\": []\r\n },\r\n {\r\n \"name\": \"PATCH\",\r\n \"request\": {\r\n \"auth\": authBearer,\r\n \"method\": \"PATCH\",\r\n \"header\": [],\r\n \"body\": jsonBody,\r\n \"url\": makeUrl(\"/:uuid\", uuidVariable)\r\n },\r\n \"response\": []\r\n },\r\n {\r\n \"name\": \"DELETE\",\r\n \"request\": {\r\n \"auth\": authBearer,\r\n \"method\": \"DELETE\",\r\n \"header\": [],\r\n \"url\": makeUrl(\"/:uuid\", uuidVariable)\r\n },\r\n \"response\": []\r\n }\r\n ]\r\n }\r\n}\r\n"]}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import{Command}from"commander";import inquirer from"inquirer";import{generateController,generateRouter}from"./generators/class.js";import fs from"fs-extra";import path from"path";import{fileURLToPath}from"url";import{exec}from"child_process";import ora from"ora";import{generateBasePostman,getItemFormatted}from"./generators/postman.js";const __dirname=path.dirname(fileURLToPath(import.meta.url)),pkg=fs.readJsonSync(new URL("../package.json",import.meta.url)),program=new Command;program.version(pkg.version,"-v, --version").option("--init","Initialize a new project").option("--backend","Initialize with backend template").option("--module","Initialize with module template").option("--db-sql","Initialize with db-sql template").option("--create-controller","Create a controller and its associated route"),program.parse(process.argv);const options=program.opts();function runFormatter(e="."){return new Promise(((t,r)=>{const s=exec("npm run format",{cwd:e});s.stdout.on("data",(e=>process.stdout.write(e))),s.stderr.on("data",(e=>process.stderr.write(e))),s.on("close",(e=>{0===e?t():r(new Error(`npm format exited with code ${e}`))}))}))}function runNpmInstall(e){return new Promise(((t,r)=>{const s=exec("npm install",{cwd:e});s.stdout.on("data",(e=>process.stdout.write(e))),s.stderr.on("data",(e=>process.stderr.write(e))),s.on("close",(e=>{0===e?t():r(new Error(`npm install exited with code ${e}`))}))}))}function initGitRepo(e){return new Promise(((t,r)=>{const s=exec("git init",{cwd:e});s.stdout.on("data",(e=>process.stdout.write(e))),s.stderr.on("data",(e=>process.stderr.write(e))),s.on("close",(e=>{0===e?t():r(new Error(`Git init exited with code ${e}`))}))}))}options.init&&(options.backend||options.module||options.dbSql)?(console.log("Hello! I'm Paul Sundays, your backend architect. Let's craft an awesome backend together!"),inquirer.prompt([{type:"input",name:"projectName",message:"Name of the project:",validate:e=>!!e||"The name of the project can not be empty"}]).then((async({projectName:e})=>{const t=options.backend?"backend":options.module?"module":"db-sql",r=path.join(__dirname,`../templates/${t}`),s=e.toLowerCase().replace(/\s+/g,"-"),o=path.resolve(s);fs.existsSync(o)&&(console.error(`Directory "${s}" already exists.`),process.exit(1));try{await fs.mkdir(o,{recursive:!0}),await fs.copy(r,o,{overwrite:!1,errorOnExist:!0,filter:(e,t)=>!0}),console.log("Template files copied successfully")}catch(e){console.error("Error copying the files:",e),process.exit(1)}let n;if(n="db-sql"===t?{name:s,version:"0.0.1",description:"Knex Module",main:"dist/index.js",scripts:{test:"jest",format:"prettier --write .",build:"tsc",clean:"rimraf dist && npm run format && npm run build","npm:publish":"npm run clean && npm publish","migrate:create":"knex migrate:make migration -x ts","migrate:deploy":"knex migrate:latest","seed:create":"knex seed:make seed -x ts","seed:run":"knex seed:run"},repository:{type:"git",url:""},author:"",license:"MIT",bugs:{url:""},homepage:"",devDependencies:{"@eslint/js":"^9.23.0","@types/node":"^22.13.13",eslint:"^9.23.0",globals:"^16.0.0",prettier:"^3.5.3",rimraf:"^6.0.1","ts-node":"^10.9.2",typescript:"^5.8.2","typescript-eslint":"^8.28.0"},dependencies:{dotenv:"^16.4.7",knex:"^3.1.0",lodash:"^4.17.21",pg:"^8.14.1",uuid:"^11.1.0"}}:"backend"===t?{name:s,version:"1.0.0",description:"Backend project generated with Sundays Framework",main:"dist/server.js",scripts:{test:"jest",start:"node dist/server.js",build:"tsc","start:dev":"nodemon src/server.ts",format:"prettier --write .","create:controller":"sundaysf --create-controller"},dependencies:{morgan:"^1.10.0",cors:"^2.8.5",dotenv:"^16.4.7",express:"^4.18.2"},devDependencies:{"@types/morgan":"^1.9.9","@types/cors":"^2.8.17","@types/express":"^4.17.21",nodemon:"^3.0.2",prettier:"^3.5.3","ts-node":"^10.9.2",typescript:"^5.8.2","@eslint/js":"^9.23.0",eslint:"^9.23.0","typescript-eslint":"^8.28.0"},author:"",license:"MIT"}:{name:s,version:"1.0.0",description:"Module generated with Sundays Framework",main:"dist/index.js",types:"dist/index.d.ts",scripts:{test:"jest",build:"tsc",format:"prettier --write .",clean:"rimraf dist && npm run build"},dependencies:{},devDependencies:{prettier:"^3.5.3",rimraf:"^6.0.1",typescript:"^5.8.2"},author:"",license:"MIT"},await fs.writeJson(path.join(o,"package.json"),n,{spaces:2}),"backend"===t){const t=generateBasePostman(e);await fs.writeJson(path.join(o,"postman.json"),t,{spaces:2})}const i=ora("Git init...").start();await initGitRepo(o),i.succeed("Git initialized");const a=ora("Installing dependencies...").start();await runNpmInstall(o),a.succeed("Dependencies installed"),await runFormatter(o),console.log(`Project '${e}' created successfully in ./${s}`)}))):options.createController?(fs.existsSync("./src/controllers")&&fs.existsSync("./postman.json")||(console.error("This command must be run inside a Sundays backend project."),console.error("Expected ./src/controllers/ and ./postman.json to exist."),process.exit(1)),inquirer.prompt([{type:"input",name:"controllerName",message:"Controller name:",validate:e=>e?!!/^[a-zA-Z][a-zA-Z0-9]*$/.test(e)||"Name must start with a letter and contain only letters and numbers":"The controller name is empty"}]).then((async({controllerName:e})=>{try{const t=e.charAt(0).toLowerCase()+e.slice(1),r=e.charAt(0).toUpperCase()+e.slice(1),s=`${r}Controller`,o=`${t}.controller.ts`,n=`${t}`,i=`${r}Router`,a=`${t}.router.ts`,c=`${t}`,p=`./src/controllers/${n}`,l=`./src/routes/${c}`;fs.existsSync(p)&&(console.error(`Controller directory "${p}" already exists.`),process.exit(1));const d=generateController(s),m=generateRouter(i,s,n),u=`${p}/${o}`,w=`${l}/${a}`;await fs.mkdir(p,{recursive:!0}),await fs.mkdir(l,{recursive:!0}),await fs.writeFile(u,d),await fs.writeFile(w,m);const f=await fs.readFile("./postman.json","utf-8"),g=JSON.parse(f),h=getItemFormatted(c,g.info.name);g.item.push(h),await fs.writeJson(path.join(".","postman.json"),g,{spaces:2}),await runFormatter("."),console.log(`Created ${s} in ${n}/${o} and ${i} in ${c}/${a}`)}catch(e){console.error("Error generating controller:",e.message),process.exit(1)}}))):program.help();
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["Command","inquirer","generateController","generateRouter","fs","path","fileURLToPath","exec","ora","generateBasePostman","getItemFormatted","__dirname","dirname","url","pkg","readJsonSync","URL","program","version","option","parse","process","argv","options","opts","runFormatter","cwd","Promise","resolve","reject","formatProcess","stdout","on","data","write","stderr","code","Error","runNpmInstall","destDir","installProcess","initGitRepo","gitProcess","init","backend","module","dbSql","console","log","prompt","type","name","message","validate","input","then","async","projectName","templateType","srcDir","join","dirName","toLowerCase","replace","existsSync","error","exit","mkdir","recursive","copy","overwrite","errorOnExist","filter","src","dest","err","packageJson","description","main","scripts","test","format","build","clean","repository","author","license","bugs","homepage","devDependencies","eslint","globals","prettier","rimraf","typescript","dependencies","dotenv","knex","lodash","pg","uuid","start","morgan","cors","express","nodemon","types","writeJson","spaces","postmanBaseData","spinnerGit","succeed","spinner","createController","controllerName","nonCapitalized","charAt","slice","capitalized","toUpperCase","controllerClassName","controllerFileName","controllerDirectoryName","routerClassName","routerFileName","routerDirectoryName","controllerDir","routerDir","classControllerContentGenerator","classRouterContentGenerator","controllerPath","routerPath","writeFile","readFile","leanData","JSON","itemToPush","info","item","push","help"],"sources":["bin/index.js"],"mappings":"OAESA,YAAe,mBACjBC,aAAc,kBACZC,mBAAoBC,mBAAsB,+BAC5CC,OAAQ,kBACRC,SAAU,cACRC,kBAAqB,aACrBC,SAAY,uBACdC,QAAS,aACPC,oBAAqBC,qBAAwB,0BAEtD,MAAMC,UAAYN,KAAKO,QAAQN,0BAA0BO,MACnDC,IAAMV,GAAGW,aAAa,IAAIC,IAAI,8BAA+BH,MAE7DI,QAAU,IAAIjB,QAEpBiB,QACKC,QAAQJ,IAAII,QAAS,iBACrBC,OAAO,SAAU,4BACjBA,OAAO,YAAa,oCACpBA,OAAO,WAAY,mCACnBA,OAAO,WAAY,mCACnBA,OAAO,sBAAuB,gDAEnCF,QAAQG,MAAMC,QAAQC,MAEtB,MAAMC,QAAUN,QAAQO,OAsOxB,SAASC,aAAaC,EAAM,KACxB,OAAO,IAAIC,SAAQ,CAACC,EAASC,KACzB,MAAMC,EAAgBvB,KAAK,iBAAkB,CAAEmB,QAE/CI,EAAcC,OAAOC,GAAG,QAAQC,GAAQZ,QAAQU,OAAOG,MAAMD,KAC7DH,EAAcK,OAAOH,GAAG,QAAQC,GAAQZ,QAAQc,OAAOD,MAAMD,KAE7DH,EAAcE,GAAG,SAASI,IACT,IAATA,EACAR,IAEAC,EAAO,IAAIQ,MAAM,+BAA+BD,KACpD,GACF,GAEV,CAGA,SAASE,cAAcC,GACnB,OAAO,IAAIZ,SAAQ,CAACC,EAASC,KACzB,MAAMW,EAAiBjC,KAAK,cAAe,CAAEmB,IAAKa,IAElDC,E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,KAAiBL,IACrCU,EAAa,GAAGJ,KAAaH,UAE7BxH,GAAG+D,MAAM2D,EAAe,CAAE1D,WAAW,UACrChE,GAAG+D,MAAM4D,EAAW,CAAE3D,WAAW,UACjChE,GAAGgI,UAAUF,EAAgBF,SAC7B5H,GAAGgI,UAAUD,EAAYF,GAE/B,MAAMpB,QAAwBzG,GAAGiI,SAAS,iBAAkB,SACtDC,EAAWC,KAAKnH,MAAMyF,GACtB2B,EAAa9H,iBAAiBmH,EAAqBS,EAASG,KAAKtF,MACvEmF,EAASI,KAAKC,KAAKH,SACbpI,GAAGuG,UAAUtG,KAAKuD,KAAK,IAAK,gBAAiB0E,EAAU,CAAE1B,OAAQ,UAEjEnF,aAAa,KACnBsB,QAAQC,IAAI,WAAWwE,QAA0BE,KAA2BD,SAA0BE,QAAsBE,KAAuBD,IACvJ,CAAE,MAAOjD,GACL5B,QAAQkB,MAAM,+BAAgCU,EAAIvB,SAClD/B,QAAQ6C,KAAK,EACjB,MAGJjD,QAAQ2H","ignoreList":[],"sourcesContent":["#!/usr/bin/env node\r\n\r\nimport { Command } from 'commander';\r\nimport inquirer from 'inquirer';\r\nimport { generateController, generateRouter } from './generators/class.js';\r\nimport fs from 'fs-extra';\r\nimport path from 'path';\r\nimport { fileURLToPath } from 'url';\r\nimport { exec } from 'child_process';\r\nimport ora from 'ora';\r\nimport { generateBasePostman, getItemFormatted } from './generators/postman.js';\r\n\r\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\r\nconst pkg = fs.readJsonSync(new URL('../package.json', import.meta.url));\r\n\r\nconst program = new Command();\r\n\r\nprogram\r\n .version(pkg.version, '-v, --version')\r\n .option('--init', 'Initialize a new project')\r\n .option('--backend', 'Initialize with backend template')\r\n .option('--module', 'Initialize with module template')\r\n .option('--db-sql', 'Initialize with db-sql template')\r\n .option('--create-controller', 'Create a controller and its associated route');\r\n\r\nprogram.parse(process.argv);\r\n\r\nconst options = program.opts();\r\n\r\nif (options.init && (options.backend || options.module || options.dbSql)) {\r\n console.log(\"Hello! I'm Paul Sundays, your backend architect. Let's craft an awesome backend together!\");\r\n inquirer.prompt([\r\n {\r\n type: 'input',\r\n name: 'projectName',\r\n message: 'Name of the project:',\r\n validate: input => input ? true : 'The name of the project can not be empty'\r\n }\r\n ]).then(async ({ projectName }) => {\r\n const templateType = options.backend ? 'backend' : options.module ? 'module' : 'db-sql';\r\n const srcDir = path.join(__dirname, `../templates/${templateType}`);\r\n const dirName = projectName.toLowerCase().replace(/\\s+/g, '-');\r\n const destDir = path.resolve(dirName);\r\n\r\n if (fs.existsSync(destDir)) {\r\n console.error(`Directory \"${dirName}\" already exists.`);\r\n process.exit(1);\r\n }\r\n\r\n try {\r\n await fs.mkdir(destDir, { recursive: true });\r\n await fs.copy(srcDir, destDir, {\r\n overwrite: false,\r\n errorOnExist: true,\r\n filter: (src, dest) => {\r\n return true;\r\n }\r\n });\r\n console.log('Template files copied successfully');\r\n } catch (err) {\r\n console.error('Error copying the files:', err);\r\n process.exit(1);\r\n }\r\n\r\n let packageJson;\r\n if (templateType === 'db-sql') {\r\n packageJson = {\r\n name: dirName,\r\n version: \"0.0.1\",\r\n description: \"Knex Module\",\r\n main: \"dist/index.js\",\r\n scripts: {\r\n test: \"jest\",\r\n format: \"prettier --write .\",\r\n build: \"tsc\",\r\n clean: \"rimraf dist && npm run format && npm run build\",\r\n \"npm:publish\": \"npm run clean && npm publish\",\r\n \"migrate:create\": \"knex migrate:make migration -x ts\",\r\n \"migrate:deploy\": \"knex migrate:latest\",\r\n \"seed:create\": \"knex seed:make seed -x ts\",\r\n \"seed:run\": \"knex seed:run\"\r\n },\r\n repository: {\r\n type: \"git\",\r\n url: \"\"\r\n },\r\n author: \"\",\r\n license: \"MIT\",\r\n bugs: {\r\n url: \"\"\r\n },\r\n homepage: \"\",\r\n devDependencies: {\r\n \"@eslint/js\": \"^9.23.0\",\r\n \"@types/node\": \"^22.13.13\",\r\n eslint: \"^9.23.0\",\r\n globals: \"^16.0.0\",\r\n prettier: \"^3.5.3\",\r\n rimraf: \"^6.0.1\",\r\n \"ts-node\": \"^10.9.2\",\r\n typescript: \"^5.8.2\",\r\n \"typescript-eslint\": \"^8.28.0\"\r\n },\r\n dependencies: {\r\n dotenv: \"^16.4.7\",\r\n knex: \"^3.1.0\",\r\n lodash: \"^4.17.21\",\r\n pg: \"^8.14.1\",\r\n uuid: \"^11.1.0\"\r\n }\r\n };\r\n } else if (templateType === 'backend') {\r\n packageJson = {\r\n name: dirName,\r\n version: \"1.0.0\",\r\n description: `Backend project generated with Sundays Framework`,\r\n main: \"dist/server.js\",\r\n scripts: {\r\n \"test\": \"jest\",\r\n \"start\": \"node dist/server.js\",\r\n \"build\": \"tsc\",\r\n \"start:dev\": \"nodemon src/server.ts\",\r\n \"format\": \"prettier --write .\",\r\n \"create:controller\": \"sundaysf --create-controller\"\r\n },\r\n dependencies: {\r\n \"morgan\": \"^1.10.0\",\r\n \"cors\": \"^2.8.5\",\r\n \"dotenv\": \"^16.4.7\",\r\n \"express\": \"^4.18.2\"\r\n },\r\n devDependencies: {\r\n \"@types/morgan\": \"^1.9.9\",\r\n \"@types/cors\": \"^2.8.17\",\r\n \"@types/express\": \"^4.17.21\",\r\n \"nodemon\": \"^3.0.2\",\r\n \"prettier\": \"^3.5.3\",\r\n \"ts-node\": \"^10.9.2\",\r\n \"typescript\": \"^5.8.2\",\r\n \"@eslint/js\": \"^9.23.0\",\r\n \"eslint\": \"^9.23.0\",\r\n \"typescript-eslint\": \"^8.28.0\"\r\n },\r\n author: \"\",\r\n license: \"MIT\"\r\n };\r\n } else {\r\n // module\r\n packageJson = {\r\n name: dirName,\r\n version: \"1.0.0\",\r\n description: `Module generated with Sundays Framework`,\r\n main: \"dist/index.js\",\r\n types: \"dist/index.d.ts\",\r\n scripts: {\r\n \"test\": \"jest\",\r\n \"build\": \"tsc\",\r\n \"format\": \"prettier --write .\",\r\n \"clean\": \"rimraf dist && npm run build\"\r\n },\r\n dependencies: {},\r\n devDependencies: {\r\n \"prettier\": \"^3.5.3\",\r\n \"rimraf\": \"^6.0.1\",\r\n \"typescript\": \"^5.8.2\"\r\n },\r\n author: \"\",\r\n license: \"MIT\"\r\n };\r\n }\r\n\r\n await fs.writeJson(path.join(destDir, 'package.json'), packageJson, { spaces: 2 });\r\n\r\n if (templateType === 'backend') {\r\n const postmanBaseData = generateBasePostman(projectName);\r\n await fs.writeJson(path.join(destDir, 'postman.json'), postmanBaseData, { spaces: 2 });\r\n }\r\n\r\n const spinnerGit = ora('Git init...').start();\r\n await initGitRepo(destDir);\r\n spinnerGit.succeed('Git initialized');\r\n\r\n const spinner = ora('Installing dependencies...').start();\r\n await runNpmInstall(destDir);\r\n spinner.succeed('Dependencies installed');\r\n\r\n await runFormatter(destDir);\r\n console.log(`Project '${projectName}' created successfully in ./${dirName}`);\r\n });\r\n} else if (options.createController) {\r\n // Verify we're inside a backend project\r\n if (!fs.existsSync('./src/controllers') || !fs.existsSync('./postman.json')) {\r\n console.error('This command must be run inside a Sundays backend project.');\r\n console.error('Expected ./src/controllers/ and ./postman.json to exist.');\r\n process.exit(1);\r\n }\r\n\r\n inquirer.prompt([\r\n {\r\n type: 'input',\r\n name: 'controllerName',\r\n message: 'Controller name:',\r\n validate: input => {\r\n if (!input) return 'The controller name is empty';\r\n if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(input)) {\r\n return 'Name must start with a letter and contain only letters and numbers';\r\n }\r\n return true;\r\n }\r\n }\r\n ]).then(async ({ controllerName }) => {\r\n try {\r\n const nonCapitalized = controllerName.charAt(0).toLowerCase() + controllerName.slice(1);\r\n const capitalized = controllerName.charAt(0).toUpperCase() + controllerName.slice(1);\r\n const controllerClassName = `${capitalized}Controller`;\r\n const controllerFileName = `${nonCapitalized}.controller.ts`;\r\n const controllerDirectoryName = `${nonCapitalized}`;\r\n const routerClassName = `${capitalized}Router`;\r\n const routerFileName = `${nonCapitalized}.router.ts`;\r\n const routerDirectoryName = `${nonCapitalized}`;\r\n\r\n const controllerDir = `./src/controllers/${controllerDirectoryName}`;\r\n const routerDir = `./src/routes/${routerDirectoryName}`;\r\n\r\n if (fs.existsSync(controllerDir)) {\r\n console.error(`Controller directory \"${controllerDir}\" already exists.`);\r\n process.exit(1);\r\n }\r\n\r\n const classControllerContentGenerator = generateController(controllerClassName);\r\n const classRouterContentGenerator = generateRouter(routerClassName, controllerClassName, controllerDirectoryName);\r\n const controllerPath = `${controllerDir}/${controllerFileName}`;\r\n const routerPath = `${routerDir}/${routerFileName}`;\r\n\r\n await fs.mkdir(controllerDir, { recursive: true });\r\n await fs.mkdir(routerDir, { recursive: true });\r\n await fs.writeFile(controllerPath, classControllerContentGenerator);\r\n await fs.writeFile(routerPath, classRouterContentGenerator);\r\n\r\n const postmanBaseData = await fs.readFile('./postman.json', 'utf-8');\r\n const leanData = JSON.parse(postmanBaseData);\r\n const itemToPush = getItemFormatted(routerDirectoryName, leanData.info.name);\r\n leanData.item.push(itemToPush);\r\n await fs.writeJson(path.join('.', 'postman.json'), leanData, { spaces: 2 });\r\n\r\n await runFormatter('.');\r\n console.log(`Created ${controllerClassName} in ${controllerDirectoryName}/${controllerFileName} and ${routerClassName} in ${routerDirectoryName}/${routerFileName}`);\r\n } catch (err) {\r\n console.error('Error generating controller:', err.message);\r\n process.exit(1);\r\n }\r\n });\r\n} else {\r\n program.help();\r\n}\r\n\r\n\r\nfunction runFormatter(cwd = '.') {\r\n return new Promise((resolve, reject) => {\r\n const formatProcess = exec('npm run format', { cwd });\r\n\r\n formatProcess.stdout.on('data', data => process.stdout.write(data));\r\n formatProcess.stderr.on('data', data => process.stderr.write(data));\r\n\r\n formatProcess.on('close', code => {\r\n if (code === 0) {\r\n resolve();\r\n } else {\r\n reject(new Error(`npm format exited with code ${code}`));\r\n }\r\n });\r\n });\r\n}\r\n\r\n\r\nfunction runNpmInstall(destDir) {\r\n return new Promise((resolve, reject) => {\r\n const installProcess = exec('npm install', { cwd: destDir });\r\n\r\n installProcess.stdout.on('data', data => process.stdout.write(data));\r\n installProcess.stderr.on('data', data => process.stderr.write(data));\r\n\r\n installProcess.on('close', code => {\r\n if (code === 0) {\r\n resolve();\r\n } else {\r\n reject(new Error(`npm install exited with code ${code}`));\r\n }\r\n });\r\n });\r\n}\r\n\r\nfunction initGitRepo(destDir) {\r\n return new Promise((resolve, reject) => {\r\n const gitProcess = exec('git init', { cwd: destDir });\r\n\r\n gitProcess.stdout.on('data', data => process.stdout.write(data));\r\n gitProcess.stderr.on('data', data => process.stderr.write(data));\r\n\r\n gitProcess.on('close', code => {\r\n if (code === 0) {\r\n resolve();\r\n } else {\r\n reject(new Error(`Git init exited with code ${code}`));\r\n }\r\n });\r\n });\r\n}\r\n"]}
@@ -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,14 @@
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
+ ],
11
+ "deny": [],
12
+ "ask": []
13
+ }
14
+ }
@@ -0,0 +1,13 @@
1
+ # Server
2
+ PORT=3098
3
+ ENVIRONMENT=local
4
+
5
+ # CORS (comma-separated origins with protocol)
6
+ CORS_ALLOWED_ORIGINS=http://localhost:3098
7
+
8
+ # Database (uncomment if using db-sql module)
9
+ # SQL_HOST=localhost
10
+ # SQL_PORT=5432
11
+ # SQL_USER=postgres
12
+ # SQL_PASSWORD=
13
+ # SQL_DB_NAME=mydb
@@ -0,0 +1,3 @@
1
+ node_modules/
2
+ dist/
3
+ package-lock.json
@@ -0,0 +1,9 @@
1
+ {
2
+ "tabWidth": 2,
3
+ "semi": true,
4
+ "singleQuote": true,
5
+ "trailingComma": "es5",
6
+ "bracketSpacing": true,
7
+ "bracketSameLine": true,
8
+ "arrowParens": "always"
9
+ }