This is the RESTful API Service. It's base example include token authorisation and sample of CRUD (create, read, update, delete) operations.
-
To store user accounts and other information i use
mongodb
. If you want you can use localmongodb
server or you can use free plan for example from mlab. How to create database on mlab see docs -
Make project directory and initialise npm project
mkdir restapi
cd restapi
npm init
- Install base node packages
npm install --save bcrypt body-parser express jsonwebtoken mongoose mongoose-timestamp postmark
- You can clone this project and skep 1 and 2 steps by
git clone git@github.com:simdo/rest.api.git
or download source project files
- Create environment file
env.json
on the root project folder
touch env.json
- Put the following code into
env.json
{
"product" : "RESTful API Service",
"company" : "Company Name, LLC",
"api" : {
"version" : "v1.0"
},
"port" : 3000,
"hosts" : {
"api" : "api.domain.name",
"app" : "app.domain.name"
},
"environment" : "development",
"mongodb" : "mongodb://user:password@id.mlab.com:port/dbname",
"secret" : "Some super sercet string for JSON Web token",
"postmark" : {
"secret" : "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
"welcome" : 1272561,
"reset" : 1272761,
"password" : 1279242,
"security" : 1279241
},
"from_email" : "Service Robot <robot@domain.name>",
"to_email" : "support@domain.name"
}
- Start project
node index.js
- Use for example Postman for test you Restful API server
This project adheres to Semantic Versioning. Every release, along with the migration instructions, is documented on the Github Releases page.
MIT