1.0.12 • Published 1 year ago

single-endpoint v1.0.12

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

single-endpoint

The 'single-endpoint' package helps you to call any GET API without creating multiple endpoints in your app for each API call. It provides a single endpoint for all GET API calls.

Installation

how to use it

 const singleEndpoint=require('single-endpoint')//import singleEndpoint from the single-endpoint

const galleryModel = require("./models/gallery");//import schema that you want to acess
const painterModel = require("./models/painter");

 reference object represent :-
  key :- use any kay as you want for acess that modal
  value :- value must be a modal
  
const reference = {
  gallery: galleryModel,
  painter: painterModel,
'name as you want to acess':'modal name of the schema'

};
 pass a singleEndpoint function as callback and pass req,res and reference
app.use("/singleApi",(req,res)=> singleEndpoint(req,res,reference));

for fetching particular data like this

for acessing the referenceData you can pass {associated_data_singleApi:1}

  gallery: {
       theme:{
           associated_data_singleApi:1,
       }
       
      }

it give the all object data

{
    "gallery": {
        "_id": {"$eq":"6419282fdc54d0198f89858d" }
        
    }
}

it give the only name and id object data

{
    "gallery": {
        "_id": {"$eq":"6419282fdc54d0198f89858d" },
        "name":{}
        
    }
}

fetching multiple modal data at once

{
    "gallery": {
        "_id": {"$eq":"6419282fdc54d0198f89858d" },
        "name":{}
        
    },
     "painter": {
        "_id": {"$eq":"6419282fdc54d0198f89858d" },
        "name":{}
        
    }
}

"That's great! Congratulations! Now, you are able to access the singleEndpoint."

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago