The DTP Sites web app development engine.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

64 lines
1.4 KiB

// hive.js
// Copyright (C) 2022 DTP Technologies, LLC
// License: Apache-2.0
'use strict';
const DTP_COMPONENT_NAME = 'hive';
const path = require('path');
const express = require('express');
const { SiteController } = require('../../lib/site-lib');
class HiveController extends SiteController {
constructor (dtp) {
super(dtp, DTP_COMPONENT_NAME);
this.services = [ ];
}
async start ( ) {
const router = express.Router();
this.dtp.app.use('/hive', router);
router.use(
async (req, res, next) => {
res.locals.currentView = 'hive';
res.locals.hiveView = 'home';
/*
* TODO: H1V3 authentication before processing request (HTTP Bearer token)
*/
return next();
},
);
router.use('/kaleidoscope',await this.loadChild(path.join(__dirname, 'hive', 'kaleidoscope')));
this.services.push({ name: 'kaleidoscope', url: '/hive/kaleidoscope' });
router.get('/', this.getHiveRoot.bind(this));
return router;
}
async getHiveRoot (req, res) {
res.status(200).json({
component: DTP_COMPONENT_NAME,
host: this.dtp.pkg.name,
description: this.dtp.pkg.description,
version: this.dtp.pkg.version,
services: this.services,
});
}
}
module.exports = {
slug: 'hive',
name: 'hive',
create: async (dtp) => {
let controller = new HiveController(dtp);
return controller;
},
};