Add eslint rule: max line length (80)
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable no-useless-escape */
|
||||
/* global process */
|
||||
const axios = require('axios');
|
||||
const log = require('../utils/log.utils');
|
||||
|
||||
@@ -20,12 +19,13 @@ async function sendToGitea(body) {
|
||||
}
|
||||
};
|
||||
var res = await axios.post(url, body, opts);
|
||||
// Need to read the output from the POST and pass the result upwards to the client.
|
||||
/* Need to read the output from the POST and pass the result upwards to the
|
||||
client.*/
|
||||
if (res.status == 201) {
|
||||
log.out('issueService.sendToGitea: Issue sent to Gitea', 'info');
|
||||
return {status: res.status,message:'issue created'};
|
||||
} else {
|
||||
log.out(`issueService.sendToGitea: Failed to send issue to Gitea: ${res.body}`, 'err');
|
||||
log.out(`issueService.sendToGitea: Fail to send issue: ${res.body}`, 'err');
|
||||
return {status: res.status,message:'issue not created'};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* global process */
|
||||
// Parse and return an LDB Request
|
||||
|
||||
const log = require('../utils/log.utils'); // Log Helper
|
||||
@@ -27,12 +26,14 @@ async function get(id, staff=false){
|
||||
}
|
||||
} catch (err) {
|
||||
log.out(`ldbService.get: Error, Unable to find CRS: ${err}`, 'info');
|
||||
return {ERROR:'NOT_FOUND',description:'The entered station was not found. Please check and try again.'};
|
||||
return {
|
||||
ERROR:'NOT_FOUND',
|
||||
description:'The entered station was not found.'};
|
||||
}
|
||||
}
|
||||
|
||||
async function arrDepBoard(CRS){
|
||||
log.out(`ldbService.arrDepBoard: Trying to fetch ArrDep Board for ${CRS}`, 'info');
|
||||
log.out(`ldbService.arrDepBoard: Trying to fetch board for ${CRS}`, 'info');
|
||||
try {
|
||||
const options = {
|
||||
numRows: 10,
|
||||
@@ -42,12 +43,15 @@ async function arrDepBoard(CRS){
|
||||
return await api.call('GetArrDepBoardWithDetails', options, false, false);
|
||||
} catch (err) {
|
||||
log.out(`ldbService.arrDepBoard: Lookup Failed for: ${CRS}`, 'warn');
|
||||
return {GetStationBoardResult: 'not available', Reason: `The CRS code ${CRS} is not valid`, Why: 'Sometimes a station will have more than one CRS - for example Filton Abbey Wood has FIT and FAW however schedules are only available when looking up with FIT - this is how the National Rail Enquiries systems work.'};
|
||||
return {
|
||||
GetStationBoardResult: 'not available',
|
||||
Reason: `The CRS code ${CRS} is not valid`
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
async function arrDepBoardStaff(CRS) {
|
||||
log.out(`ldbService.arrDepBoardStaff: Trying to fetch ArrDep Board for ${CRS}`, 'dbug');
|
||||
log.out(`ldbService.arrDepBoardStaff: Try to fetch board for ${CRS}`, 'dbug');
|
||||
try {
|
||||
const options = {
|
||||
numRows: 25,
|
||||
@@ -58,7 +62,10 @@ async function arrDepBoardStaff(CRS) {
|
||||
return await api.call('GetArrDepBoardWithDetails', options, false, false);
|
||||
} catch (err) {
|
||||
log.out(`ldbService.arrDepBoardStaff: Lookup Failed for: ${CRS}, "warn`);
|
||||
return {GetStationBoardResult: 'not available', Reason: `The CRS code ${CRS} is not valid`, Why: 'Sometimes a station will have more than one CRS - for example Filton Abbey Wood has FIT and FAW however schedules are only available when looking up with FIT - this is how the National Rail Enquiries systems work.'};
|
||||
return {
|
||||
GetStationBoardResult: 'not available',
|
||||
Reason: `The CRS code ${CRS} is not valid`
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* global process */
|
||||
const log = require('../utils/log.utils');
|
||||
const mail = require('nodemailer'); //>> Probs wrong
|
||||
|
||||
@@ -18,7 +17,9 @@ let transporter = mail.createTransport({
|
||||
}
|
||||
});
|
||||
|
||||
async function send(message){ // message is an object containing strings for: *to, cc, bcc, *subject, *txt, html (* denotes required)
|
||||
/* 'message' is an object containing string values for:
|
||||
*to, cc, bcc, *subject, *txt, html. * denotes required */
|
||||
async function send(message) {
|
||||
log.out('mailServices.send: Message send request received', 'info');
|
||||
message.from = fromAddr;
|
||||
try {
|
||||
|
||||
@@ -8,8 +8,8 @@ const errors = require('../configs/errorCodes.configs');
|
||||
|
||||
async function createRegKey(body) {
|
||||
log.out('registerServices.createRegKey: Incoming request', 'INFO');
|
||||
const domain = await clean.getDomainFromEmail(body.email); // The function should validate the email
|
||||
log.out(`registerServices: New registration request from domain: ${domain}`, 'info');
|
||||
const domain = await clean.getDomainFromEmail(body.email);
|
||||
log.out(`registerServices: Registration request from: ${domain}`, 'info');
|
||||
if (domains.includes(domain)) {
|
||||
log.out(`registerServices.createRegKey: Key from valid domain: ${domain}`);
|
||||
const uuid = await auth.generateKey();
|
||||
@@ -17,7 +17,7 @@ async function createRegKey(body) {
|
||||
const message = await auth.generateConfirmationEmail(body.email, uuid);
|
||||
if (!message) {
|
||||
const err = new Error('Message generation error');
|
||||
log.out('registerServices.createRegKey: Error generating registration email', 'err');
|
||||
log.out('registerServices.createRegKey: Error generating email', 'err');
|
||||
log.out(err, 'err');
|
||||
return 500;
|
||||
}
|
||||
@@ -31,9 +31,9 @@ async function createRegKey(body) {
|
||||
|
||||
async function regUser(req) { // Add input validation
|
||||
log.out(`Read UUID: ${req.uuid}`, 'dbug');
|
||||
log.out(`registrationServices.regUser: Checking validity of : ${req.uuid}`, 'info');
|
||||
log.out(`registrationServices.regUser: Request from: ${req.uuid}`, 'info');
|
||||
const res = await auth.checkRequest(req.uuid);
|
||||
log.out(`registrationServices.regUser: checkRequest returned: ${JSON.stringify(res)}`, 'info');
|
||||
log.out(`registrationServices.regUser: ${JSON.stringify(res)}`, 'info');
|
||||
if (res.result) {
|
||||
const uuid = await auth.generateKey();
|
||||
const apiKey = await db.addUser(uuid, res.domain);
|
||||
|
||||
@@ -5,7 +5,8 @@ const pis = require('../services/pis.services');
|
||||
|
||||
async function findByHeadcodeToday(headcode) {
|
||||
const sanitizedHeadcode = clean.removeNonAlphanumeric(headcode).toUpperCase();
|
||||
log.out(`trainServiceServices.findByHeadcode: Searching for headcode ${sanitizedHeadcode}`, 'dbug');
|
||||
log.out('trainServiceServices.findByHeadcode: Searching for headcode ' +
|
||||
sanitizedHeadcode, 'dbug');
|
||||
const now = new Date();
|
||||
const dayMap = ['su', 'm', 't', 'w', 'th', 'f', 's'];
|
||||
const shortDay = dayMap[now.getDay()]; // Fetch short day from map
|
||||
@@ -40,6 +41,8 @@ module.exports = {
|
||||
|
||||
/* Internal Functions, not to be exported */
|
||||
|
||||
/* Accepts the 'stops' array from a db query and produces an
|
||||
array of only public stops as TIPLOCs. */
|
||||
async function getPublicStops(data) {
|
||||
let tiplocList = [];
|
||||
for (const publicStop in data) {
|
||||
@@ -50,7 +53,10 @@ async function getPublicStops(data) {
|
||||
return tiplocList;
|
||||
}
|
||||
|
||||
async function parseTrains(data) { // Takes a single days data from a headcode query and returns only relevant services
|
||||
/* Takes a single days data from a headcode query and requeries
|
||||
using the trainUid, required to ensure any cancellations are
|
||||
accounted for */
|
||||
async function parseTrains(data) {
|
||||
let trainUids = [];
|
||||
for (const i of data) {
|
||||
const trainUid = i['trainUid'];
|
||||
@@ -66,7 +72,10 @@ async function parseTrains(data) { // Takes a single days data from a headcode q
|
||||
return parsedData;
|
||||
}
|
||||
|
||||
async function findByTrainUid(uid, date = new Date()) { // Date defaults to today
|
||||
/* Queries using a trainUid and filters all schedules that
|
||||
have been over-ridden by overlays, cancellations and new
|
||||
schedules. */
|
||||
async function findByTrainUid(uid, date = new Date()) {
|
||||
const query = {
|
||||
trainUid: uid,
|
||||
scheduleStartDate: {$lte: date},
|
||||
@@ -109,17 +118,21 @@ async function findByTrainUid(uid, date = new Date()) { // Date defaults to toda
|
||||
|
||||
if (stpIndicator === 'C') {
|
||||
return;
|
||||
//continue;
|
||||
}
|
||||
if (stpIndicator === 'N' && !thisStpIndicators.hasC) {
|
||||
if (stpIndicator === 'N' &&
|
||||
!thisStpIndicators.hasC) {
|
||||
return serviceDetail;
|
||||
//preparedData.push(serviceDetail);
|
||||
} else if (stpIndicator === 'O' && !thisStpIndicators.hasC && !thisStpIndicators.hasN) {
|
||||
|
||||
} else if (stpIndicator === 'O' &&
|
||||
!thisStpIndicators.hasC &&
|
||||
!thisStpIndicators.hasN) {
|
||||
return serviceDetail;
|
||||
//preparedData.push(serviceDetail);
|
||||
} else if (stpIndicator === 'P' && !thisStpIndicators.hasC && !thisStpIndicators.hasN && !thisStpIndicators.hasO) {
|
||||
|
||||
} else if (stpIndicator === 'P' &&
|
||||
!thisStpIndicators.hasC &&
|
||||
!thisStpIndicators.hasN &&
|
||||
!thisStpIndicators.hasO) {
|
||||
return serviceDetail;
|
||||
//preparedData.push(serviceDetail);
|
||||
}
|
||||
}
|
||||
return preparedData;
|
||||
|
||||
Reference in New Issue
Block a user