diff --git a/app.js b/app.js index 19ea293..3978886 100644 --- a/app.js +++ b/app.js @@ -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) =>{ diff --git a/src/configs/version.configs.js b/src/configs/version.configs.js index 086755e..036abdb 100644 --- a/src/configs/version.configs.js +++ b/src/configs/version.configs.js @@ -1,5 +1,6 @@ const version = { - api: "0.0.1" + api: ["/api/v1/",], + app: "0.0.1" }; module.exports = version; \ No newline at end of file diff --git a/src/controllers/list.controllers.js b/src/controllers/list.controllers.js index 34dd916..fdf9023 100644 --- a/src/controllers/list.controllers.js +++ b/src/controllers/list.controllers.js @@ -10,6 +10,5 @@ async function get(req, res, next){ } module.exports = { - get, - post + get } \ No newline at end of file diff --git a/src/routes/test.routes.js b/src/routes/test.routes.js index 99aa571..2c6c5a8 100644 --- a/src/routes/test.routes.js +++ b/src/routes/test.routes.js @@ -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); diff --git a/src/services/db.services.js b/src/services/db.services.js index e69de29..c58d80b 100644 --- a/src/services/db.services.js +++ b/src/services/db.services.js @@ -0,0 +1 @@ +// General DB Access aswell as dbInit tests etc. \ No newline at end of file diff --git a/src/services/ldb.services.js b/src/services/ldb.services.js index 2ad7189..54f52b6 100644 --- a/src/services/ldb.services.js +++ b/src/services/ldb.services.js @@ -1 +1,10 @@ -const ldb = require('ldbs-json'); \ No newline at end of file +const ldb = require('ldbs-json'); +const keys = require('/srv/keys/owlboard/keys.configs'); + +async function returnBoard(){ + new ldb(keys.ldb,false) +}; + +module.exports = { + returnBoard +} \ No newline at end of file diff --git a/src/services/list.services.js b/src/services/list.services.js index 2bb7010..a3b5d23 100644 --- a/src/services/list.services.js +++ b/src/services/list.services.js @@ -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 } \ No newline at end of file diff --git a/src/services/test.services.js b/src/services/test.services.js index 4eab255..350ee0c 100644 --- a/src/services/test.services.js +++ b/src/services/test.services.js @@ -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(){ diff --git a/src/utils/dbinit.utils.js b/src/utils/dbinit.utils.js new file mode 100644 index 0000000..c142d2e --- /dev/null +++ b/src/utils/dbinit.utils.js @@ -0,0 +1,3 @@ +// Initialise database functions here +// Rewrite Python3 script to clean CORPUS data +// Also maybe scripting to FETCH the CORPUS data \ No newline at end of file diff --git a/src/utils/ldbKey.utils.js b/src/utils/ldbKey.utils.js deleted file mode 100644 index b5f40d1..0000000 --- a/src/utils/ldbKey.utils.js +++ /dev/null @@ -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 -}; \ No newline at end of file