create-express-kickstart 1.3.2 → 1.3.4
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/.env.example +11 -9
- package/README.md +7 -7
- package/bin/cli.js +804 -393
- package/package.json +5 -5
- package/src/app.js +34 -78
- package/src/db/index.js +12 -14
- package/src/server.js +18 -20
- package/templates/.dockerignore +8 -0
- package/templates/Dockerfile +14 -20
- package/templates/auth/auth.controller.js +96 -31
- package/templates/auth/auth.middleware.js +30 -22
- package/templates/auth/user.model.js +31 -0
- package/templates/docker-compose.yml +21 -23
- package/tests/cli.test.js +573 -0
- package/src/models/example-model.js +0 -18
- package/src/utils/constants.js +0 -1
package/.env.example
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
# Basic Environment Variables
|
|
2
|
-
PORT=8000
|
|
3
|
-
MONGODB_URI=mongodb://localhost:27017/
|
|
4
|
-
CORS_ORIGIN
|
|
5
|
-
NODE_ENV=development
|
|
6
|
-
|
|
7
|
-
# Rate Limiting
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
# Basic Environment Variables
|
|
2
|
+
PORT=8000
|
|
3
|
+
MONGODB_URI=mongodb://localhost:27017/my_app_db
|
|
4
|
+
CORS_ORIGIN=http://localhost:3000
|
|
5
|
+
NODE_ENV=development
|
|
6
|
+
|
|
7
|
+
# Rate Limiting
|
|
8
|
+
# 15 minutes in milliseconds
|
|
9
|
+
RATE_LIMIT_WINDOW_MS=900000
|
|
10
|
+
# Maximum requests per window
|
|
11
|
+
RATE_LIMIT_MAX=100
|
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
[](https://expressjs.com/)
|
|
5
5
|
[](https://opensource.org/licenses/ISC)
|
|
6
6
|
|
|
7
|
-
A
|
|
7
|
+
A configurable CLI tool to scaffold a solid Express API foundation with sane defaults for routing, middleware, error handling, auth starters, and Docker support.
|
|
8
8
|
|
|
9
9
|
## Quick Start
|
|
10
10
|
```bash
|
|
@@ -14,7 +14,7 @@ npx create-express-kickstart@latest my-app
|
|
|
14
14
|
## What is `create-express-kickstart`?
|
|
15
15
|
|
|
16
16
|
**The Purpose:**
|
|
17
|
-
Whenever developers start a new Node.js & Express.js project, they often spend the first couple of hours writing the
|
|
17
|
+
Whenever developers start a new Node.js & Express.js project, they often spend the first couple of hours writing the same setup code: configuring `express`, setting up `cors`, managing environment variables, writing global error handlers, standardizing API responses, and wiring database connections. `create-express-kickstart` exists to remove that repetitive setup so you can move straight into business logic with a consistent starter.
|
|
18
18
|
|
|
19
19
|
**What It Does:**
|
|
20
20
|
It is an interactive CLI framework scaffolding generator. Upon running the command, it asks you a series of simple questions regarding the architecture of your new API (e.g., Do you want MongoDB? Do you want JWT Auth Boilerplate? Docker? Jest for testing?). Based on your exact answers, it instantly generates a fully configured, running codebase tailored exclusively to your project's needs.
|
|
@@ -23,8 +23,8 @@ It is an interactive CLI framework scaffolding generator. Upon running the comma
|
|
|
23
23
|
Under the hood, the CLI runs dynamically directly from NPM via `npx` executing a Node.js compiler script:
|
|
24
24
|
1. **Interactive Prompting:** The CLI polls for your configurations in real-time.
|
|
25
25
|
2. **Selective Templating:** It recursively copies a pre-configured, highly modular `src` application design into your directory.
|
|
26
|
-
3. **
|
|
27
|
-
4. **
|
|
26
|
+
3. **Selective Scaffolding:** If you opt out of specific modules like CORS, Pino, or Mongoose, the generator removes those pieces from the generated app so you do not start with unused code.
|
|
27
|
+
4. **Dependency Bootstrapping:** It writes a project-specific `package.json`, installs the selected dependencies with your chosen package manager (`npm`, `yarn`, `pnpm`, or `bun`), and pins installed versions when the install completes successfully.
|
|
28
28
|
|
|
29
29
|
**What is Inside (The Architecture):**
|
|
30
30
|
The generated Express template champions the **MVC (Model-View-Controller)** pattern with robust modern Node.js Path Aliasing bindings enabled out of the box:
|
|
@@ -35,7 +35,7 @@ The generated Express template champions the **MVC (Model-View-Controller)** pat
|
|
|
35
35
|
- `ApiResponse` structure class for predictable and formatted JSON HTTP payloads.
|
|
36
36
|
- `ApiError` extension class for standardizing HTTP error interceptions.
|
|
37
37
|
- `asyncHandler` functional wrapper intercepting promise rejections seamlessly to avoid repetitive try-catch blocks in your controllers!
|
|
38
|
-
- **Optional Add-ons** -
|
|
38
|
+
- **Optional Add-ons** - JWT + Mongo auth starter routes, generated cryptographic helpers (`bcryptjs` and `jsonwebtoken`), Docker templates, and Jest healthcheck tests.
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
---
|
|
@@ -61,7 +61,7 @@ npx create-express-kickstart@latest my-awesome-api
|
|
|
61
61
|
### 2. What happens under the hood?
|
|
62
62
|
1. **Scaffolding:** It instantly generates your API boilerplate with built-in `errorHandler`, `ApiResponse`, and `asyncHandler` classes/utilities.
|
|
63
63
|
2. **Setup:** It automatically configures `.env`, path resolutions, and modern ES setups inside `package.json`.
|
|
64
|
-
3. **
|
|
64
|
+
3. **Selected Dependencies:** It installs the dependencies you chose for that project, including Express middleware, MongoDB support, Docker assets, or JWT auth scaffolding when requested.
|
|
65
65
|
|
|
66
66
|
### 3. Run Your Application
|
|
67
67
|
|
|
@@ -116,7 +116,7 @@ const restrictedRoute = asyncHandler(async (req, res) => {
|
|
|
116
116
|
A wrapper for your async route handlers that eliminates the need for repetitive `try-catch` blocks.
|
|
117
117
|
|
|
118
118
|
### `jwt.util.js` & `hash.util.js`
|
|
119
|
-
If you choose
|
|
119
|
+
If you choose the JWT auth starter, the generated app includes Mongoose-backed auth routes, secure password hashing utilities, JWT helpers, and placeholder environment configuration for secrets.
|
|
120
120
|
```javascript
|
|
121
121
|
import { hashData, compareData } from "#utils/hash.util.js";
|
|
122
122
|
import { generateToken, verifyToken } from "#utils/jwt.util.js";
|