sam-starter is a CLI tool for initializing backend development projects with a structured setup for models, controllers, routes, and more.
To install sam-starter
, use npm (Node.js package manager):
npm install -g sam-starter
This command installs sam-starter
globally, allowing you to use it from any directory in your terminal.
To initialize a new backend project using sam-starter
, navigate to your project directory and run:
sam init
This command sets up the basic project structure and installs necessary dependencies defined in the starter template.
To create a new model in your project, use the following command:
sam make:model ModelName
Replace ModelName
with the name of your model. This command creates a new model file (ModelNameModel.js
) under src/models
and sets up basic schema and model definitions using Mongoose.
To create a new controller in your project, use the following command:
sam make:controller ControllerName
Replace ControllerName
with the name of your controller. This command generates a new controller file (ControllerNameController.js
) under src/controllers
with a basic controller class template.
To create a new route in your project, use the following command:
sam make:route RouteName
Replace RouteName
with the name of your route. This command creates a new route file (RouteNameRoute.js
) under src/routes
and sets up route handlers using Express.
Note: If a route file with the specified name already exists, sam-starter
will display a message indicating that the route already exists and will not overwrite the existing file.
After initializing your project with sam init
, the project structure will look like this:
my-project/
│
├── src/
│ ├── models/
│ │ ├── ModelNameModel.js
│ │ └── ...
│ ├── controllers/
│ │ ├── ControllerNameController.js
│ │ └── ...
│ ├── routes/
│ │ ├── RouteNameRoute.js
│ │ └── route.js
│ │ └── ...
│ └── ...
│
├── package.json
└── README.md
This project is licensed under the MIT License - see the LICENSE file for details.