Add /api/v2/user/...
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
a4d82b0aa7
commit
eb80d7386e
2
app.js
2
app.js
@ -34,6 +34,7 @@ const pis2Rtr = require('./src/routes/pis2.routes'); // API Version 2 Routes
|
|||||||
const ref2Rtr = require('./src/routes/ref2.routes'); // API Version 2 Routes
|
const ref2Rtr = require('./src/routes/ref2.routes'); // API Version 2 Routes
|
||||||
const live2Rtr = require('./src/routes/live2.routes'); // API Version 2 Routes
|
const live2Rtr = require('./src/routes/live2.routes'); // API Version 2 Routes
|
||||||
const tt2Rtr = require('./src/routes/timetable2.routes'); // API Version 2
|
const tt2Rtr = require('./src/routes/timetable2.routes'); // API Version 2
|
||||||
|
const user2Rtr = require('./src/routes/user2.routes'); // API Version 2 Routes
|
||||||
const miscRtr = require('./src/routes/misc.routes'); // Non-Public API Routes
|
const miscRtr = require('./src/routes/misc.routes'); // Non-Public API Routes
|
||||||
|
|
||||||
// Set Server Configurations
|
// Set Server Configurations
|
||||||
@ -71,6 +72,7 @@ app.use('/api/v2/pis', authenticate, pis2Rtr); // API Version 2
|
|||||||
app.use('/api/v2/live', live2Rtr); // API Version 2
|
app.use('/api/v2/live', live2Rtr); // API Version 2
|
||||||
app.use('/api/v2/ref', ref2Rtr); // API Version 2
|
app.use('/api/v2/ref', ref2Rtr); // API Version 2
|
||||||
app.use('/api/v2/timetable', tt2Rtr); // API Version 2
|
app.use('/api/v2/timetable', tt2Rtr); // API Version 2
|
||||||
|
app.use('/api/v2/user', user2Rtr); // API Version 2
|
||||||
app.use('/misc', miscRtr); // Non public-api endpoints (Stats, Issue, etc.)
|
app.use('/misc', miscRtr); // Non public-api endpoints (Stats, Issue, etc.)
|
||||||
|
|
||||||
// Unauthenticated Routes
|
// Unauthenticated Routes
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const version = {
|
const version = {
|
||||||
api: ['/api/v1/','/api/v2'],
|
api: ['/api/v1/','/api/v2'],
|
||||||
app: '2023.6.10'
|
app: '2023.6.11'
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = version;
|
module.exports = version;
|
@ -20,7 +20,18 @@ async function request(req, res, next) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getUser(req, res, next) {
|
||||||
|
try {
|
||||||
|
let uuid = req.params.uuid;
|
||||||
|
res.json(await reg.getUser(uuid));
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
next(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
register,
|
register,
|
||||||
request
|
request,
|
||||||
|
getUser
|
||||||
};
|
};
|
10
src/routes/user2.routes.js
Normal file
10
src/routes/user2.routes.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const router = express.Router();
|
||||||
|
const regCtr = require('../controllers/registration.controllers');
|
||||||
|
|
||||||
|
// User
|
||||||
|
router.get('/:uuid', regCtr.getUser);
|
||||||
|
router.post('/request', regCtr.request);
|
||||||
|
router.post('/register', regCtr.register);
|
||||||
|
|
||||||
|
module.exports = router;
|
@ -45,7 +45,17 @@ async function regUser(req) { // Add input validation
|
|||||||
return {status: 401, errorCode: 703, errorMsg: errors[703]};
|
return {status: 401, errorCode: 703, errorMsg: errors[703]};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function getUser(uuid) {
|
||||||
|
log.out('registrationServices: Finding user for given UUID', 'dbug');
|
||||||
|
const filter = {
|
||||||
|
uuid: uuid
|
||||||
|
};
|
||||||
|
const res = await db.query('users', filter, false);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
regUser,
|
regUser,
|
||||||
createRegKey
|
createRegKey,
|
||||||
|
getUser
|
||||||
};
|
};
|
Loading…
Reference in New Issue
Block a user