-
Notifications
You must be signed in to change notification settings - Fork 0
API v2
Magnus L. Holtet edited this page May 4, 2022
·
5 revisions
Documentation for creating, understanding and maintaining API.
All endpoints are defined in the folder routers
. There exists a router for each module of the API, i.e a router for employee-related endpoints, another one for competence-endpoints and so on.
To define an endpoint, you either add to an already existing router, or you create a new router and make sure to import it in the routers/routers.ts
file. This file bundles all the routers and passes it to the Express server.
router.get('/yourEndpoint', async (req, res, next) => {
try {
// Get data from Dataplattform using reports
const data = await getReport<TypeOfYourDataFromReport>({
accessToken: req.accessToken,
reportName: 'yourReportName',
})
// Aggregation of data
const aggregatedData = yourPotentialAggregationOfTheData(data)
// Send response
res.send(aggregatedData)
} catch (error) {
// Pass potential error to handler
next(error)
}
})