GithubHelp home page GithubHelp logo

simplerest's Introduction

simpleREST

a node.js simple REST app using ejs and mongodb

This example is based on: http://coenraets.org/blog/2012/10/creating-a-rest-api-using-node-js-express-and-mongodb/

Terms

  • CRUD - Create, Read, Update and Delete
  • REST - REpresentational State Transfer
  • DAO - Data Access Object

Used Technologies

  • node.js
  • express
  • ejs (view engine)
  • mongodb

Application layers

  • Presentation - HTML and CSS. The HTML files contain only static data and controls, NO format and NO logic.
  • Presentation logic - Javascript and jQuery.
  • Business logic interface - REST services. Presentation logic call REST services (using jQuery), which produces JSON data.
  • Business logic - Logic or service classes, separated from REST facades. SOA style decoupling.
  • Data logic - DAO classes.

Setting up the project

  • execute the following commands from the project library:
  •  $ npm install -g express		 // install express globally
    
  •  $ express --sessions --ejs	// create express application skeleton (with EJS and Session)
    
  •  $ npm install -d				       // install all dependencies
    
  •  $ npm install mongodb
    

Project Tree - Starting point (as generated by express)

/
|- package.json
|- app.js
/ public
	/ javascripts
	/ images
	/ stylesheets
		|- style.css
/ routes
	|- index.js
	|- user.js
/ views
	|- index.ejs

Our Project Tree

/
|- package.json
|- app.js
/ lib
	- products.js			[Data Logic (DAO)]
/ public
	/ javascripts			[Presentation Logic]
		/ external
		/ views_cb
			|- index_cb.js	//code-behind for index.ejs (you will find jQuery ajax requests here)
	/ images
	/ stylesheets			[Presentation]
		|- style.css
/ routes
	|- index.js			
/ views					[Presentation]
	|- index.ejs
	|- layout.ejs
	|- products.ejs

Testing

can be done using cURL (command line utility for transferring data with URL syntax)

simplerest's People

Contributors

orenelzam avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.