Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nodejs-backpack

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nodejs-backpack

Node Backpack is a powerful tool designed to simplify the development of Node.js REST APIs with ease and precision. It provides a streamlined workflow by automatically generating Mongoose schemas and handling the necessary configurations in your project.

  • 1.0.1
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Node Backpack

Node Backpack is a powerful tool designed to simplify the development of Node.js REST APIs with ease and precision. It provides a streamlined workflow by automatically generating Mongoose schemas and handling the necessary configurations in your project. With just a few simple commands, Node Backpack can create REST API components such as controllers and routes, while also ensuring route validation is implemented flawlessly. Additionally, Node Backpack offers a command to generate sample files, providing a solid starting point for your project. With Node Backpack, you can quickly set up your project and focus on building your APIs, letting the tool handle the repetitive tasks and allowing you to follow a smooth development process.

Installation

Install package globally with npm

  npm install nodejs-backpack -g

Useful Steps & Commands

Step1: Create an empty directory

  • Create directory mkdir NodeJs-REST-APIs
  • Enter into directory cd NodeJs-REST-APIs

Step1: Run Command nodejs-backpack sample:files

  • File "sample-app.js", "sample-package.json" & ".sample-env" created in the root directory.

  • Rename sample files to "app.js", "package.json" & ".env" which are created in the root directory.

  • Update .env > DB=mongodb+srv... with valid connection.

    PORT=3000
    DB="mongodb+srv://........mongodb.net/node_backpack"
    

Step2: Run Command nodejs-backpack make:schema Post

  • Rename schema name in comand as per your requirement nodejs-backpack make:schema Post
  • File "Post.js" created in the '/models' directory
  • Update /models/Post.js schema and add necessary fields with required: true/false

Step3: Run Command nodejs-backpack make:apis Post --url=posts --schema=Posts

  • Rename schema name in comand as per your requirement nodejs-backpack make:apis Post --url=posts --schema=Posts.
  • Example: nodejs-backpack make:apis ROUTE_NAME --url=ROUTE_URL --schema=SCHEMA_NAME.
  • Note: SCHEMA_NAME must exist in model directory /models/SCHEMA_NAME

-- It will autogenerate below files for REST APIs and export into respective directories as shown in below details:

  • PostRoute.js file created in the '/routes' directory.
  • PostController.js file created successfully in the '/controllers/' directory.
  • IndexRoute.js file created successfully.
  • ListValidationRequest.js file created in the '/routes/validationRequest/' directory.
  • GetDetailValidationRequest.js file created in the '/routes/validationRequest/' directory.
  • StoreValidationRequest.js file created in the '/routes/validationRequest/' directory.
  • UpdateValidationRequest.js file created in the '/routes/validationRequest/' directory.
  • DestroyValidationRequest.js file created in the '/routes/validationRequest/' directory.
  • const PostRoute = require("./PostRoute"); imported into IndexRoute.js successfully!
  • router.use("/", PostRoute); appended into IndexRoute.js successfully.

Step4: Now your APIs are ready to use and you can do modification in files as per your custom requiremnt:

Step5: Open Postman and create new collection and check the below apis:

  • Based on my command, nodejs-backpack make:apis Post --url=posts --schema=Posts.
  • ROUTE_NAME = Post
  • ROUTE_URL = posts
  • SCHEMA_NAME = Posts
  • Below are list of APIs created by commands .../api/ROUTE_URL:
  • Get List API: GET: http://localhost:3000/api/posts?page_no=1&page_limit=20&search=
  • Get Detail API: GET: http://localhost:3000/api/posts/64a41036174844d0394e7b2f
  • Store API: GET: http://localhost:3000/api/posts
  • Update API: GET: http://localhost:3000/api/posts/64a41036174844d0394e7b2f
  • Delete API: GET: http://localhost:3000/api/posts/64a41036174844d0394e7b2f

Environment Variables

To run this project, you will need to add the following environment variables to your .env file

PORT=3000
DB="mongodb+srv://........mongodb.net/node_backpack"

Authors

  • Jaykumar Gohil (@jksk21)

Keywords

FAQs

Package last updated on 05 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc