express-genix 1.1.0 → 1.1.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.
- package/README.md +259 -110
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,110 +1,259 @@
|
|
|
1
|
-
# Express-Genix CLI
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
-
|
|
69
|
-
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
###
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
1
|
+
# Express-Genix CLI
|
|
2
|
+
|
|
3
|
+
express-genix is a production-grade CLI tool that generates Express.js applications with a robust, scalable foundation. It scaffolds projects with JWT authentication (including refresh tokens), MongoDB (with Mongoose) or PostgreSQL (with Sequelize), rate-limiting, security middleware (Helmet, CORS), custom logging, Swagger API documentation, Jest testing, ESLint (Airbnb style), Prettier formatting, and Docker support with database services.
|
|
4
|
+
|
|
5
|
+
**NEW**: Now includes a "No Database" option for APIs that don't require database persistence - perfect for microservices, proxy servers, or computational APIs.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- Generates Express apps with a clean structure (src/server.js, src/app.js, src/routes, etc.)
|
|
10
|
+
- **Three database options**: MongoDB (Mongoose), PostgreSQL (Sequelize), or No Database
|
|
11
|
+
- Includes JWT-based authentication with register, login, refresh tokens, and logout (database modes)
|
|
12
|
+
- Provides security (Helmet, CORS, rate-limiting), logging (Morgan, custom logger), and Swagger UI
|
|
13
|
+
- Sets up Jest/Supertest for testing, ESLint for code quality, and Prettier for formatting
|
|
14
|
+
- **Automatic post-generation cleanup** - runs `eslint --fix` and Prettier formatting
|
|
15
|
+
- **Zero linting errors out of the box** - generated code is production-ready immediately
|
|
16
|
+
- Docker configuration with database services for easy deployment
|
|
17
|
+
- User-friendly CLI with input validation and detailed output
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
Install express-genix globally from npm to use it anywhere:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install -g express-genix
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Alternatively, use it directly with npx without installation:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npx express-genix init
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Usage
|
|
34
|
+
|
|
35
|
+
Run the CLI to generate a new Express project:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
express-genix init
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Or with npx:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
npx express-genix init
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Prompts
|
|
48
|
+
|
|
49
|
+
- **Project name**: Enter a name (letters, numbers, hyphens, underscores; default: my-express-app)
|
|
50
|
+
- **Database**: Choose from:
|
|
51
|
+
- **MongoDB (with Mongoose)** - Full authentication system with JWT
|
|
52
|
+
- **PostgreSQL (with Sequelize)** - Full authentication system with JWT
|
|
53
|
+
- **No Database (API without database)** - Example CRUD API with in-memory storage
|
|
54
|
+
|
|
55
|
+
The CLI creates a project directory, generates files, installs dependencies, and **automatically formats and lints the code**.
|
|
56
|
+
|
|
57
|
+
Navigate to the generated project (e.g., `cd my-express-app`) and run:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npm run dev
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Visit `http://localhost:3000/api-docs` for Swagger documentation or `http://localhost:3000/health` for health checks.
|
|
64
|
+
|
|
65
|
+
### Generated Project Features
|
|
66
|
+
|
|
67
|
+
**All Projects Include:**
|
|
68
|
+
- Rate limiting, security middleware, logging
|
|
69
|
+
- Swagger API documentation with OpenAPI 3.0
|
|
70
|
+
- Jest testing with coverage
|
|
71
|
+
- ESLint (Airbnb) + Prettier formatting
|
|
72
|
+
- Docker support with clustering
|
|
73
|
+
- Health checks and structured logging
|
|
74
|
+
|
|
75
|
+
**Database Projects Include:**
|
|
76
|
+
- **Authentication**: `/api/auth/register`, `/api/auth/login`, `/api/auth/refresh`, `/api/auth/logout`
|
|
77
|
+
- **User Management**: `/api/users/profile` (GET, PUT, DELETE)
|
|
78
|
+
- **Features**: JWT with refresh tokens, password hashing (bcrypt)
|
|
79
|
+
|
|
80
|
+
**No-Database Projects Include:**
|
|
81
|
+
- **Example API**: `/api/examples` (GET, POST, PUT, DELETE) with in-memory storage
|
|
82
|
+
- **Perfect for**: Microservices, proxy servers, computational APIs
|
|
83
|
+
|
|
84
|
+
### CLI Options
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
express-genix init --skip-cleanup # Skip automatic formatting (for debugging)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Project Structure
|
|
91
|
+
|
|
92
|
+
### CLI Structure
|
|
93
|
+
```
|
|
94
|
+
express-genix/
|
|
95
|
+
├── index.js # Main CLI entry point
|
|
96
|
+
├── package.json # CLI package configuration
|
|
97
|
+
├── README.md # This documentation
|
|
98
|
+
├── lib/
|
|
99
|
+
│ ├── cleanup.js # Post-generation cleanup functions
|
|
100
|
+
│ ├── generator.js # File generation logic
|
|
101
|
+
│ └── utils.js # Utility functions
|
|
102
|
+
└── templates/
|
|
103
|
+
├── core/ # Core files (app.js, server.js, etc.)
|
|
104
|
+
├── config/ # Configuration files
|
|
105
|
+
├── controllers/ # Route handlers
|
|
106
|
+
├── middleware/ # Custom middleware
|
|
107
|
+
├── models/ # Database models
|
|
108
|
+
├── routes/ # API routes
|
|
109
|
+
├── services/ # Business logic
|
|
110
|
+
├── utils/ # Utilities
|
|
111
|
+
└── tests/ # Test files
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Generated Express App Structure
|
|
115
|
+
```
|
|
116
|
+
├── src/
|
|
117
|
+
│ ├── config/ # Database and Swagger configurations
|
|
118
|
+
│ ├── controllers/ # Request handlers and business logic
|
|
119
|
+
│ ├── middleware/ # Custom middleware (auth, validation, errors)
|
|
120
|
+
│ ├── models/ # Database models (if using database)
|
|
121
|
+
│ ├── routes/ # API route definitions
|
|
122
|
+
│ ├── services/ # Business logic layer
|
|
123
|
+
│ ├── utils/ # Utility functions and helpers
|
|
124
|
+
│ ├── app.js # Express app setup with middleware
|
|
125
|
+
│ └── server.js # Server entry point with clustering
|
|
126
|
+
├── tests/ # Jest tests for endpoints
|
|
127
|
+
├── .env # Environment variables
|
|
128
|
+
├── .eslintrc.json # ESLint configuration
|
|
129
|
+
├── .prettierrc # Prettier configuration
|
|
130
|
+
├── Dockerfile # Docker configuration
|
|
131
|
+
├── docker-compose.yml # Docker services (app + database)
|
|
132
|
+
└── package.json # Dependencies and scripts
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Available Scripts (Generated Project)
|
|
136
|
+
|
|
137
|
+
- `npm run dev` - Start development server with nodemon
|
|
138
|
+
- `npm start` - Start production server with clustering
|
|
139
|
+
- `npm test` - Run Jest tests with coverage
|
|
140
|
+
- `npm run lint` - Run ESLint checks
|
|
141
|
+
- `npm run lint:fix` - Fix ESLint issues automatically
|
|
142
|
+
- `npm run format` - Format code with Prettier
|
|
143
|
+
- `npm run format:check` - Check code formatting
|
|
144
|
+
|
|
145
|
+
## Contributing
|
|
146
|
+
|
|
147
|
+
To contribute to express-genix:
|
|
148
|
+
|
|
149
|
+
1. **Fork and Clone**:
|
|
150
|
+
```bash
|
|
151
|
+
git clone <your-fork-url>
|
|
152
|
+
cd express-genix
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
2. **Install Dependencies**:
|
|
156
|
+
```bash
|
|
157
|
+
npm install
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
3. **Make Changes**:
|
|
161
|
+
- Update templates in `templates/` directory
|
|
162
|
+
- Modify generation logic in `lib/generator.js`
|
|
163
|
+
- Follow Airbnb JavaScript style
|
|
164
|
+
- Test changes locally: `node index.js init`
|
|
165
|
+
- Verify generated projects have zero linting errors
|
|
166
|
+
|
|
167
|
+
4. **Submit a Pull Request**:
|
|
168
|
+
- Push changes and submit a PR with a clear description
|
|
169
|
+
- Include test results showing the generated project works correctly
|
|
170
|
+
|
|
171
|
+
## Version History
|
|
172
|
+
|
|
173
|
+
- **v1.1.0**: Added "No Database" option and template-based architecture with EJS
|
|
174
|
+
- **v1.0.1**: Added automatic post-generation cleanup with Prettier and ESLint auto-fix
|
|
175
|
+
- **v1.0.0**: Initial release with Express boilerplate generation
|
|
176
|
+
|
|
177
|
+
## Publishing to npm
|
|
178
|
+
|
|
179
|
+
To publish express-genix to npm, follow these steps from the CLI's root directory:
|
|
180
|
+
|
|
181
|
+
### 1. Prepare the Project
|
|
182
|
+
|
|
183
|
+
Ensure all template files are in place in the `templates/` directory structure.
|
|
184
|
+
|
|
185
|
+
Verify `package.json` is configured correctly:
|
|
186
|
+
|
|
187
|
+
```json
|
|
188
|
+
{
|
|
189
|
+
"name": "express-genix",
|
|
190
|
+
"version": "1.1.0",
|
|
191
|
+
"description": "Production-grade CLI to generate Express apps with JWT, DB, rate-limiting, automatic formatting, and more",
|
|
192
|
+
"main": "index.js",
|
|
193
|
+
"bin": {
|
|
194
|
+
"express-genix": "./index.js"
|
|
195
|
+
},
|
|
196
|
+
"dependencies": {
|
|
197
|
+
"commander": "^12.1.0",
|
|
198
|
+
"inquirer": "^10.2.0",
|
|
199
|
+
"ejs": "^3.1.9"
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### 2. Test Locally
|
|
205
|
+
|
|
206
|
+
Run the CLI to ensure it generates working, properly formatted projects for all three database options:
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
node index.js init
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
Test each option:
|
|
213
|
+
- MongoDB with authentication
|
|
214
|
+
- PostgreSQL with authentication
|
|
215
|
+
- No database with example API
|
|
216
|
+
|
|
217
|
+
### 3. Publish
|
|
218
|
+
|
|
219
|
+
Login to npm and publish:
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
npm login
|
|
223
|
+
npm publish --access public
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### 4. Verify
|
|
227
|
+
|
|
228
|
+
Test the published package:
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
npx express-genix init
|
|
232
|
+
# Should generate a project with zero linting errors
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Troubleshooting
|
|
236
|
+
|
|
237
|
+
### Publishing Issues
|
|
238
|
+
|
|
239
|
+
- **Name Conflict**: If `express-genix` is taken, use a scoped name like `@yourname/express-genix`
|
|
240
|
+
- **Authentication Error**: Verify with `npm whoami`, re-login if needed
|
|
241
|
+
- **Permission Issues**: Move project to a directory with full write access
|
|
242
|
+
|
|
243
|
+
### Generated Project Issues
|
|
244
|
+
|
|
245
|
+
- **Dependency Errors**: Run `npm cache clean --force && npm install`
|
|
246
|
+
- **Database Connection**: Ensure MongoDB/PostgreSQL is running and connection strings are correct
|
|
247
|
+
- **Linting Issues**: Run `npm run lint:fix && npm run format` to resolve formatting
|
|
248
|
+
|
|
249
|
+
## License
|
|
250
|
+
|
|
251
|
+
MIT License
|
|
252
|
+
|
|
253
|
+
Copyright (c) 2025 Joshua Maeba Nyamasege
|
|
254
|
+
|
|
255
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
256
|
+
|
|
257
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
258
|
+
|
|
259
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|