yapper-cli
v2.1.0
Published
yapper is highly opionated cli tool that lets you generate strucutred Apis,modules and production ready setups instantly.
Readme
yapper
😺 Yapper is a highly opinionated CLI tool that lets you generate structured APIs, modules, and production-ready Express + Mongoose setups instantly.
It handles all the boilerplate of setting up an production grade Express.js application and allows you to easily generate new API modules (controllers, services, routes, and schemas) with a single command.
Installation
Install yapper globally via npm to use its commands from anywhere:
npm install -g yapper-cliUsage
1. Create a New Project
To generate a new, fully configured Express + Mongoose project, use the yapper command:
yapper <project-name>This will create a new folder named <project-name> containing:
- A structured Express app with best practices
- Centralized error handling and standardized API responses
- Pre-configured
loggeranddotenv - A MongoDB connection setup using Mongoose
- TypeScript support and standard configurations (
tsconfig.json,package.json, etc.) - Dockerization Setup: A production-ready multi-stage
Dockerfile,.dockerignore, and a pre-configureddocker-compose.yml(with a health-checked MongoDB instance). - Prettier Setup: Pre-configured code formatting via
.prettierrcand.prettierignore, with npm scripts to run Prettier.
Once generated, navigate into your new project, check dependencies, and start the dev server:
cd <project-name>
npm run dev2. Generate a New Module
To add a new API module to your project, use the yapp command from within your project's root directory:
yapp <module-name>For example, running yapp user will automatically generate the following files:
src/schemas/user.schema.tssrc/services/user.service.tssrc/controllers/user.controller.tssrc/routes/user.route.ts
These files come pre-filled with standard CRUD boilerplate, completely hooked up and ready to be imported into your main application.
3. Docker Support
Yapper generates everything needed to run your application in Docker out of the box.
Configuration Files Generated:
- Dockerfile: A multi-stage build optimized for production (using
node:20-alpine). The builder stage compiles TypeScript, and the production stage packages only the build artifacts and production dependencies (npm ci --omit=dev). - docker-compose.yml: Orchestrates the application container and a health-checked
mongo:7database container. - .dockerignore: Prevents build context bloat by excluding files like
node_modules,dist,.env, and git configs.
Steps to Run with Docker:
Navigate to the project directory:
cd <project-name>Open the
.envfile (or copy from.env.example) and configure theMONGO_URIto use themongoservice name as the hostname. For example:MONGO_URI=mongodb://mongo:27017/<project-name>Spin up the application and database services:
docker compose up --build(Or
docker-compose up --buildif you are using Docker Compose V1)
The server will start up once the MongoDB container health check passes, and will be accessible at the port specified in your .env (defaults to 3000).
Contributing
Contributions, ideas, and improvements are welcome.
Open an issue or submit a PR.
- Connect With Me
Suggestions are welcome.
Email: [email protected]
Blog
- Newsletter
https://newsletter.anshumancdx.xyz/
Support the Project
If you find this useful, consider giving the repo a star at
