@product.engineer.sushant/mssp
v1.0.2
Published
A command-line tool to automate the creation of TypeScript-based microservices in a Node.js microservice architecture. MSSP generates boilerplate files, configures environment variables and Dockerfiles, updates gateway configuration, and installs dependen
Readme
MSSP — Microservice Scaffolding Pipeline
A command-line tool to automate the creation of TypeScript-based microservices in a Node.js microservice architecture. MSSP generates boilerplate files, configures environment variables and Dockerfiles, updates gateway configuration, and installs dependencies automatically.
Features
- Interactive CLI: Enter a service name using an interactive terminal prompt.
- Automatic Service Generation: Creates a new service folder and its
srcdirectory. - TypeScript Boilerplate: Generates controller, service, model, interface, enum, middleware, DTO, and router files.
- Automatic Port Assignment: Calculates and configures a port for the new service.
- Environment Configuration: Creates a service-specific
.envfile. - Docker Support: Generates a Dockerfile for the new service.
- Gateway Integration: Adds the new service's gateway configuration.
- Server Registration: Updates the
servers.jsonconfiguration. - Dependency Installation: Runs
npm installautomatically for the generated service.
Requirements
Make sure you have the following installed:
- Node.js
- npm
- TypeScript
- An existing microservice project with the expected pipeline and gateway directory structure
Installation
Install MSSP globally from npm:
npm install -g @product.engineer.sushant/msspAlternatively, run it without a global installation:
npx @product.engineer.sushant/msspNote: The package must be published to npm before other users can install it.
Usage
Navigate to the directory where you want to create your new microservice, then run:
msspThe CLI will display a welcome message and ask for a service name:
----🌟 Welcome Team ! 🌟----
Enter Service Name || To exit app write : qEnter a service name, for example:
paymentMSSP will then:
- Validate the service name.
- Create the service directory.
- Assign a port to the service.
- Generate the TypeScript application and boilerplate files.
- Create the
.env,Dockerfile, andpackage.jsonfiles. - Register the service with the gateway and server configuration.
- Install the required npm dependencies.
After successful creation, the CLI displays a success message.
Navigate to the generated service directory and start development:
cd payment
npm run devGenerated Project Structure
A generated service will have a structure similar to the following:
payment/
├── src/
│ ├── app.ts
│ ├── payment.controller.ts
│ ├── payment.service.ts
│ ├── payment.model.ts
│ ├── payment.interface.ts
│ ├── payment.enum.ts
│ ├── payment.middleware.ts
│ ├── payment.dto.ts
│ └── payment.router.ts
├── .env
├── Dockerfile
├── package.json
└── tsconfig.jsonThe exact contents of the generated files depend on the boilerplate templates configured in MSSP.
Available Commands
Run in development mode
npm run devUses ts-node-dev to run the TypeScript application during development.
Build the project
npm run buildCompiles TypeScript files using the configured tsconfig.json.
Start the compiled application
npm startRuns the compiled application from dist/app.js.
Service Naming Rules
Service names must follow these rules:
- Names must not be empty.
- Only letters, numbers, and hyphens are allowed.
- Spaces and other special characters are not allowed.
- Names are converted to lowercase.
- The service name
pipelineis reserved.
Valid examples:
payment
user-service
order123
notification-serviceInvalid examples:
Payment Service
user_service
payment@serviceConfiguration
MSSP relies on the existing pipeline configuration and boilerplate templates.
The pipeline .env file is used to determine the next service port and generate environment configuration for the new service.
The gateway integration expects the gateway project to exist in the directory structure configured by MSSP. The tool also expects the server registry to be available at the configured src/servers.json path.
Before running MSSP, ensure that these files and directories exist and are configured correctly.
Dependencies
MSSP uses the following primary dependencies:
| Package | Purpose |
|---|---|
| chalk | Terminal colors and styled messages |
| inquirer | Interactive command-line prompts |
| dotenv | Environment variable loading |
| express | Node.js web application framework |
| mongoose | MongoDB object modeling |
| cors | Cross-origin resource sharing |
| morgan | HTTP request logging |
Development dependencies include TypeScript, ts-node-dev, and the relevant type definitions.
Important Notes
- Run MSSP from the directory where you want the new service to be created.
- The parent project must follow the expected pipeline and gateway layout.
- Creating a service modifies the pipeline's port configuration, gateway application, and server registry.
- Ensure that your gateway configuration and
servers.jsonfile are backed up or version-controlled before generating services. - Keep secrets in environment variables and do not publish
.envfiles containing credentials. - Review generated configuration before deploying services to production.
Troubleshooting
Command not found
If mssp is not recognized, verify that the package was installed globally:
npm list -g --depth=0You can also try:
npx @product.engineer.sushant/msspService already exists
Choose a different service name or inspect the existing service directory before trying again.
Invalid service name
Use only letters, numbers, and hyphens, such as payment-service.
Gateway or configuration errors
Verify that the gateway directory, pipeline .env, and src/servers.json exist at the paths expected by the CLI.
Author
Sushant
License
ISC
