Added conntest endpoint

This commit is contained in:
Jonathan Barrow
2022-01-10 08:19:45 -05:00
parent a2e4b15830
commit d04ff4b249
2 changed files with 38 additions and 0 deletions

View File

@@ -11,6 +11,7 @@ const config = require('./config.json');
const { http: { port } } = config;
const app = express();
const conntest = require('./services/conntest');
const account = require('./services/account');
const nasc = require('./services/nasc');
const datastore = require('./services/datastore');
@@ -30,6 +31,7 @@ app.use(express.urlencoded({
app.use(xmlparser);
// import the servers into one
app.use(conntest);
app.use(account);
app.use(nasc);
app.use(datastore);

View File

@@ -0,0 +1,36 @@
// handles conntest endpoints
const express = require('express');
const subdomain = require('express-subdomain');
const logger = require('../../../logger');
// Router to handle the subdomain restriction
const conntest = express.Router();
// Setup route
logger.info('[conntest] Applying imported routes');
conntest.get('/', async (request, response) => {
response.set('Content-Type', 'text/html');
response.set('X-Organization', 'Nintendo');
response.send(`
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>HTML Page</title>
</head>
<body bgcolor="#FFFFFF">
This is test.html page
</body>
</html>
`)
});
// Main router for endpoints
const router = express.Router();
// Create subdomains
logger.info('[conntest] Creating \'conntest\' subdomain');
router.use(subdomain('conntest', conntest));
module.exports = router;