Add kube resource
This commit is contained in:
parent
e1001f4584
commit
29f724aaa6
21
README.md
21
README.md
@ -14,17 +14,7 @@ Currently only the public API is available as I am currently unable to request a
|
|||||||
## Requirements:
|
## Requirements:
|
||||||
|
|
||||||
To run this server you will need:
|
To run this server you will need:
|
||||||
- NodeJS
|
- Docker or Kubernetes
|
||||||
- Caching Reverse Proxy Server
|
|
||||||
- Not strictly neccessary but improves performance
|
|
||||||
- Do not cache anything on the /api/ path, API caching is done internally
|
|
||||||
- PostgreSQL Server
|
|
||||||
- Create a database and user for OwlBoard:
|
|
||||||
- DB Name: owlboard
|
|
||||||
- DB User: owlboard
|
|
||||||
- DB Pass: owlboard
|
|
||||||
- Default Name, User & Pass can be changed in /src/configs/database.configs.js
|
|
||||||
- Any additional databases will be created automatically
|
|
||||||
|
|
||||||
## WebApp Colours:
|
## WebApp Colours:
|
||||||
|
|
||||||
@ -51,6 +41,15 @@ To run this server you will need:
|
|||||||
- POST: Post issue to Gitea Repo
|
- POST: Post issue to Gitea Repo
|
||||||
- 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:
|
||||||
|
- /alive:
|
||||||
|
- GET: Check alive
|
||||||
|
- Returns JSON: `{"status":"alive"}`
|
||||||
|
|
||||||
|
- /ready:
|
||||||
|
- GET: Check ready
|
||||||
|
- 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.
|
||||||
- routes -> Routers - Directs requests to controllers.
|
- routes -> Routers - Directs requests to controllers.
|
||||||
|
2
app.js
2
app.js
@ -11,6 +11,7 @@ const version = require('./src/configs/version.configs');
|
|||||||
const testRtr = require('./src/routes/test.routes');
|
const testRtr = require('./src/routes/test.routes');
|
||||||
const listRtr = require('./src/routes/list.routes');
|
const listRtr = require('./src/routes/list.routes');
|
||||||
const ldbRtr = require('./src/routes/ldb.routes');
|
const ldbRtr = require('./src/routes/ldb.routes');
|
||||||
|
const kubeRtr = require('./src/routes/kube.routes');
|
||||||
|
|
||||||
// Print version number:
|
// Print version number:
|
||||||
console.log(`Starting OwlBoard - App Version: ${version.app} - API versions: ${version.api}`);
|
console.log(`Starting OwlBoard - App Version: ${version.app} - API versions: ${version.api}`);
|
||||||
@ -31,6 +32,7 @@ app.use(express.static('static')); //Serve static content from static
|
|||||||
app.use('/api/v1/test', testRtr);
|
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/kube', kubeRtr);
|
||||||
|
|
||||||
// Start Express
|
// Start Express
|
||||||
app.listen(config.port, config.listen, (error) =>{
|
app.listen(config.port, config.listen, (error) =>{
|
||||||
|
19
src/controllers/kube.controllers.js
Normal file
19
src/controllers/kube.controllers.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
const kube = require('../services/kube.services');
|
||||||
|
|
||||||
|
async function getAlive(req, res, next){
|
||||||
|
res.status("200").send(`{"status":"alive"}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getReady(req, res, next){
|
||||||
|
try {
|
||||||
|
res.json(await kube.getReady(req.body))
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`Unknown Error`, err.message);
|
||||||
|
next(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
getAlive,
|
||||||
|
getReady
|
||||||
|
}
|
8
src/routes/kube.routes.js
Normal file
8
src/routes/kube.routes.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
const express = require('express');
|
||||||
|
const router = express.Router();
|
||||||
|
const kubeController = require('../controllers/kube.controllers');
|
||||||
|
|
||||||
|
router.get('/alive', testController.getAlive);
|
||||||
|
router.get('/ready', kubeController.getReady);
|
||||||
|
|
||||||
|
module.exports = router;
|
Reference in New Issue
Block a user