A simple NodeJs template to help you prototype your rest service for study case or even to production. It uses minimum modules as possible and MongoDb as database.
For development, you will only need Node.js and a node global package, installed in your environement.
-
Just go on official Node.js website and download the installer.
-
You can install NodeJs and npm with apt install, using the following commands:
$ sudo apt install nodejs $ sudo apt install npm
-
You can find more information about the installation on the official Node.js website and the official NPM website.
If the installation was successful, you should be able to run the following command from your command line:
$ node --version
$ npm --version
-
Just go on official MongoDb Windows Install follow the instructions.
-
Just go on official MongoDb Linux Install follow the instructions.
-
Just go on official MongoDb OS X Install follow the instructions.
After you install MongoDb in your local machine make sure it is running, then you are ready!
$ git clone https://github.com/brworkit/nodejs-server-template.git
$ cd nodejs-server-template
$ npm i [to install all required modules]
Start server using:
$ node server.js or npm start (you choose)
{
"username",
"email",
"password"
}
{
"email",
"password"
}
{
"username",
"email"
}
{
"message": "Users found",
"result": [
{
"id",
"username",
"email",
"created"
}
]
}
{
"message"
}
You can import the NODEJS-SERVER-TEMPLATE.postman_collection.json file into your postman to test API.
MIT License.
Copyright (c) 2020 brworkit.