A simple RESTful API working with MongoDB, Node Mongoose and Express
MONGODB -> No SQL server.
NODE -> JavaScript run-time environment for executing JavaScript code server-side.
Mongoose -> MongoDB validation, casting and business logic from backend.
Express -> web application framework.
Middlewares:
- body-parser
- method-override
Please make sure that you have node and mongodb installed.
To create the package.json:
npm initnpm install mongoose --save-dev
npm install express --save-dev
npm install body-parser --save-dev
npm install method-override --save-devTo install with package.json:
npm installRunning Application
Firt start the mongo service
mongodor
mongod --port 27017Then run the application
node app.jsYou can use Restlet Client for Chrome to test using http://localhost:3200/api/myfinances/ as url:
Example POST:
{
"username":"admin",
"fullName":"Administrator",
"password":"123",
"email":"test@gmail.com",
"privileges":1,
"defaultCurrency":"usd",
"preferencesShowSubcategories": true
}It will be create a database called 'finances' and a collection 'users'. To check if it is working you can call again using the method GET.
The API has suppport to PUT to update and DELETE to remove a specific document by id.
Example url:
http://localhost:3200/api/usersDiggo.cc