implement /pis endpoint

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-04-21 21:28:13 +01:00
parent 5da7a951e3
commit 121528c413
3 changed files with 26 additions and 0 deletions

2
app.js
View File

@ -26,6 +26,7 @@ const findRtr = require('./src/routes/find.routes'); // /find endpoint
const issueRtr = require('./src/routes/issue.routes'); // /issue endpoints
const statRtr = require('./src/routes/stats.routes'); // /stat endpoints
const regRtr = require('./src/routes/registration.routes'); // /registration endpoints
const pisRtr = require('./src/routes/pis.routes'); // /pis endpoints
// Set Server Configurations
const srvListen = process.env.OWL_SRV_LISTEN || "0.0.0.0"
@ -72,6 +73,7 @@ app.use('/api/v1/find', findRtr);
app.use('/api/v1/issue', issueRtr);
app.use('/api/v1/stats', statRtr);
app.use('/api/v1/register', regRtr);
app.use('/api/v1/pis', pisRtr)
// Authented Routes
app.use('/api/v1/ldbs', authenticate)

View File

@ -0,0 +1,17 @@
const pis = require('../services/pis.services');
async function byOrigDest(req, res, next){
try {
let start = req.params.start
let end = req.params.end
res.json(await pis.findPisByOrigDest(start,end))
} catch (err) {
console.error(`Unknown Error`, err.message);
next(err);
}
}
module.exports = {
byOrigDest
}

7
src/routes/pis.routes.js Normal file
View File

@ -0,0 +1,7 @@
const express = require('express');
const router = express.Router();
const pisController = require('../controllers/pis.controllers');
router.get('/origdest/:start/:end', pisController.byOrigDest);
module.exports = router;