Remove /test endpoint. Update readme

This commit is contained in:
Fred Boniface 2022-12-24 10:44:01 +00:00
parent c2c04cee12
commit cc2895bf40
5 changed files with 18 additions and 70 deletions

View File

@ -22,37 +22,39 @@ To run this server you will need:
## API Endpoints: ## API Endpoints:
- /api/v1: - /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: - /list:
- GET: Get list of stations - /stations:
- Request Header - Basic Auth -- Not Currently Implemented/Required on this route - GET: Get list of stations
- Returns JSON: `{"STATION NAME":{"CRS":"code","TIPLOC":"code"}}` - Authenticated: No
- Returns JSON: `{"STATION NAME":{"CRS":"code","TIPLOC":"code"}}`
- /all: - /corpus:
- GET: Get full CORPUS Data - 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: - /ldb:
- /{crs}: - /{crs}:
- GET: Get arrival/departure board for {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. - Returns JSON: Formatted as per ldbs-json module.
- /gitea: - /gitea:
- POST: Post issue to Gitea Repo - POST: Post issue to Gitea Repo
- Authenticated: Yes
- Not yet implemented, submit issues at https://git.fjla.uk/fred.boniface/owlboard - Not yet implemented, submit issues at https://git.fjla.uk/fred.boniface/owlboard
- /api/kube: - /kube:
- /alive: - /alive:
- GET: Check alive - GET: Check alive
- Returns JSON: `{"status":"alive"}` - Authenticated: No
- Returns JSON: `{"status":"alive"}`
- /ready: - /ready:
- GET: Check ready - GET: Check ready
- Returns JSON: `{"state":""}` ready or not_ready. - Authenticated: No
- Returns JSON: `{"state":""}` ready or not_ready.
## Stack: ## Stack:
- app.js -> Launches server, Entry Point, defines routers and middlewares. - app.js -> Launches server, Entry Point, defines routers and middlewares.

1
app.js
View File

@ -44,7 +44,6 @@ app.use(express.json()); //JSON Parsing for POST Requests
app.use(express.static('static')); //Serve static content from /static app.use(express.static('static')); //Serve static content from /static
// Express Routes // Express Routes
app.use('/api/v1/test', testRtr);
app.use('/api/v1/list', listRtr); app.use('/api/v1/list', listRtr);
app.use('/api/v1/ldb', ldbRtr); app.use('/api/v1/ldb', ldbRtr);
app.use('/api/v1/kube', kubeRtr); app.use('/api/v1/kube', kubeRtr);

View File

@ -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
}

View File

@ -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;

View File

@ -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
}