Skip to content

LeonardoRamos/node-generic-rest-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NodeGenericRestApi

API Rest developed using NodeJs. Its purpose is to serve as a lib to make it easier to provide and serve data from any API that uses it as a framework.

Setting up

To test the project locally, simply clone the repository and import into any IDE you may prefer. After that, you will need to run npm install, after that, run npm install --global yarn and then run yarn start.

API

The API accepts filters, sorting, aggregation functions, grouping and field projection. For authentications, it uses JWT.

Filter

The available options of filters to be applied:

  • Equals: "=eq=" or "=" (may be used to compare if value is equal to null)

  • Less than or equal: "=le=" or "<="

  • Greater than or equal: "=ge=" or ">="

  • Greater than: "=gt=" or ">"

  • Less than: "=lt=" or "<"

  • Not equal: "=ne=" or "!=" (may be used to compare if the value is other than null)

  • In: "=in="

  • Out: "=out="

  • Like: "=like="

Logical operators in the url:

  • AND: "_and_" or just ";"
  • OR: "_or_" or just ","

filter = [field1=value,field2=like=value2;field3!=value3...]

Projection

The Projection follows the following syntax, and the json response will only have with the specified fields:

projection = [field1, field2, field3...]

Sort

The Sorting follows the following syntax (where sortOrder may be asc or desc):

sort = [field1 = sortOrder, field2 = sortOrder...]

GroupBy

GroupBy follows the following syntax (groupBy does not accept projections parameters and is expected to be used along with an aggregation function):

groupBy = [field1, field2, field3...]

Sum

It performs Sum function in the specified fields, and follows the following syntax:

sum = [field1, field2, field3...]

Avg

It performs function of Avg in the specified fields, and follows the following syntax:

avg = [field1, field2, field3...]

Count

It performs Count function in the specified fields, and follows the following syntax:

count = [field1, field2, field3...]

Count Distinct

It performs Count Distinct function in the specified fields, and follows the following syntax:

countDistinct = [field1, field2, field3...]

Extra Parameters

  • offset (DEFAULT_OFFSET = 0)
  • limit (DEFAULT_LIMIT = 20 and MAX_LIMIT = 100)

About

Generic Rest API using NodeJs Language

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published