Add kube resource

This commit is contained in:
Fred Boniface 2022-12-16 00:21:44 +00:00
parent e1001f4584
commit 29f724aaa6
4 changed files with 39 additions and 11 deletions

View File

@ -14,17 +14,7 @@ Currently only the public API is available as I am currently unable to request a
## Requirements:
To run this server you will need:
- NodeJS
- 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
- Docker or Kubernetes
## WebApp Colours:
@ -51,6 +41,15 @@ To run this server you will need:
- POST: Post issue to Gitea Repo
- 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:
- app.js -> Launches server, Entry Point, defines routers and middlewares.
- routes -> Routers - Directs requests to controllers.

2
app.js
View File

@ -11,6 +11,7 @@ const version = require('./src/configs/version.configs');
const testRtr = require('./src/routes/test.routes');
const listRtr = require('./src/routes/list.routes');
const ldbRtr = require('./src/routes/ldb.routes');
const kubeRtr = require('./src/routes/kube.routes');
// Print version number:
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/list', listRtr);
app.use('/api/v1/ldb', ldbRtr);
app.use('/api/kube', kubeRtr);
// Start Express
app.listen(config.port, config.listen, (error) =>{

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

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