Code Monkey home page Code Monkey logo

express-restful-api's People

Contributors

sideroad avatar toantd90 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

toantd90

express-restful-api's Issues

JSON schema

When HTTP request have x-json-schema, return JSON schema

Geo location search

Add latlng to attribute type. format is latitude,longitude.

Be able to fetch collection filtered by latitude,longitude,radius(m).
Here is a example to search Kyoto around 1km.
location=35.5783703,136.6170494,1000

POST instance to children

if seeds does not have parent as fruits and fruits have seeds as children.
It should be able to POST seeds as children such as below.

POST /fruits/grape/seeds/a
Push specified ID of seed into grape children

DELETE /fruits/grape/seeds
delete grape children

DELETE /fruits/grape/seeds/a
delete specified id from grape children

groupBy feature

Add groupBy request parameter in collection fetch.
If there is number attribution type, calculate sum and response the amount as field.
Add size in grouped item.

Here is a example fetched collection without groupBy

{
  "items": [
    {
      "id": "29d3d12",
      "name": "sideroad",
      "amount": "1000"
    },
    {
      "id": "029234a",
      "name": "sideroad",
      "amount": "500"
    },
    {
      "id": "8eb23da",
      "name": "foobar",
      "amount": "100"
    }
  ]
}

Here is a example fetched collection with groupBy=name

{
  "items": [
    {
      "name": "sideroad",
      "amount": 1500,
      "size": 2
    },
    {
      "name": "foobar",
      "amount": 100,
      "size": 1
    }
  ]
}

PATCH as not idempotent

Use PATCH method for NOT idempotent update.

URL
PATCH /apis/fruits/apple

Request Body
{ amount: 10 }

Validation API

options

{
  "person": {
    "name": {
      "regexp": "^[a-zA-Z 0-9]+$",
      "invalid": "Only alphabets number spaces allowed"
    },
    "age": {
      "regexp": "^[0-9]+$",
      "invalid": "Only number allowed"
    }
  }
}

/validation/groups?name=invalid_value&age=unknown

  • HTTP Method ( GET )
  • Status Code ( 400 or 200 )

Valid

No Response

Invalid

{
  "name": "Only alphabets number spaces allowed",
  "age": "Only number allowed"
}

PUT as create or update

/person/sideroad

client should be specify id to create or update instance.

PUT should be act as idempotent.

PUT for update should be replace all attribution for the data.

Singleton API

separate configuration singleton and collections

singleton only has READ and UPDATE.
singleton does not have CREATE and DELETE.

singleton be able to have a attribute of children, instance
singleton can not have a attribute of parent

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.