init-project-api-v2
v1.0.4
Published
This tool provides an initial setup with basic CRUD operations for the models you create. It generates a starting point for your projectThis tool provides an initial setup with basic CRUD operations for the models you create. It generates a starting point
Downloads
5
Readme
init-project-api
Introduction
init-project-api
is a Node.js package designed to simplify the initial setup of a REST API project. It automates the creation of a basic project structure, including directories and files for models, routes, controllers, and more. Additionally, it sets up essential configurations like database connection, CORS, body parsing, and even Swagger for API documentation. This tool also integrates basic CRUD operations for models created during the setup process.
Table of Contents
- Introduction
- Installation
- Usage
- Features
- Dependencies
- Configuration
- Examples
- Troubleshooting
- Contributors
- License
- Disclaimer
Installation
To install init-project-api
globally on your system, use the following npm command:
npm i -g init-project-api-v2
This will allow you to use the init-project
command in any directory to initialize a new API project.
Usage
After installing the package globally, navigate to the directory where you want to create your API project and open your terminal in that location. Run the following command:
init-project
Follow the prompts to configure your project, including setting up environment variables, adding models with CRUD operations, and more.
Features
- Generates a basic project structure for API development
- Creates a
.env
file for environment variables - Sets up a MongoDB database connection
- Initializes CRUD operations for specified models
- Supports file uploads with Multer
- Provides scripts to start the server with nodemon for live reloading
Dependencies
This package installs several dependencies required for API development, including:
- express
- mongoose
- cors
- dotenv
- bcrypt
- jsonwebtoken
- multer
- nodemon
- inquirer
- swagger-jsdoc
- swagger-ui-express
Configuration
During the setup process, the script prompts for various configurations, such as port number, MongoDB URI, secret key for JWT, etc. You can also add custom environment variables as needed.
Examples
The init-project-api-v2
tool dynamically generates models, routes, and controllers based on user input. Each model's CRUD operations are accessible through generated endpoints, adhering to RESTful standards.
For instance, if you create a User
model, the following endpoints will be available:
- POST
/api/user
to create a new user - GET
/api/user
to retrieve all users - GET
/api/user/:id
to retrieve a specific user by ID - PUT
/api/user/:id
to update a user by ID - DELETE
/api/user/:id
to delete a user by ID
Troubleshooting
If you encounter any issues during installation or execution, ensure you have the latest version of Node.js and npm installed. Check the console output for specific error messages and address any dependency-related issues.
Disclaimer
This tool provides an initial setup with basic CRUD operations for the models you create. It generates a starting point for your project, but it's up