Express Starter CLI is a command-line tool that helps you quickly scaffold a Node.js + Express.js project with MongoDB. It sets up the basic structure and installs essential packages like express
, mongoose
, jsonwebtoken
, and more. This tool saves you from repetitive setup work so you can start building your application faster.
- Creates a fully working Node.js + Express.js application.
- Sets up a MongoDB connection using
mongoose
. - Includes JWT authentication setup with
jsonwebtoken
. - Installs necessary middleware like
cors
,bcryptjs
,multer
for handling requests and file uploads. - Provides a pre-configured folder structure (controllers, models, routes, middleware, utils).
- Includes a
.env.example
file for environment variable configuration. - Adds a sample API endpoint to get you started.
To install the Express Starter CLI globally on your machine, you can use npm:
npm install -g express-starter-cli
This will make the express-starter
command available globally in your terminal.
Once the CLI is installed, you can create a new project by running:
express-starter
Replace <project-name>
with the name of your project.
This command will create a folder called my-awesome-app
with the following structure:
my-awesome-app/
├── config/
│ └── connect.js # MongoDB connection setup
├── controllers/ # Controllers for your routes
├── middleware/ # Custom middleware (e.g., for auth)
├── models/ # Mongoose models
├── routes/ # Route handlers
├── utils/ # Utility functions (e.g., token generation)
├── .env.example # Example environment variable file
├── index.js # Main file to run the application
├── package.json # NPM package configuration
After running the command, navigate into your project folder:
cd my-awesome-app
Before running the application, make sure to set up your environment variables. Copy the .env.example
file to .env
and update the values as needed:
cp .env.example .env
You can then start the server using Node.js:
node index.js
or using Nodemon for automatic restarts:
npm install -g nodemon
nodemon index.js
By default, the server will be running on http://localhost:5000
. You can change the port by updating the PORT
value in your .env
file.
After creating your project, you may want to add additional features. You can manually install other npm packages as needed. Here are some examples:
-
For logging:
npm install morgan
-
For validation:
npm install express-validator
We welcome contributions! If you'd like to add a new feature, report a bug, or improve the code, please open an issue or submit a pull request on GitHub.
To contribute:
- Fork the repository.
- Create a new branch for your feature (
git checkout -b feature/your-feature-name
). - Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature/your-feature-name
). - Open a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.