create-jerry 1.0.0 โ†’ 2.0.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 (48) hide show
  1. package/README.md +225 -55
  2. package/Templates/base/js/app.js +19 -0
  3. package/Templates/base/js/config/index.js +18 -0
  4. package/Templates/base/js/middlewares/error.middleware.js +8 -0
  5. package/Templates/base/js/routes/index.js +12 -0
  6. package/Templates/base/js/server.js +21 -0
  7. package/Templates/base/js/utils/asyncHandler.js +5 -0
  8. package/Templates/base/ts/app.ts +19 -0
  9. package/Templates/base/ts/config/index.ts +18 -0
  10. package/Templates/base/ts/middlewares/error.middleware.ts +15 -0
  11. package/Templates/base/ts/routes/index.ts +12 -0
  12. package/Templates/base/ts/server.ts +21 -0
  13. package/Templates/base/ts/tsconfig.json +18 -0
  14. package/Templates/base/ts/utils/asyncHandler.ts +5 -0
  15. package/Templates/db/mongodb/js/db.js +39 -0
  16. package/Templates/db/mongodb/ts/db.ts +50 -0
  17. package/Templates/db/mysql/js/db.js +58 -0
  18. package/Templates/db/mysql/ts/db.ts +72 -0
  19. package/Templates/modules/ai/js/ai.controller.js +30 -0
  20. package/Templates/modules/ai/js/ai.provider.js +32 -0
  21. package/Templates/modules/ai/js/ai.routes.js +8 -0
  22. package/Templates/modules/ai/js/ai.service.js +16 -0
  23. package/Templates/modules/ai/ts/ai.controller.ts +31 -0
  24. package/Templates/modules/ai/ts/ai.provider.ts +30 -0
  25. package/Templates/modules/ai/ts/ai.routes.ts +8 -0
  26. package/Templates/modules/ai/ts/ai.service.ts +16 -0
  27. package/Templates/modules/user/js/user.controller.js +46 -0
  28. package/Templates/modules/user/js/user.provider.js +25 -0
  29. package/Templates/modules/user/js/user.routes.js +12 -0
  30. package/Templates/modules/user/js/user.service.js +21 -0
  31. package/Templates/modules/user/ts/user.controller.ts +27 -0
  32. package/Templates/modules/user/ts/user.provider.ts +25 -0
  33. package/Templates/modules/user/ts/user.routes.ts +12 -0
  34. package/Templates/modules/user/ts/user.service.ts +21 -0
  35. package/fileCreator.js +140 -31
  36. package/folderCreator.js +15 -0
  37. package/index.js +85 -76
  38. package/installer.js +11 -13
  39. package/package.json +5 -3
  40. package/packageJsonCreator.js +45 -72
  41. package/plugins/ai.plugin.js +25 -0
  42. package/plugins/mongodb.plugin.js +15 -0
  43. package/plugins/mysql.plugin.js +15 -0
  44. package/plugins/pluginManager.js +18 -0
  45. package/Templates/db-mongo.js +0 -20
  46. package/Templates/db-sql.js +0 -35
  47. package/Templates/express.js +0 -35
  48. package/folderCreater.js +0 -34
package/README.md CHANGED
@@ -1,81 +1,251 @@
1
- # JERRIT: Backend Project Scaffolding Tool
1
+ # ๐Ÿš€ create-jerry (JerrIt CLI)
2
+
3
+ > A lightning-fast CLI tool to scaffold production-ready Express backend projects with MongoDB or MySQL, plugin-based architecture, and optional AI module support.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/create-jerry.svg)](https://www.npmjs.com/package/create-jerry)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ ---
9
+
10
+ ## โœจ Overview
11
+
12
+ **create-jerry** is a backend scaffolding CLI inspired by tools like Vite and Create React App.
13
+
14
+ It generates a structured Express.js backend with:
15
+
16
+ - MongoDB OR MySQL support
17
+ - JavaScript OR TypeScript support
18
+ - Optional AI module (OpenAI integration)
19
+ - Plugin-based architecture (extensible design)
20
+ - Clean modular folder structure
21
+
2
22
  ---
3
23
 
4
- ## Problem Statement:
5
- A Project Scaffolding Framework similar to Vite.js and Next.js that aims to provide a ready-to-code boilerplate for working with MongoDB or MySQL databases through express.js server. The Project aims to minimize the setup time for building a MERN or SERN app, enhancing productivity and efficiency for developers.
24
+ ## โšก Features
25
+
26
+ - ๐ŸŽฏ Interactive CLI prompts (Inquirer-based)
27
+ - ๐Ÿง  Optional AI module (OpenAI integration)
28
+ - ๐Ÿ—„๏ธ Database selection (MongoDB / MySQL)
29
+ - ๐Ÿงพ JavaScript & TypeScript support
30
+ - ๐Ÿ”Œ Plugin-based architecture system
31
+ - ๐Ÿ“ Production-ready folder structure
32
+ - โš™๏ธ Auto dependency injection in package.json
33
+ - ๐Ÿš€ Fully working Express server setup
6
34
 
7
35
  ---
8
36
 
37
+ ## ๐Ÿš€ Quick Start
9
38
 
10
- ## Project Structure:
11
- ```
12
- XeoBuilds/
13
- |_ Templates/
14
- | |_ db-mongo.js
15
- | |_ db-sql.js
16
- | |_ express.js
17
- |
18
- |_ .gitignore
19
- |_ fileCreator.js
20
- |_ folderCreator.js
21
- |_ installer.js
22
- |_ index.js
23
- |_ package.json
24
- |_ package-lock.json
25
- |_ README.md
39
+ ```bash
40
+ npx create-jerry
26
41
  ```
42
+
43
+ Then follow prompts:
44
+
45
+ 1. Project name
46
+ 2. Database (MongoDB / MySQL)
47
+ 3. Language (JavaScript / TypeScript)
48
+ 4. AI module (Yes / No)
49
+
27
50
  ---
28
51
 
52
+ ## ๐Ÿ“ฆ What Gets Generated
53
+
54
+ ### Project Structure
55
+
56
+ ```
57
+ your-project/
58
+ โ”œโ”€โ”€ src/
59
+ โ”‚ โ”œโ”€โ”€ config/
60
+ โ”‚ โ”‚ โ”œโ”€โ”€ db.js / db.ts
61
+ โ”‚ โ”‚ โ””โ”€โ”€ index.js
62
+ โ”‚ โ”‚
63
+ โ”‚ โ”œโ”€โ”€ modules/
64
+ โ”‚ โ”‚ โ”œโ”€โ”€ user/
65
+ โ”‚ โ”‚ โ””โ”€โ”€ ai/ (optional)
66
+ โ”‚ โ”‚
67
+ โ”‚ โ”œโ”€โ”€ routes/
68
+ โ”‚ โ”‚ โ””โ”€โ”€ index.js
69
+ โ”‚ โ”‚
70
+ โ”‚ โ”œโ”€โ”€ middlewares/
71
+ โ”‚ โ”‚ โ””โ”€โ”€ error.middleware.js
72
+ โ”‚ โ”‚
73
+ โ”‚ โ”œโ”€โ”€ utils/
74
+ โ”‚ โ”‚ โ””โ”€โ”€ asyncHandler.js
75
+ โ”‚ โ”‚
76
+ โ”‚ โ”œโ”€โ”€ app.js
77
+ โ”‚ โ””โ”€โ”€ server.js
78
+ โ”‚
79
+ โ”œโ”€โ”€ .env
80
+ โ”œโ”€โ”€ package.json
81
+ โ””โ”€โ”€ tsconfig.json (if TypeScript)
82
+ ```
29
83
 
30
- ## Libraries used to build:
31
- - inquirer
32
- - chalk
33
- - chalkAnimation
34
- - execSync
35
- - nanospinner
36
- - fs module
37
- <!-- fs/promises module -->
38
84
  ---
39
85
 
86
+ ## ๐Ÿง  Architecture
87
+
88
+ This CLI uses a **plugin-based generator system**:
89
+
90
+ ### Supported Plugins
91
+
92
+ - ๐ŸŸข MongoDB Plugin
93
+ - ๐ŸŸก MySQL Plugin
94
+ - ๐Ÿค– AI Plugin (OpenAI)
95
+
96
+ ### Each Plugin Handles:
97
+
98
+ - Module generation (if required)
99
+ - Dependency injection
100
+ - Route injection
101
+ - Setup logic execution
40
102
 
41
- ## Packages/Libraries for Backend:
42
- - express
43
- - cors
44
- - mongoose
45
- - mysql2
46
- - dotenv
47
- - router
48
103
  ---
49
104
 
105
+ ## ๐Ÿ”Œ Example CLI Flow
50
106
 
51
- ## Backend Generated:
107
+ ```bash
108
+ โœ” Project name? my-app
109
+ โœ” Select Database MongoDB
110
+ โœ” Select Language Typescript
111
+ โœ” Add AI module? Yes
52
112
  ```
53
- project-name/
54
- |_ Models/
55
- | |_ db.js
56
- |
57
- |_ Controller/
58
- | |_ index.js
59
- |
60
- |_ Middleware/
61
- | |_ handler.js
62
- |
63
- |_ Config/
64
- | |_ .env
65
- |
66
- |_ app.js
67
- |_ package.json
113
+
114
+ ### Output:
115
+
116
+ - MongoDB configured project
117
+ - AI module added (optional)
118
+ - Routes auto-injected
119
+ - Dependencies installed dynamically
120
+
121
+ ---
122
+
123
+ ## ๐Ÿงฐ Available Scripts (Generated Project)
124
+
125
+ ```bash
126
+ npm run dev # Development mode
127
+ npm start # Production mode
128
+ npm run build # TypeScript build (if TS)
68
129
  ```
130
+
69
131
  ---
70
132
 
133
+ ## ๐Ÿง  AI Module (Optional)
134
+
135
+ When enabled:
136
+
137
+ - `/ai/chat` endpoint is created
138
+ - OpenAI SDK installed
139
+ - Controller โ†’ Service โ†’ Provider architecture
140
+ - GPT-powered backend endpoint ready to use
71
141
 
72
- ## Demo Video:
73
- Video Link: https://drive.google.com/file/d/1o_9_5RMI21Inew4knCqXlCmeArhAG3xD/view?usp=sharing
74
- <!-- ![]() -->
75
142
  ---
76
143
 
144
+ ## ๐Ÿ—„๏ธ Database Support
77
145
 
146
+ ### MongoDB
78
147
 
79
- <!-- ## Low Level Daigram ## Challenges -->
80
- # Thank You, Don't forget to add a โญ
148
+ - Mongoose integration
149
+ - Predefined User model + CRUD
150
+ - Auto connection setup
151
+
152
+ ### MySQL
153
+
154
+ - mysql2 connection pool
155
+ - Prebuilt SQL queries
156
+ - Ready-to-use CRUD layer
157
+
158
+ ---
159
+
160
+ ## ๐Ÿ”Œ Plugin System
161
+
162
+ Plugins follow this structure:
163
+
164
+ ```js
165
+ {
166
+ name: "plugin-name",
167
+ setup(),
168
+ inject,
169
+ dependencies
170
+ }
171
+ ```
172
+
173
+ ### Benefits:
174
+
175
+ - Extensible architecture
176
+ - Clean separation of concerns
177
+ - Easy future expansion (auth, redis, payments, etc.)
178
+
179
+ ---
180
+
181
+ ## ๐Ÿ“š Tech Stack
182
+
183
+ - Node.js
184
+ - Express.js
185
+ - Inquirer.js
186
+ - Chalk
187
+ - Nanospinner
188
+ - OpenAI SDK (optional)
189
+ - Mongoose / MySQL2
190
+
191
+ ---
192
+
193
+ ## ๐ŸŽฏ Why create-jerry?
81
194
 
195
+ Because backend setup is repetitive:
196
+
197
+ - Folder structure setup โŒ
198
+ - Database configuration โŒ
199
+ - Boilerplate code โŒ
200
+
201
+ Now:
202
+
203
+ ```bash
204
+ npx create-jerry
205
+ ```
206
+
207
+ Done in seconds โšก
208
+
209
+ ---
210
+
211
+ ## ๐Ÿ› ๏ธ Future Plans
212
+ - ๐ŸŸฆ Typescript Migration
213
+ - ๐Ÿ” Authentication plugin (JWT / OAuth)
214
+ - โšก Redis caching plugin
215
+ - ๐Ÿ“ฆ Docker support
216
+ - ๐Ÿงช Testing setup (Jest)
217
+ - โ˜๏ธ Deployment presets
218
+
219
+ ---
220
+
221
+ ## ๐Ÿ‘จโ€๐Ÿ’ป Author
222
+
223
+ **Tanmay Khanna**
224
+
225
+ - GitHub: [@TomLucasakaTGeek](https://github.com/TomLucasakaTGeek)
226
+ - Project: JerrIt CLI
227
+
228
+ ---
229
+
230
+ ## โญ Support
231
+
232
+ If this helped you:
233
+
234
+ - โญ Star the repo
235
+ - ๐Ÿ” Share with developers
236
+ - ๐Ÿงฉ Contribute plugins
237
+
238
+ ---
239
+
240
+ ## ๐Ÿ“„ License
241
+
242
+ MIT License
243
+
244
+ ---
245
+
246
+ **Built with โค๏ธ to make backend development faster and easier**
247
+
248
+
249
+
250
+ <!-- ## Low Level Daigram ## Challenges -->
251
+ <!-- ======= -->
@@ -0,0 +1,19 @@
1
+ import express from 'express';
2
+ import cors from 'cors';
3
+ import routes from './routes/index.js';
4
+ import { errorHandler } from './middlewares/error.middleware.js';
5
+
6
+ const app = express();
7
+
8
+ app.use(cors());
9
+ app.use(express.json());
10
+
11
+ app.use('/api', routes);
12
+
13
+ app.get('/health', (_, res) => {
14
+ res.json({ status: 'OK' });
15
+ });
16
+
17
+ app.use(errorHandler);
18
+
19
+ export default app;
@@ -0,0 +1,18 @@
1
+ import dotenv from 'dotenv';
2
+
3
+ dotenv.config();
4
+
5
+ export const config = {
6
+ port: process.env.PORT || 3000,
7
+
8
+ // MongoDB
9
+ mongoUri: process.env.MONGO_URI,
10
+
11
+ // MySQL
12
+ mysql: {
13
+ host: process.env.MYSQL_HOST,
14
+ user: process.env.MYSQL_USER,
15
+ password: process.env.MYSQL_PASSWORD,
16
+ database: process.env.MYSQL_DATABASE
17
+ }
18
+ };
@@ -0,0 +1,8 @@
1
+ export const errorHandler = (err, _req, res, _next) => {
2
+ console.error(err);
3
+
4
+ res.status(err.status || 500).json({
5
+ success: false,
6
+ message: err.message || 'Internal Server Error',
7
+ });
8
+ };
@@ -0,0 +1,12 @@
1
+ import { Router } from 'express';
2
+ import userRoutes from '../modules/user/user.routes.js';
3
+
4
+ // [IMPORT_ROUTES]
5
+
6
+ const router = Router();
7
+
8
+ router.use('/users', userRoutes);
9
+
10
+ // [USE_ROUTES]
11
+
12
+ export default router;
@@ -0,0 +1,21 @@
1
+ import app from './app.js';
2
+ import { config } from './config/index.js';
3
+ import { connectDB } from './config/db.js';
4
+
5
+ const start = async () => {
6
+ try {
7
+ if (connectDB) {
8
+ await connectDB();
9
+ }
10
+
11
+ app.listen(config.port, () => {
12
+ console.log(`๐Ÿš€ Server running on port ${config.port}`);
13
+ });
14
+
15
+ } catch (err) {
16
+ console.error('โŒ Failed to start server:', err);
17
+ process.exit(1);
18
+ }
19
+ };
20
+
21
+ start();
@@ -0,0 +1,5 @@
1
+ export const asyncHandler = (fn) => {
2
+ return function (req, res, next) {
3
+ Promise.resolve(fn(req, res, next)).catch(next);
4
+ };
5
+ };
@@ -0,0 +1,19 @@
1
+ import express from 'express';
2
+ import cors from 'cors';
3
+ import routes from './routes/index.js';
4
+ import { errorHandler } from './middlewares/error.middleware.js';
5
+
6
+ const app = express();
7
+
8
+ app.use(cors());
9
+ app.use(express.json());
10
+
11
+ app.use('/api', routes);
12
+
13
+ app.get('/health', (_, res) => {
14
+ res.json({ status: 'OK' });
15
+ });
16
+
17
+ app.use(errorHandler);
18
+
19
+ export default app;
@@ -0,0 +1,18 @@
1
+ import dotenv from 'dotenv';
2
+
3
+ dotenv.config();
4
+
5
+ export const config = {
6
+ port: process.env.PORT || 3000,
7
+
8
+ // MongoDB
9
+ mongoUri: process.env.MONGO_URI,
10
+
11
+ // MySQL
12
+ mysql: {
13
+ host: process.env.MYSQL_HOST,
14
+ user: process.env.MYSQL_USER,
15
+ password: process.env.MYSQL_PASSWORD,
16
+ database: process.env.MYSQL_DATABASE
17
+ }
18
+ };
@@ -0,0 +1,15 @@
1
+ import { Request, Response, NextFunction } from 'express';
2
+
3
+ export const errorHandler = (
4
+ err: any,
5
+ _req: Request,
6
+ res: Response,
7
+ _next: NextFunction
8
+ ) => {
9
+ console.error(err);
10
+
11
+ res.status(err.status || 500).json({
12
+ success: false,
13
+ message: err.message || 'Internal Server Error',
14
+ });
15
+ };
@@ -0,0 +1,12 @@
1
+ import { Router } from 'express';
2
+ import userRoutes from '../modules/user/user.routes.js';
3
+
4
+ // [IMPORT_ROUTES]
5
+
6
+ const router = Router();
7
+
8
+ router.use('/users', userRoutes);
9
+
10
+ // [USE_ROUTES]
11
+
12
+ export default router;
@@ -0,0 +1,21 @@
1
+ import app from './app.js';
2
+ import { config } from './config/index.js';
3
+ import { connectDB } from './config/db.js';
4
+
5
+ const start = async () => {
6
+ try {
7
+ if (connectDB) {
8
+ await connectDB();
9
+ }
10
+
11
+ app.listen(config.port, () => {
12
+ console.log(`๐Ÿš€ Server running on port ${config.port}`);
13
+ });
14
+
15
+ } catch (err) {
16
+ console.error('โŒ Failed to start server:', err);
17
+ process.exit(1);
18
+ }
19
+ };
20
+
21
+ start();
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "module": "NodeNext",
5
+ "moduleResolution": "NodeNext",
6
+
7
+ "rootDir": "src",
8
+ "outDir": "dist",
9
+
10
+ "strict": true,
11
+ "esModuleInterop": true,
12
+ "skipLibCheck": true,
13
+
14
+ "forceConsistentCasingInFileNames": true
15
+ },
16
+ "include": ["src"],
17
+ "exclude": ["node_modules", "dist"]
18
+ }
@@ -0,0 +1,5 @@
1
+ export const asyncHandler = (fn: Function) => {
2
+ return function (req: any, res: any, next: any) {
3
+ Promise.resolve(fn(req, res, next)).catch(next);
4
+ };
5
+ };
@@ -0,0 +1,39 @@
1
+ import mongoose from 'mongoose';
2
+ import dotenv from 'dotenv';
3
+
4
+ dotenv.config();
5
+
6
+ const connectDB = async () => {
7
+ try {
8
+ await mongoose.connect(process.env.MONGO_URI);
9
+ console.log('MongoDB connected');
10
+ } catch (err) {
11
+ console.error(err);
12
+ process.exit(1);
13
+ }
14
+ };
15
+
16
+ const userSchema = new mongoose.Schema(
17
+ {
18
+ name: String,
19
+ email: String,
20
+ password: String
21
+ },
22
+ { timestamps: true }
23
+ );
24
+
25
+ const User = mongoose.model('User', userSchema);
26
+
27
+ // CRUD
28
+
29
+ export const getAllUsers = async () => User.find();
30
+
31
+ export const getUserById = async (id) => User.findById(id);
32
+
33
+ export const createUser = async (data) => User.create(data);
34
+
35
+ export const updateUser = async (id, data) =>
36
+ User.findByIdAndUpdate(id, data, { new: true });
37
+
38
+ export const deleteUser = async (id) =>
39
+ User.findByIdAndDelete(id);
@@ -0,0 +1,50 @@
1
+ import mongoose from 'mongoose';
2
+ import dotenv from 'dotenv';
3
+
4
+ dotenv.config();
5
+
6
+ const connectDB = async (): Promise<void> => {
7
+ try {
8
+ await mongoose.connect(process.env.MONGO_URI as string);
9
+ console.log('MongoDB connected');
10
+ } catch (err) {
11
+ console.error(err);
12
+ process.exit(1);
13
+ }
14
+ };
15
+
16
+ interface IUser {
17
+ name: string;
18
+ email: string;
19
+ password: string;
20
+ }
21
+
22
+ const userSchema = new mongoose.Schema<IUser>(
23
+ {
24
+ name: String,
25
+ email: String,
26
+ password: String
27
+ },
28
+ { timestamps: true }
29
+ );
30
+
31
+ const User = mongoose.model<IUser>('User', userSchema);
32
+
33
+ // CRUD
34
+
35
+ export const getAllUsers = async () => User.find();
36
+
37
+ export const getUserById = async (id: string) =>
38
+ User.findById(id);
39
+
40
+ export const createUser = async (data: IUser) =>
41
+ User.create(data);
42
+
43
+ export const updateUser = async (
44
+ id: string,
45
+ data: Partial<IUser>
46
+ ) =>
47
+ User.findByIdAndUpdate(id, data, { new: true });
48
+
49
+ export const deleteUser = async (id: string) =>
50
+ User.findByIdAndDelete(id);
@@ -0,0 +1,58 @@
1
+ import mysql from 'mysql2/promise';
2
+ import dotenv from 'dotenv';
3
+
4
+ dotenv.config();
5
+
6
+ const pool = mysql.createPool({
7
+ host: process.env.MYSQL_HOST,
8
+ user: process.env.MYSQL_USER,
9
+ password: process.env.MYSQL_PASSWORD,
10
+ database: process.env.MYSQL_DATABASE
11
+ });
12
+
13
+ export const connectDB = async () => {
14
+ try {
15
+ await pool.getConnection();
16
+ console.log('MySQL connected');
17
+ } catch (err) {
18
+ console.error(err);
19
+ process.exit(1);
20
+ }
21
+ };
22
+
23
+ // CRUD
24
+
25
+ export const getAllUsers = async () => {
26
+ const [rows] = await pool.query('SELECT * FROM users');
27
+ return rows;
28
+ };
29
+
30
+ export const getUserById = async (id) => {
31
+ const [rows] = await pool.query(
32
+ 'SELECT * FROM users WHERE id = ?',
33
+ [id]
34
+ );
35
+ return rows[0];
36
+ };
37
+
38
+ export const createUser = async ({ name, email, password }) => {
39
+ const [result] = await pool.query(
40
+ 'INSERT INTO users (name, email, password) VALUES (?, ?, ?)',
41
+ [name, email, password]
42
+ );
43
+
44
+ return getUserById(result.insertId);
45
+ };
46
+
47
+ export const updateUser = async (id, data) => {
48
+ await pool.query(
49
+ 'UPDATE users SET name=?, email=?, password=? WHERE id=?',
50
+ [data.name, data.email, data.password, id]
51
+ );
52
+
53
+ return getUserById(id);
54
+ };
55
+
56
+ export const deleteUser = async (id) => {
57
+ await pool.query('DELETE FROM users WHERE id=?', [id]);
58
+ };