Code Monkey home page Code Monkey logo

boilerplate-restify-for-rest-api's Introduction

boilerplate-restify-for-rest-api Build Status Dependency Status License: MIT

Boilerplate of Restify for REST API

Required

  • Docker installed

Let's begin developing

git clone https://github.com/keidrun/boilerplate-restify-for-rest-api.git
cd boilerplate-restify-for-rest-api
docker-compose up

Develop with testing

docker-compose up -d
docker exec -it my_app yarn test-watch

API endpoints

Method URI Data
POST /users name,age,gender,email
GET /users -
GET /users/:id -
PUT /users/:id name,age,gender,email
DELETE /users/:id -

Manual Tests

$ curl -v -H "Accept:application/json" -H "Content-Type:application/json" -X POST -d '{"name":"Keid","age":30,"gender":"male","email":"[email protected]"}' http://localhost:3000/users | jq
...
< HTTP/1.1 200 OK
...
{
  "status": "success",
  "data": {
    "_id": "5bb30edcd1b036e33f6a2e57",
    "name": "Keid",
    "age": 30,
    "gender": "male",
    "email": "[email protected]",
    "__v": 0
  }
}
$ curl -v -H "Accept:application/json" -H "Content-Type:application/json" -X POST -d '{"name":"Tom","age":24,"gender":"male","email":"[email protected]"}' http://localhost:3000/users | jq
...
< HTTP/1.1 200 OK
...
{
  "status": "success",
  "data": {
    "_id": "5bb30f70d1b036e33f6a2e58",
    "name": "Tom",
    "age": 24,
    "gender": "male",
    "email": "[email protected]",
    "__v": 0
  }
}
$ curl -v -H "Accept:application/json" -H "Content-Type:application/json" -X POST -d '{"name":"Mary","age":32,"gender":"female","email":"[email protected]"}' http://localhost:3000/users | jq
...
< HTTP/1.1 200 OK
...
{
  "status": "success",
  "data": {
    "_id": "5bb30f84d1b036e33f6a2e59",
    "name": "Mary",
    "age": 32,
    "gender": "female",
    "email": "[email protected]",
    "__v": 0
  }
}
$ curl -v -H "Accept:application/json" http://localhost:3000/users | jq
...
< HTTP/1.1 200 OK
...
{
  "status": "success",
  "data": [
    {
      "_id": "5bb30edcd1b036e33f6a2e57",
      "name": "Keid",
      "age": 30,
      "gender": "male",
      "email": "[email protected]",
      "__v": 0
    },
    {
      "_id": "5bb30f70d1b036e33f6a2e58",
      "name": "Tom",
      "age": 24,
      "gender": "male",
      "email": "[email protected]",
      "__v": 0
    },
    {
      "_id": "5bb30f84d1b036e33f6a2e59",
      "name": "Mary",
      "age": 32,
      "gender": "female",
      "email": "[email protected]",
      "__v": 0
    }
  ]
}
$ curl -v -H "Accept:application/json" http://localhost:3000/users/5bb30f70d1b036e33f6a2e58 | jq
...
< HTTP/1.1 200 OK
...
{
  "status": "success",
  "data": {
    "_id": "5bb30f70d1b036e33f6a2e58",
    "name": "Tom",
    "age": 24,
    "gender": "male",
    "email": "[email protected]",
    "__v": 0
  }
}
$ curl -v -H "Accept:application/json" -H "Content-Type:application/json" -X PUT -d '{"name":"Amily","age":21,"gender":"female","email":"[email protected]"}' http://localhost:3000/users/5bb30f70d1b036e33f6a2e58 | jq
...
< HTTP/1.1 200 OK
...
{
  "status": "success",
  "data": {
    "_id": "5bb30f70d1b036e33f6a2e58",
    "name": "Amily",
    "age": 21,
    "gender": "female",
    "email": "[email protected]",
    "__v": 0
  }
}
$ curl -v -H "Accept:application/json" -X DELETE http://localhost:3000/users/5bb30f84d1b036e33f6a2e59 | jq
...
< HTTP/1.1 200 OK
...
{
  "status": "success",
  "data": {
    "_id": "5bb30f84d1b036e33f6a2e59",
    "name": "Mary",
    "age": 32,
    "gender": "female",
    "email": "[email protected]",
    "__v": 0
  }
}
$ curl -v -H "Accept:application/json" http://localhost:3000/users | jq
...
< HTTP/1.1 200 OK
...
{
  "status": "success",
  "data": [
    {
      "_id": "5bb30edcd1b036e33f6a2e57",
      "name": "Keid",
      "age": 30,
      "gender": "male",
      "email": "[email protected]",
      "__v": 0
    },
    {
      "_id": "5bb30f70d1b036e33f6a2e58",
      "name": "Amily",
      "age": 21,
      "gender": "female",
      "email": "[email protected]",
      "__v": 0
    }
  ]
}

boilerplate-restify-for-rest-api's People

Contributors

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