Add comments to file heads and imporove readability
This commit is contained in:
parent
cc8dcd864c
commit
fccb00232c
24
app.js
24
app.js
@ -1,9 +1,9 @@
|
||||
// OwlBoard - © Fred Boniface 2022 - Licensed under GPLv3 (or later)
|
||||
|
||||
// Please see the included LICENSE file statically served fonts are
|
||||
// licensed separately, each folder contains a license file
|
||||
// Please see the included LICENSE file. Statically served fonts are
|
||||
// licensed separately, each folder contains a license file where a
|
||||
// different license applies.
|
||||
|
||||
// Load & prepare modules:
|
||||
const express = require('express');
|
||||
const app = express();
|
||||
const config = require('./src/configs/server.configs');
|
||||
@ -11,20 +11,10 @@ const version = require('./src/configs/version.configs');
|
||||
const testRtr = require('./src/routes/test.routes');
|
||||
const listRtr = require('./src/routes/list.routes');
|
||||
|
||||
// TESTING ONLY
|
||||
const corpus = require('./src/utils/corpus.utils');
|
||||
|
||||
corpus.getCorpus();
|
||||
|
||||
// Print version number:
|
||||
console.log(`Starting OwlBoard - App Version: ${version.app} - API versions: ${version.api}`);
|
||||
|
||||
// Check database:
|
||||
// Check for presece of DB Credentials
|
||||
// Check tables are correct
|
||||
// Build lookup table is not present or if not been updated in X time.
|
||||
|
||||
// Error Handling:
|
||||
// Express Error Handling:
|
||||
app.use((err, req, res, next) => {
|
||||
const statusCode = err.statuscode || 500;
|
||||
console.error(err.message, err.stack);
|
||||
@ -32,15 +22,15 @@ app.use((err, req, res, next) => {
|
||||
return;
|
||||
});
|
||||
|
||||
// Submodules:
|
||||
// Express Submodules:
|
||||
app.use(express.json()); //JSON Parsing for POST Requests
|
||||
app.use(express.static('static')); //Serve static content from static
|
||||
|
||||
// Point to Routes
|
||||
// Express Routes
|
||||
app.use('/api/v1/test', testRtr);
|
||||
app.use('/api/v1/list', listRtr);
|
||||
|
||||
// Start server
|
||||
// Start Express
|
||||
app.listen(config.port, config.listen, (error) =>{
|
||||
if(!error) {
|
||||
console.log(`Started server on http://${config.listen}:${config.port}`);
|
||||
|
7
src/configs/database.configs.js
Normal file
7
src/configs/database.configs.js
Normal file
@ -0,0 +1,7 @@
|
||||
const database = {
|
||||
port: 8460,
|
||||
location: "localhost",
|
||||
dbType: "postgres"
|
||||
};
|
||||
|
||||
module.exports = database;
|
@ -1,6 +1,6 @@
|
||||
// Get CORPUS data from Network Rail and format the data for OwlBoard
|
||||
|
||||
// Username and password must be stored in `/srv/keys/owlboard/keys.config.js`
|
||||
// Network Rail Datafeed user and pass must be stored in `/srv/keys/owlboard/keys.config.js`
|
||||
|
||||
// FUNCTIONS
|
||||
// init() : Exported: Uses the internal functions to return a clean CORPUS file.
|
||||
@ -19,15 +19,14 @@ async function initCorpus() {
|
||||
|
||||
async function getCorpus() {
|
||||
authHead = Buffer.from(`${keys.nr_user}:${keys.nr_pass}`).toString('base64');
|
||||
const url = 'https://datafeeds.networkrail.co.uk/ntrod/SupportingFileAuthenticate?type=CORPUS'
|
||||
const options = {
|
||||
method: 'get',
|
||||
baseURL: 'https://datafeeds.networkrail.co.uk/ntrod/SupportingFileAuthenticate?type=CORPUS',
|
||||
timeout: 3000,
|
||||
headers: {'Authorization': `Basic ${authHead}`},
|
||||
responseType: 'arraybuffer'
|
||||
};
|
||||
let download = axios.get(options);
|
||||
console.log(download);
|
||||
return await axios.get(url, options).then(function (response){console.log(response.data);return response.data;});
|
||||
}
|
||||
|
||||
async function getCorpusAgain() {
|
||||
@ -53,8 +52,10 @@ async function getCorpusAgain() {
|
||||
})
|
||||
}
|
||||
|
||||
async function init() {
|
||||
|
||||
async function init() { // PSUEDOCODE
|
||||
var zipData = await get();
|
||||
var rawData = extract(zipData);
|
||||
var cleanData = clean(rawData)
|
||||
}
|
||||
|
||||
async function get() {
|
||||
@ -72,5 +73,6 @@ async function clean() {
|
||||
module.exports = {
|
||||
initCorpus,
|
||||
getCorpusAgain,
|
||||
getCorpus
|
||||
getCorpus,
|
||||
init
|
||||
}
|
@ -1,5 +1,10 @@
|
||||
// Initialise database functions here
|
||||
// Rewrite Python3 script to clean CORPUS data
|
||||
// Also maybe scripting to FETCH the CORPUS data
|
||||
|
||||
// FUNCTIONS
|
||||
// init() : Exported: Uses the internal functions to initialise databases.
|
||||
// check() : Checks authentication, presence of tables and contents of tables.
|
||||
// build() : Builds the lookup table using the corpus.utils to download data.
|
||||
const dbCfg = require('../configs/database.configs');
|
||||
const corpus = require('../utils/corpus.utils');
|
||||
|
||||
module.exports = {
|
||||
init
|
||||
}
|
Reference in New Issue
Block a user