api-writer
v0.0.8
Published
Streamline API writing with lightning-fast performance. Simplify complex tasks and reduce development time with streamlined code. Boost productivity and efficiency with optimized workflows.
Downloads
12
Readme
Description
api-writer
is a tool for quickly generating a Node.js project with MongoDB integration. It sets up a basic API server using Express.js for routing, MongoDB for data storage, and includes automatic generation of models, controllers, and routes for each module.
Usage
Import package
const apiWriter = require('api-writer');
Define your schema
const modules = [
{
name: 'User',
properties: ['id', 'name', 'email'],
additionalApis: [
{ method: 'POST', controllerFunction: 'createUser' },
{ method: 'DELETE', controllerFunction: 'deleteUserById' }
]
},
{
name: 'Post',
properties: ['id', 'title', 'content'],
additionalApis: [
{ method: 'PUT', controllerFunction: 'updatePostTitle' }
]
}
];
Generate project
const projectName = 'projectAlpha';
apiWriter(projectName, modules);
Features
- Generates a basic Node.js project structure with MongoDB integration.
- Automatically generates MongoDB models, controllers, and routes for each module.
- Supports additional APIs for modules.
- Includes MongoDB configuration.
- Uses Express.js for routing.
- Easy to customize and extend.
Project Structure
app.js
: Main entry point of the application.server.js
: Starts the server.dbConfig.js
: MongoDB configuration.models/<Module>Model.js
: Directory for modelsroutes/<Module>Route.js
: Directory for routescontrollers/<Module>Controller.js
: Directory for controllers.package.json
: Project metadata and dependencies.
Contributing
Contributions are welcome! Please submit pull requests to contribute to this project.
Licence
This project is licensed under the MIT License.