This repository has been archived on 2023-08-24. You can view files and clone it, but cannot push or open issues or pull requests.
OwlBoard/app.js

44 lines
1.5 KiB
JavaScript
Raw Normal View History

2022-11-30 22:08:27 +00:00
// OwlBoard - © Fred Boniface 2022 - Licensed under GPLv3 (or later)
// Please see the included LICENSE file. Statically served fonts are
// licensed separately, each folder contains a license file where a
// different license applies.
2022-11-30 00:21:59 +00:00
2022-11-30 14:32:36 +00:00
const express = require('express');
const app = express();
2022-12-01 13:40:24 +00:00
const config = require('./src/configs/server.configs');
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');
2022-12-16 00:21:44 +00:00
const kubeRtr = require('./src/routes/kube.routes');
2022-11-30 00:21:59 +00:00
2022-12-01 13:40:24 +00:00
// Print version number:
2022-12-01 22:07:20 +00:00
console.log(`Starting OwlBoard - App Version: ${version.app} - API versions: ${version.api}`);
2022-11-30 00:21:59 +00:00
// Express Error Handling:
2022-12-01 13:40:24 +00:00
app.use((err, req, res, next) => {
const statusCode = err.statuscode || 500;
console.error(err.message, err.stack);
res.status(statusCode).json({'message': err.message});
2022-12-01 13:53:32 +00:00
return;
2022-11-30 00:21:59 +00:00
});
// Express Submodules:
2022-12-01 22:07:20 +00:00
app.use(express.json()); //JSON Parsing for POST Requests
app.use(express.static('static')); //Serve static content from static
// Express Routes
2022-12-01 22:07:20 +00:00
app.use('/api/v1/test', testRtr);
app.use('/api/v1/list', listRtr);
app.use('/api/v1/ldb', ldbRtr);
2022-12-16 00:21:44 +00:00
app.use('/api/kube', kubeRtr);
2022-11-30 00:21:59 +00:00
// Start Express
2022-12-01 13:40:24 +00:00
app.listen(config.port, config.listen, (error) =>{
if(!error) {
console.log(`Started server on http://${config.listen}:${config.port}`);
} else {
console.log("Error occurred, server can't start", error);
}
});