Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

Commit

Permalink
Minor HTTP refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
GingerAdonis committed Jun 8, 2022
1 parent 1dc03a9 commit d969492
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
6 changes: 5 additions & 1 deletion config/site.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@
"title": "OpenRCT2",
"description": null,
"publicUrl": "http://localhost:5000",
"forumsPublicUrl": "https://forums.openrct2.org"
"forumsPublicUrl": "https://forums.openrct2.org",
"author": {
"name": "OpenRCT2 Webmaster",
"emailAddress": "[email protected]"
}
}
27 changes: 15 additions & 12 deletions src/http/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@ import {AltApiRouter} from './routes/altapi.js';
import {Log} from '../utils/log.js';
import {VersionUtils} from '../utils/version.js';

Eta.configure({
cache: true,
rmWhitespace: true,
});

/**
* @typedef {import('node:http').Server} NodeHTTPServer
*/

export default class HTTPServer {
static {
Eta.configure({
cache: true,
rmWhitespace: true,
});
}

/**
* @type {HTTPServer}
*/
Expand Down Expand Up @@ -110,22 +112,21 @@ export default class HTTPServer {
application.set('view engine', 'eta');
application.set('views', './views');

const siteConfig = Config.get('site');

// Set site global
application.locals.site = {
title: Config.get('site')['title'],
description: Config.get('site')['description'],
publicUrl: Config.get('site')['publicUrl'],
title: siteConfig['title'],
description: siteConfig['description'],
publicUrl: siteConfig['publicUrl'],
version: VersionUtils.getVersion(),
};

// Set frontend entrypoint global
application.locals.frontendEntrypoints = await HTTPServer.#getFrontendBundles();

// Set author global
application.locals.author = {
name: 'OpenRCT2 Webmaster',
emailAddress: '[email protected]',
};
application.locals.author = siteConfig['author'];
}

/**
Expand Down Expand Up @@ -345,3 +346,5 @@ export default class HTTPServer {
});
}
}

export {Router};

0 comments on commit d969492

Please sign in to comment.