feat: option to disable /version query

This commit is contained in:
Vjacheslav Trushkin 2022-11-22 11:37:48 +02:00
parent e6b57798d8
commit 3ed726c956
3 changed files with 20 additions and 8 deletions

View File

@ -9,7 +9,9 @@ export const appConfig: AppConfig = {
// Index page
redirectIndex: 'https://iconify.design/',
// Region to add to `/version` response. Used to tell which server is responding when running multiple servers
// Region to add to `/version` response
// Used to tell which server is responding when running multiple servers
// Requires `enableVersion` to be enabled
statusRegion: '',
// Cache root directory
@ -33,6 +35,9 @@ export const appConfig: AppConfig = {
// Delay to wait between successful update request and actual update
updateThrottle: 60,
// Enables `/version` query
enableVersion: false,
// Enable icon sets and icon lists
// Disable this option if you need API to serve only icon data to save memory
enableIconLists: true,

View File

@ -178,12 +178,14 @@ export async function startHTTPServer() {
});
// Version
server.get('/version', (req, res) => {
versionResponse(req.query, res);
});
server.post('/version', (req, res) => {
versionResponse(req.query, res);
});
if (appConfig.enableVersion) {
server.get('/version', (req, res) => {
versionResponse(req.query, res);
});
server.post('/version', (req, res) => {
versionResponse(req.query, res);
});
}
// Redirect
server.get('/', (req, res) => {

View File

@ -5,7 +5,9 @@ export interface AppConfig {
// Index page
redirectIndex: string;
// Region to add to `/version` response. Used to tell which server is responding when running multiple servers
// Region to add to `/version` response
// Used to tell which server is responding when running multiple servers
// Requires `enableVersion` to be enabled
statusRegion: string;
// Cache root directory
@ -30,6 +32,9 @@ export interface AppConfig {
// Update check throttling
updateThrottle: number;
// Enables `/version` query
enableVersion: boolean;
// Enable icon sets and icon lists
// Disable this option if you need API to serve only icon data to save memory
enableIconLists: boolean;