Git Product home page Git Product logo

resourceserver's Introduction

Resourceserver

TODO:

  1. Add validation

  2. Add pre/post hooks

Implements an in-memory (or persistent via redis) resource oriented HTTP server, provding 5 basic operations (shown in curl_tests.sh). Edit redis connection config in config.coffee.

POST /:collection

Create a new resource.

curl -vX POST http://localhost:3002/people \
  -H 'content-type: application/json' -d '{"name": "Liam", "age": 29}'
{
  "name": "Liam",
  "age": 29,
  "id": 2
}
curl -vX POST http://localhost:3002/people \
  -H 'content-type: application/json' -d '{"name": "Noah", "age": 1}'
{
  "name": "Noah",
  "age": 1,
  "id": 2
}

GET /:collection/:id

Retrieve the :collection resource with id :id.

curl -v http://localhost:3002/people/1
{
  "name": "Liam",
  "age": 29,
  "id": 1
}

GET /:collection

Retrieve an array of all :collection resources.

curl -v http://localhost:3002/people
[
  {
    "name": "Liam",
    "age": 29,
    "id": 1
  },
  {
    "name": "Noah",
    "age": 1,
    "id": 2
  }
]

PUT /:collection/:id

Override the :collection resource with id :id.

curl -vX PUT http://localhost:3002/people/1 \
  -H 'content-type: application/json' -d '{"name": "LiamO", "age": 30}'
{
  "name": "LiamO",
  "age": 30,
  "id": "1"
}

DELETE /:collection/:id

Delete the :collection resource with id :id.

curl -vX DELETE http://localhost:3002/people/1

It uses the CORS headers to allow cross-origin requests.

Usage

  1. Clone the repository

  2. Install node.js

  3. Install the dependencies with npm install

  4. Start the server with npm start

  5. [Optional] Run tests with cd test && ./curl_tests.sh

resourceserver's People

Contributors

adamchester avatar alexbeletsky avatar liammclennan avatar tbranyen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

resourceserver's Issues

I'm interested to see what you do here

I've been exploring tighter backbone integration with node. At the moment i'm rendering the same templates server and client side. And i've thinking about how I can better unify the routes, instead of having to declare them twice (once serverside and once client side).

Another possibility i've been thinking about is pushing templates down the wire when they change.

OPTIONS method failed to respond.

image

image

image

When I create an object, XHR's default behavior issue an OPTIONS method first, then issue POST metHod, the first one failed, however, chrome ignore that, and continue issue PUT method call. But firefox will fail all together if the first one fail. I think you should change to respond to OPTIONS query.

CoffeeScript compilation

As indicated in my PR, I don't know node.js scarcely at all. When starting up my resourceserver, I had to first manually compile the config.coffee and logger.coffee files to js by installing coffee-script as a global package in node, and then compiling each file individually. Should that be part of the startup script, or did I just miss a step in setting up node somewhere?

(PS, thanks for your PluralSight video Liam, it helped me present on Backbone in a lunch&learn today. :) )

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.