men-api-scaffold
v1.0.5
Published
A CLI to scaffold a MEN stack API project using ES6 modules.
Maintainers
Readme
men-api-scaffold
A simple CLI tool to scaffold a modern MEN stack (MongoDB, Express, Node.js) API project using ES6 modules.
🚀 Usage
You can use this tool to create a new API project by running:
npx men-api-scaffold my-apiThis will create a new folder my-api/ with the full project structure, including all configuration files and dependencies defined.
📁 What you get
- Express app with ES6 module support
- MongoDB integration via Mongoose
- Static file setup and middleware preconfigured
.env.exampleand linting ready- Modular folder structure for scalability
📝 Next steps
After generation:
cd my-api
npm install- make sure to create .env based on the provided .example or copy it as logs show right before launch.
finally
npm run dev[!IMPORTANT]
In case you are not using mongoDB in your pc you will get an
MongooseServerSelectionError: connect ECONNREFUSED
⚠️ MongoDB Connection Requirements
This scaffold uses MongoDB with Mongoose. To run the project successfully, a valid MongoDB connection must be available.
🧩 1. Use Local MongoDB (default option)
By default, the scaffold expects MongoDB to be running locally at: mongodb://localhost:27017
✅ Steps to run it locally:
Install MongoDB Community Edition:
- https://www.mongodb.com/try/download/community
Start MongoDB:
- On Windows (using services):
net start MongoDB
Or manually:
bashmongod
Verify it is running:
bashmongo
- Set the .env file: Create your .env from the example file: bashcp .env.example .env Example content: envMONGO_URI=mongodb://localhost:27017/men-db PORT=4444
🌐 2. Use MongoDB Atlas (cloud)
- If you don't want to install MongoDB locally, use MongoDB Atlas: ✅ Steps:
Sign up at: https://www.mongodb.com/cloud/atlas
Create a new cluster (Shared Tier is free)
Click "Connect" > "Connect your application", and copy the connection string like: mongodb+srv://:@.mongodb.net/?retryWrites=true&w=majority
Replace , , , and with your actual values.
Paste it into your .env:
envMONGO_URI=mongodb+srv://user:[email protected]/my-db PORT=4444
📦 Project structure
The generated project includes:
my-api/
├── bin/
├── lib/
├── models/
├── public/
├── routes/
├── views/
├── app.js
├── .env.example
├── package.json
├── README.md
└── ...🛠 Maintained by
Roberto Gomez Fabrega
GitHub Repository
