From cc2895bf40a99b046c737b2b17f14ba1913bfa03 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Sat, 24 Dec 2022 10:44:01 +0000 Subject: [PATCH] Remove /test endpoint. Update readme --- README.md | 34 +++++++++++++++-------------- app.js | 1 - src/controllers/test.controllers.js | 25 --------------------- src/routes/test.routes.js | 8 ------- src/services/test.services.js | 20 ----------------- 5 files changed, 18 insertions(+), 70 deletions(-) delete mode 100644 src/controllers/test.controllers.js delete mode 100644 src/routes/test.routes.js delete mode 100644 src/services/test.services.js diff --git a/README.md b/README.md index 8fce966..ebbdb17 100644 --- a/README.md +++ b/README.md @@ -22,37 +22,39 @@ To run this server you will need: ## API Endpoints: - /api/v1: - - /test: - - GET: Check your connection with the server - - If `Authentication: Basic` header is provided your key will be checked, if not then just the conenction will be tested. - /list: - - GET: Get list of stations - - Request Header - Basic Auth -- Not Currently Implemented/Required on this route - - Returns JSON: `{"STATION NAME":{"CRS":"code","TIPLOC":"code"}}` + - /stations: + - GET: Get list of stations + - Authenticated: No + - Returns JSON: `{"STATION NAME":{"CRS":"code","TIPLOC":"code"}}` - - /all: + - /corpus: - GET: Get full CORPUS Data - - Returns JSON in original CORPUS format minus any blank values. + - Authenticated: No + - Returns JSON in original CORPUS format minus any blank values. - /ldb: - /{crs}: - GET: Get arrival/departure board for {crs} - - Request Header - Basic Auth -- Not Currently Implemented/Required on this route + - Authenticated: No - Returns JSON: Formatted as per ldbs-json module. - /gitea: - POST: Post issue to Gitea Repo + - Authenticated: Yes - Not yet implemented, submit issues at https://git.fjla.uk/fred.boniface/owlboard - - /api/kube: - - /alive: - - GET: Check alive - - Returns JSON: `{"status":"alive"}` + - /kube: + - /alive: + - GET: Check alive + - Authenticated: No + - Returns JSON: `{"status":"alive"}` - - /ready: - - GET: Check ready - - Returns JSON: `{"state":""}` ready or not_ready. + - /ready: + - GET: Check ready + - Authenticated: No + - Returns JSON: `{"state":""}` ready or not_ready. ## Stack: - app.js -> Launches server, Entry Point, defines routers and middlewares. diff --git a/app.js b/app.js index 3b983ba..580072a 100644 --- a/app.js +++ b/app.js @@ -44,7 +44,6 @@ app.use(express.json()); //JSON Parsing for POST Requests app.use(express.static('static')); //Serve static content from /static // Express Routes -app.use('/api/v1/test', testRtr); app.use('/api/v1/list', listRtr); app.use('/api/v1/ldb', ldbRtr); app.use('/api/v1/kube', kubeRtr); diff --git a/src/controllers/test.controllers.js b/src/controllers/test.controllers.js deleted file mode 100644 index dcee6c5..0000000 --- a/src/controllers/test.controllers.js +++ /dev/null @@ -1,25 +0,0 @@ -const test = require('../services/test.services'); - -async function get(req, res, next){ - try { - res.json(await test.get(req.body)) - } catch (err) { - console.error(`Unknown Error`, err.message); - next(err); - } -} - -async function post(req, res){ - // try { checkAuth(req.body) } catch (err) { req.header(401); req.body({401:"unauthorised"})} - try { - res.json(await test.post(req.body)) - } catch (err) { - console.error(`Unknown Error`, err.message); - next(err); - } -}; - -module.exports = { - get, - post -} \ No newline at end of file diff --git a/src/routes/test.routes.js b/src/routes/test.routes.js deleted file mode 100644 index 2c6c5a8..0000000 --- a/src/routes/test.routes.js +++ /dev/null @@ -1,8 +0,0 @@ -const express = require('express'); -const router = express.Router(); -const testController = require('../controllers/test.controllers'); - -router.get('/', testController.get); -router.post('/', testController.post); - -module.exports = router; \ No newline at end of file diff --git a/src/services/test.services.js b/src/services/test.services.js deleted file mode 100644 index e2573de..0000000 --- a/src/services/test.services.js +++ /dev/null @@ -1,20 +0,0 @@ -// Get CORPUS data from Network Rail and format the data for OwlBoard - -// FUNCTIONS -// get() : Exported: Returns: Ready Status and Owlboard Version -// post() : Exported: Will check the API authentication and return status - -const version = require('../configs/version.configs'); - -async function get(){ - return {"OwlBoard_Status":"ready","OwlBoard_Version":version}; -} - -async function post(){ - return {"type":"post"}; -} - -module.exports = { - get, - post -} \ No newline at end of file