Skip to content

alesm0101/finances

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RESTful API with MongoDB

A simple RESTful API working with MongoDB, Node Mongoose and Express

Dependencies:

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

Quick Start

Please make sure that you have node and mongodb installed.

To create the package.json:

npm init
npm install mongoose --save-dev
npm install express --save-dev
npm install body-parser --save-dev
npm install method-override --save-dev

To install with package.json:

npm install

Running Application

Firt start the mongo service

mongod

or

mongod --port 27017

Then run the application

node app.js

Testing

You 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/users

Credits

Diggo.cc

About

Using MongoDB

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published