implement /pis endpoint
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
5da7a951e3
commit
121528c413
2
app.js
2
app.js
@ -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)
|
||||
|
17
src/controllers/pis.controllers.js
Normal file
17
src/controllers/pis.controllers.js
Normal 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
7
src/routes/pis.routes.js
Normal 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;
|
Loading…
Reference in New Issue
Block a user