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

Watchers

 avatar  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.