From d879d544fe0fee2bfb70fd385170317ef4859322 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Wed, 7 Jun 2023 11:45:48 +0100 Subject: [PATCH] eslint fixes Signed-off-by: Fred Boniface --- .eslintrc.js | 6 ++++++ app.js | 26 +++++++++++++------------- src/services/dbAccess.services.js | 5 +++-- src/services/pis.services.js | 6 ++---- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index cf336a8..e78c61e 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -26,6 +26,12 @@ module.exports = { 'semi': [ 'error', 'always' + ], + 'max-len': [ + 'warn', + { + 'code': 80 + } ] } }; diff --git a/app.js b/app.js index 52fe845..d49eb46 100644 --- a/app.js +++ b/app.js @@ -19,17 +19,16 @@ const rateLimit = require('express-rate-limit'); const authenticate= require('./src/middlewares/auth.middlewares'); // Internal Requires -const log = require('./src/utils/log.utils'); // Log Helper -const version = require('./src/configs/version.configs'); // Version Strings -const listRtr = require('./src/routes/list.routes'); // /list endpoints -const ldbRtr = require('./src/routes/ldb.routes'); // /ldb endpoints -const kubeRtr = require('./src/routes/kube.routes'); // /kube endpoints -const findRtr = require('./src/routes/find.routes'); // /find endpoints -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 -const trainRtr = require('./src/routes/train.routes'); // /train routes +const log = require('./src/utils/log.utils'); +const version = require('./src/configs/version.configs'); +const listRtr = require('./src/routes/list.routes'); +const ldbRtr = require('./src/routes/ldb.routes'); +const kubeRtr = require('./src/routes/kube.routes'); +const findRtr = require('./src/routes/find.routes'); +const issueRtr = require('./src/routes/issue.routes'); +const statRtr = require('./src/routes/stats.routes'); +const regRtr = require('./src/routes/registration.routes'); +const pisRtr = require('./src/routes/pis.routes'); // Set Server Configurations const srvListen = process.env.OWL_SRV_LISTEN || '0.0.0.0'; @@ -44,7 +43,8 @@ const limiter = rateLimit({ // Print version number: 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: // const varTest = require('./src/utils/varTest.utils'); @@ -78,7 +78,7 @@ app.use('/api/v1/stats', statRtr); app.use('/api/v1/register', regRtr); // 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/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 diff --git a/src/services/dbAccess.services.js b/src/services/dbAccess.services.js index af9e060..fa2710a 100644 --- a/src/services/dbAccess.services.js +++ b/src/services/dbAccess.services.js @@ -80,13 +80,14 @@ async function colCount(collection) { await client.connect(); let col = db.collection(collection); 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; } module.exports = { query, - increment, // Probqbly doesn't need exporting? - It does, ldbServices needs to increment when the API is hit! + increment, addUser, userAtime, addRegReq, diff --git a/src/services/pis.services.js b/src/services/pis.services.js index 7b315a9..642cdd9 100644 --- a/src/services/pis.services.js +++ b/src/services/pis.services.js @@ -5,7 +5,8 @@ const log = require('../utils/log.utils'); const clean = require('../utils/sanitizer.utils'); 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 lastCrs = clean.cleanApiEndpointTxt(end.toLowerCase()); 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); return await search; } @@ -45,8 +45,6 @@ async function findByTiplocArray(tiplocArray) { return await res; } -// Hopefully at some point, I will also be able to implement a find PIS code by headcode option. - module.exports = { findPisByOrigDest, findPisByCode,