Various, fairly unproductive

This commit is contained in:
Fred Boniface 2022-12-01 22:07:20 +00:00
parent b4bd795b3a
commit 3d30b6964f
10 changed files with 32 additions and 48 deletions

17
app.js
View File

@ -12,11 +12,12 @@ const testRtr = require('./src/routes/test.routes');
const listRtr = require('./src/routes/list.routes');
// Print version number:
console.log(`Starting OwlBoard, API version ${version.api}`);
console.log(`Starting OwlBoard - App Version: ${version.app} - API versions: ${version.api}`);
// Submodules:
app.use(express.json()); //JSON Parsing for POST Requests
app.use(express.static('static')); //Serve static content from static
// 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:
app.use((err, req, res, next) => {
@ -26,9 +27,13 @@ app.use((err, req, res, next) => {
return;
});
// Submodules:
app.use(express.json()); //JSON Parsing for POST Requests
app.use(express.static('static')); //Serve static content from static
// Point to Routes
app.use('/api/test', testRtr);
app.use('/api/list', listRtr);
app.use('/api/v1/test', testRtr);
app.use('/api/v1/list', listRtr);
// Start server
app.listen(config.port, config.listen, (error) =>{

View File

@ -1,5 +1,6 @@
const version = {
api: "0.0.1"
api: ["/api/v1/",],
app: "0.0.1"
};
module.exports = version;

View File

@ -10,6 +10,5 @@ async function get(req, res, next){
}
module.exports = {
get,
post
get
}

View File

@ -2,18 +2,6 @@ const express = require('express');
const router = express.Router();
const testController = require('../controllers/test.controllers');
/* GET programming languages. */
//router.get('/', programmingLanguagesController.get);
/* POST programming language */
//router.post('/', programmingLanguagesController.create);
/* PUT programming language */
//router.put('/:id', programmingLanguagesController.update);
/* DELETE programming language */
//router.delete('/:id', programmingLanguagesController.remove);
router.get('/', testController.get);
router.post('/', testController.post);

View File

@ -0,0 +1 @@
// General DB Access aswell as dbInit tests etc.

View File

@ -1 +1,10 @@
const ldb = require('ldbs-json');
const keys = require('/srv/keys/owlboard/keys.configs');
async function returnBoard(){
new ldb(keys.ldb,false)
};
module.exports = {
returnBoard
}

View File

@ -1,10 +1,10 @@
const version = require('../configs/version.configs');
async function get(){
return {"OwlBoard_Status":"ready","OwlBoard_Version":version.api};
// Databse lookup, get list of all stations as per the Python script output
return {};
}
module.exports = {
get,
post
get
}

View File

@ -1,7 +1,7 @@
const version = require('../configs/version.configs');
async function get(){
return {"OwlBoard_Status":"ready","OwlBoard_Version":version.api};
return {"OwlBoard_Status":"ready","OwlBoard_Version":version};
}
async function post(){

View File

@ -0,0 +1,3 @@
// Initialise database functions here
// Rewrite Python3 script to clean CORPUS data
// Also maybe scripting to FETCH the CORPUS data

View File

@ -1,22 +0,0 @@
const fs = require('fs');
async function returnKey(type){ //Reads API key from file and returns either ldb or ldbsv key
try {
var keys = JSON.parse(fs.readFileSync('/srv/keys/owlboard/keys.json', 'utf8'));
console.log('API Keys loaded from /srv/keys/ownboard/keys.json');
} catch (err) {
var keys = 'ERR';
console.error('Unable to obtain API Keys from file');
console.error(err);
};
if (staff = true){
return keys.ldb;
} else {
return keys.ldvsv;
};
};
module.exports = {
returnKey
};