Node REST service with express + Sequelize for MySql
CoffeeScript JavaScript
Switch branches/tags
Nothing to show
Pull request Compare This branch is 43 commits ahead, 1 commit behind master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
daos
node_modules
public
scripts
test
Gruntfile.coffee
Gruntfile.js
README.md
app.coffee
app.js
database.coffee
database.js
models.coffee
models.js
package.json
routes.coffee
routes.js
routesSequelize.coffee
routesSequelize.js
urlValidator.coffee
urlValidator.js

README.md

#Node.js RESTful API with MySql/MongoHQ database with Express + Sequelize#


##TODO:##

##References:##

##NOTES:##

  • Server created at http://localhost:8010
  • CoffeeScript implemented.
  • Tested with mocha + request + should.js (see TODO)
  • Tested with vows + request + assert (see TODO)
  • Tested with QUnit (see TODO)

express-resource is NOT COMPATIBLE with express3 so I used express for the routings

##API reference##

###/patterns (GET)###

  • DESCRIPTION Returns all patterns

  • URL STRUCTURE ...[api_url]/patterns

  • METHOD GET

  • RETURNS A list of all patterns patterns on the current revision The HTTP response contains all patterns in a JSON array

    Sample JSON return value

    [  
    {  
	    "name": "Singleton",  
    	"category": "Creational",  
    	"intent": "Ensure a class only has one instance, and provide a global point of acg cess to it",  
    	"motivation": "It's important for some classes to have exactly one instance. Making a class responsible for keepintrack of its sole instance.",  
    	"applicability": "there must be exactly one instance of a class, and it must be accessible.\\nwhen the sole instance should be extensible by subclassing, and clients",  
    	"structure": "Cambiar por BLOB",  
        "_id": "50f6f74fe4f707ca70000001"  
    },  
    {  
        "name": "Prototype",  
        "category": "Creational",  
        "intent": "Specify the kinds of objects to create using a prototypical instance, and create",  
        "motivation": "Use the Prototype Pattern when a client needs to create  a set of",  
        "applicability": "Use the Prototype pattern when a system should be independent of how its products",  
        "structure": "Cambiar por BLOB",  
        "_id": "50f6f74fe4f707ca70000002"  
    }  
    ]
  • ERRORS

###/patterns (POST)###

  • DESCRIPTION inserts a new pattern
  • URL STRUCTURE ...[api_url]/patterns
  • METHOD POST
  • REQUEST BODY required A JSON object with the new pattern's data with unless the name field
  • RETURNS status code 200
  • ERRORS 400 Error inserting pattern

###/patterns (PUT)###

  • DESCRIPTION updates a collection of patterns

  • URL STRUCTURE ...[api_url]/patterns

  • METHOD PUT

  • REQUEST BODY required A JSON array object with the collecion of patterns to be updated.

  • RETURNS a JSON object with the number of total updated patterns

    Sample JSON return value

    {
        "updated_patterns": 2
    }

###/patterns (DEL)###

  • DESCRIPTION Deletes all patterns.

  • URL STRUCTURE ...[api_url]/patterns

  • METHOD DEL

  • RETURNS a JSON object with the number of total deleted patterns.

    Sample JSON return value

    {
        "deleted_patterns": 3
    }

###/patterns/count (GET)###

  • DESCRIPTION returns the number of patterns

  • URL STRUCTURE ...[api_url]/patterns/count

  • METHOD GET

  • RETURNS A JSON object with the number of patterns in our database.

    Sample JSON return value

    {
        "number_of_patterns": 4
    }

###/patterns/:name (GET)###

  • DESCRIPTION Returns information about the pattern specified by the name parameter

  • URL STRUCTURE ...[api_url]/patterns/:name

  • METHOD GET

  • PARAMETERS name: Used to specify the name of the pattern to be returned

  • RETURNS A JSON object with information about the parameter specified by the :name attribute.

    Sample JSON return value

    {
        "name": "Singleton",
        "category": "Creational",
        "intent": "Ensure a class only has one instance, and provide a global point of acg cess to it",
        "motivation": "It's important for some classes to have exactly one instance. Making a class responsible for keepintrack of its sole instance.",
        "applicability": "there must be exactly one instance of a class, and it must be accessible.\\nwhen the sole instance should be extensible by subclassing, and clients",
        "structure": "Cambiar por BLOB",
        "_id": "50f6f74fe4f707ca70000001"
    }
  • ERRORS 404 The pattern specified by the name parameter does'nt exist in the database

###/patterns/:name (PUT)###

  • DESCRIPTION Updates the pattern specified by the name parameter

  • URL STRUCTURE ...[api_url]/patterns/:name

  • METHOD PUT

  • PARAMETERS name: Used to specify the name of the pattern to be updated

  • REQUEST BODY required A JSON object containing the new information about the pattern to be updated

  • RETURNS A JSON object with the new information about the updated parameter specified by the :name attribute.

    Sample JSON return value

    {
        "name": "Singleton",
        "category": "Creational",
        "intent": "Ensure a class only has one instance, and provide a global point of acg cess to it",
        "motivation": "It's important for some classes to have exactly one instance. Making a class responsible for keepintrack of its sole instance.",
        "applicability": "there must be exactly one instance of a class, and it must be accessible.\\nwhen the sole instance should be extensible by subclassing, and clients",
        "structure": "Cambiar por BLOB",
        "_id": "50f6f74fe4f707ca70000001"
    }
  • ERRORS 404 The pattern specified by the name parameter does'nt exist in the database

###/patterns/:name (DEL)###

  • DESCRIPTION Deletes the pattern specified by the name parameter
  • URL STRUCTURE ...[api_url]/patterns/:name
  • METHOD DEL
  • PARAMETERS name: Used to specify the name of the pattern to be deleted
  • ERRORS 500 There was an error deleting the specified pattern.

###Pagination /patterns?limit=:limit&offset=:offset####

  • DESCRIPTION Used when you want a specific number of objects returned.
  • URL STRUCTURE `...[api_url]/patterns?limit=:limit&offset=:offset
  • METHOD GET
  • PARAMETERS offset: Offsets the start of each page by the number specified. Default value is 0. limit: The number of individual objects that are returned in each page. Default value is 10.
  • ERRORS 400 Bad request