eslint fixes

Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
Fred Boniface 2023-06-07 11:45:48 +01:00
parent c4b3be9086
commit d879d544fe
4 changed files with 24 additions and 19 deletions

View File

@ -26,6 +26,12 @@ module.exports = {
'semi': [ 'semi': [
'error', 'error',
'always' 'always'
],
'max-len': [
'warn',
{
'code': 80
}
] ]
} }
}; };

26
app.js
View File

@ -19,17 +19,16 @@ const rateLimit = require('express-rate-limit');
const authenticate= require('./src/middlewares/auth.middlewares'); const authenticate= require('./src/middlewares/auth.middlewares');
// Internal Requires // Internal Requires
const log = require('./src/utils/log.utils'); // Log Helper const log = require('./src/utils/log.utils');
const version = require('./src/configs/version.configs'); // Version Strings const version = require('./src/configs/version.configs');
const listRtr = require('./src/routes/list.routes'); // /list endpoints const listRtr = require('./src/routes/list.routes');
const ldbRtr = require('./src/routes/ldb.routes'); // /ldb endpoints const ldbRtr = require('./src/routes/ldb.routes');
const kubeRtr = require('./src/routes/kube.routes'); // /kube endpoints const kubeRtr = require('./src/routes/kube.routes');
const findRtr = require('./src/routes/find.routes'); // /find endpoints const findRtr = require('./src/routes/find.routes');
const issueRtr = require('./src/routes/issue.routes'); // /issue endpoints const issueRtr = require('./src/routes/issue.routes');
const statRtr = require('./src/routes/stats.routes'); // /stat endpoints const statRtr = require('./src/routes/stats.routes');
const regRtr = require('./src/routes/registration.routes'); // /registration endpoints const regRtr = require('./src/routes/registration.routes');
const pisRtr = require('./src/routes/pis.routes'); // /pis endpoints const pisRtr = require('./src/routes/pis.routes');
const trainRtr = require('./src/routes/train.routes'); // /train routes
// Set Server Configurations // Set Server Configurations
const srvListen = process.env.OWL_SRV_LISTEN || '0.0.0.0'; const srvListen = process.env.OWL_SRV_LISTEN || '0.0.0.0';
@ -44,7 +43,8 @@ const limiter = rateLimit({
// Print version number: // Print version number:
log.out(`app: Starting OwlBoard in ${mode} mode`, 'init'); log.out(`app: Starting OwlBoard in ${mode} mode`, 'init');
log.out(`app: Starting OwlBoard - Backend Version: ${version.app} - API versions: ${version.api}`, 'init'); log.out(`app: Starting OwlBoard - Backend Version: ${version.app} - ` +
`API versions: ${version.api}`, 'init');
// Test for required vars: // Test for required vars:
// const varTest = require('./src/utils/varTest.utils'); // const varTest = require('./src/utils/varTest.utils');
@ -78,7 +78,7 @@ app.use('/api/v1/stats', statRtr);
app.use('/api/v1/register', regRtr); app.use('/api/v1/register', regRtr);
// Authented Routes // Authented Routes
app.use('/api/v1/ldbs', authenticate, (req, res) => res.status(501).json({status: 'Not Implemented', message: 'This feature is not yet implemented due to upstream issues'})); app.use('/api/v1/ldbs', authenticate, (req, res) => res.status(501).json({status: 'not implemented'}));
app.use('/api/v1/pis', authenticate, pisRtr); app.use('/api/v1/pis', authenticate, pisRtr);
app.use('/api/v1/auth/test', authenticate, (req, res) => res.status(200).json({status: 'ok', message: 'Authentication successful'})); // Returns 401 if auth failed, 200 if successful. app.use('/api/v1/auth/test', authenticate, (req, res) => res.status(200).json({status: 'ok', message: 'Authentication successful'})); // Returns 401 if auth failed, 200 if successful.
app.use('/api/v1/train', /*authenticate,*/ trainRtr); // Disable authentication during testing app.use('/api/v1/train', /*authenticate,*/ trainRtr); // Disable authentication during testing

View File

@ -80,13 +80,14 @@ async function colCount(collection) {
await client.connect(); await client.connect();
let col = db.collection(collection); let col = db.collection(collection);
let count = col.countDocuments(); let count = col.countDocuments();
log.out(`dbAccess.colCount: Collection: ${collection} contains ${count} documents`); log.out(`dbAccess.colCount: Collection: ${collection} contains ${count}` +
' documents');
return await count; return await count;
} }
module.exports = { module.exports = {
query, query,
increment, // Probqbly doesn't need exporting? - It does, ldbServices needs to increment when the API is hit! increment,
addUser, addUser,
userAtime, userAtime,
addRegReq, addRegReq,

View File

@ -5,7 +5,8 @@ const log = require('../utils/log.utils');
const clean = require('../utils/sanitizer.utils'); const clean = require('../utils/sanitizer.utils');
async function findPisByOrigDest(start,end) { async function findPisByOrigDest(start,end) {
log.out(`pisServices.findPisByOrigDest: Searching for PIS for Orig: ${start}, Dest: ${end}`, 'dbug'); log.out('pisServices.findPisByOrigDest: Searching for PIS for Orig: ' +
`${start}, Dest: ${end}`, 'dbug');
const firstCrs = clean.cleanApiEndpointTxt(start.toLowerCase()); const firstCrs = clean.cleanApiEndpointTxt(start.toLowerCase());
const lastCrs = clean.cleanApiEndpointTxt(end.toLowerCase()); const lastCrs = clean.cleanApiEndpointTxt(end.toLowerCase());
const query = { const query = {
@ -22,7 +23,6 @@ async function findPisByOrigDest(start,end) {
] ]
} }
}; };
//const oldQuery = {$and:[{$expr:{$eq:[{$first:"$stops"},firstCrs]}},{$expr:{$eq:[{$last:"$stops"},lastCrs]}}]}
const search = db.query('pis', query); const search = db.query('pis', query);
return await search; return await search;
} }
@ -45,8 +45,6 @@ async function findByTiplocArray(tiplocArray) {
return await res; return await res;
} }
// Hopefully at some point, I will also be able to implement a find PIS code by headcode option.
module.exports = { module.exports = {
findPisByOrigDest, findPisByOrigDest,
findPisByCode, findPisByCode,