Various, fairly unproductive
This commit is contained in:
parent
b4bd795b3a
commit
3d30b6964f
17
app.js
17
app.js
@ -12,11 +12,12 @@ const testRtr = require('./src/routes/test.routes');
|
|||||||
const listRtr = require('./src/routes/list.routes');
|
const listRtr = require('./src/routes/list.routes');
|
||||||
|
|
||||||
// Print version number:
|
// Print version number:
|
||||||
console.log(`Starting OwlBoard, API version ${version.api}`);
|
console.log(`Starting OwlBoard - App Version: ${version.app} - API versions: ${version.api}`);
|
||||||
|
|
||||||
// Submodules:
|
// Check database:
|
||||||
app.use(express.json()); //JSON Parsing for POST Requests
|
// Check for presece of DB Credentials
|
||||||
app.use(express.static('static')); //Serve static content from static
|
// Check tables are correct
|
||||||
|
// Build lookup table is not present or if not been updated in X time.
|
||||||
|
|
||||||
// Error Handling:
|
// Error Handling:
|
||||||
app.use((err, req, res, next) => {
|
app.use((err, req, res, next) => {
|
||||||
@ -26,9 +27,13 @@ app.use((err, req, res, next) => {
|
|||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Submodules:
|
||||||
|
app.use(express.json()); //JSON Parsing for POST Requests
|
||||||
|
app.use(express.static('static')); //Serve static content from static
|
||||||
|
|
||||||
// Point to Routes
|
// Point to Routes
|
||||||
app.use('/api/test', testRtr);
|
app.use('/api/v1/test', testRtr);
|
||||||
app.use('/api/list', listRtr);
|
app.use('/api/v1/list', listRtr);
|
||||||
|
|
||||||
// Start server
|
// Start server
|
||||||
app.listen(config.port, config.listen, (error) =>{
|
app.listen(config.port, config.listen, (error) =>{
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
const version = {
|
const version = {
|
||||||
api: "0.0.1"
|
api: ["/api/v1/",],
|
||||||
|
app: "0.0.1"
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = version;
|
module.exports = version;
|
@ -10,6 +10,5 @@ async function get(req, res, next){
|
|||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
get,
|
get
|
||||||
post
|
|
||||||
}
|
}
|
@ -2,18 +2,6 @@ const express = require('express');
|
|||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
const testController = require('../controllers/test.controllers');
|
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.get('/', testController.get);
|
||||||
router.post('/', testController.post);
|
router.post('/', testController.post);
|
||||||
|
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
// General DB Access aswell as dbInit tests etc.
|
@ -1 +1,10 @@
|
|||||||
const ldb = require('ldbs-json');
|
const ldb = require('ldbs-json');
|
||||||
|
const keys = require('/srv/keys/owlboard/keys.configs');
|
||||||
|
|
||||||
|
async function returnBoard(){
|
||||||
|
new ldb(keys.ldb,false)
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
returnBoard
|
||||||
|
}
|
@ -1,10 +1,10 @@
|
|||||||
const version = require('../configs/version.configs');
|
const version = require('../configs/version.configs');
|
||||||
|
|
||||||
async function get(){
|
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 = {
|
module.exports = {
|
||||||
get,
|
get
|
||||||
post
|
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
const version = require('../configs/version.configs');
|
const version = require('../configs/version.configs');
|
||||||
|
|
||||||
async function get(){
|
async function get(){
|
||||||
return {"OwlBoard_Status":"ready","OwlBoard_Version":version.api};
|
return {"OwlBoard_Status":"ready","OwlBoard_Version":version};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function post(){
|
async function post(){
|
||||||
|
3
src/utils/dbinit.utils.js
Normal file
3
src/utils/dbinit.utils.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
// Initialise database functions here
|
||||||
|
// Rewrite Python3 script to clean CORPUS data
|
||||||
|
// Also maybe scripting to FETCH the CORPUS data
|
@ -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
|
|
||||||
};
|
|
Reference in New Issue
Block a user