debug import name consistency
parent
e78ed5e163
commit
a1d5b45362
12
app.js
12
app.js
|
|
@ -28,9 +28,9 @@ import { version } from './version.js';
|
||||||
import * as databaseInitializer from './helpers/initializer.database.js';
|
import * as databaseInitializer from './helpers/initializer.database.js';
|
||||||
import { apiGetHandler } from './handlers/permissions.js';
|
import { apiGetHandler } from './handlers/permissions.js';
|
||||||
import { getSafeRedirectURL } from './helpers/functions.authentication.js';
|
import { getSafeRedirectURL } from './helpers/functions.authentication.js';
|
||||||
import debug from 'debug';
|
|
||||||
import { useTestDatabases } from './data/databasePaths.js';
|
import { useTestDatabases } from './data/databasePaths.js';
|
||||||
const debugApp = debug(`lot-occupancy-system:app:${process.pid}`);
|
import Debug from 'debug';
|
||||||
|
const debug = Debug(`lot-occupancy-system:app:${process.pid}`);
|
||||||
databaseInitializer.initializeDatabase();
|
databaseInitializer.initializeDatabase();
|
||||||
const _dirname = '.';
|
const _dirname = '.';
|
||||||
export const app = express();
|
export const app = express();
|
||||||
|
|
@ -44,7 +44,7 @@ if (!configFunctions.getProperty('reverseProxy.disableCompression')) {
|
||||||
app.use(compression());
|
app.use(compression());
|
||||||
}
|
}
|
||||||
app.use((request, _response, next) => {
|
app.use((request, _response, next) => {
|
||||||
debugApp(`${request.method} ${request.url}`);
|
debug(`${request.method} ${request.url}`);
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
app.use(express.json());
|
app.use(express.json());
|
||||||
|
|
@ -61,7 +61,7 @@ app.use(rateLimit({
|
||||||
}));
|
}));
|
||||||
const urlPrefix = configFunctions.getProperty('reverseProxy.urlPrefix');
|
const urlPrefix = configFunctions.getProperty('reverseProxy.urlPrefix');
|
||||||
if (urlPrefix !== '') {
|
if (urlPrefix !== '') {
|
||||||
debugApp('urlPrefix = ' + urlPrefix);
|
debug('urlPrefix = ' + urlPrefix);
|
||||||
}
|
}
|
||||||
app.use(urlPrefix, express.static(path.join('public')));
|
app.use(urlPrefix, express.static(path.join('public')));
|
||||||
app.use(urlPrefix + '/lib/bulma-calendar', express.static(path.join('node_modules', 'bulma-calendar', 'dist')));
|
app.use(urlPrefix + '/lib/bulma-calendar', express.static(path.join('node_modules', 'bulma-calendar', 'dist')));
|
||||||
|
|
@ -75,7 +75,7 @@ const FileStoreSession = FileStore(session);
|
||||||
app.use(session({
|
app.use(session({
|
||||||
store: new FileStoreSession({
|
store: new FileStoreSession({
|
||||||
path: './data/sessions',
|
path: './data/sessions',
|
||||||
logFn: debug(`lot-occupancy-system:session:${process.pid}`),
|
logFn: Debug(`lot-occupancy-system:session:${process.pid}`),
|
||||||
retries: 20
|
retries: 20
|
||||||
}),
|
}),
|
||||||
name: sessionCookieName,
|
name: sessionCookieName,
|
||||||
|
|
@ -147,7 +147,7 @@ app.get(urlPrefix + '/logout', (request, response) => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
app.use((request, _response, next) => {
|
app.use((request, _response, next) => {
|
||||||
debugApp(request.url);
|
debug(request.url);
|
||||||
next(createError(404, 'File not found: ' + request.url));
|
next(createError(404, 'File not found: ' + request.url));
|
||||||
});
|
});
|
||||||
export default app;
|
export default app;
|
||||||
|
|
|
||||||
12
app.ts
12
app.ts
|
|
@ -37,10 +37,10 @@ import * as databaseInitializer from './helpers/initializer.database.js'
|
||||||
import { apiGetHandler } from './handlers/permissions.js'
|
import { apiGetHandler } from './handlers/permissions.js'
|
||||||
import { getSafeRedirectURL } from './helpers/functions.authentication.js'
|
import { getSafeRedirectURL } from './helpers/functions.authentication.js'
|
||||||
|
|
||||||
import debug from 'debug'
|
|
||||||
import { useTestDatabases } from './data/databasePaths.js'
|
import { useTestDatabases } from './data/databasePaths.js'
|
||||||
|
|
||||||
const debugApp = debug(`lot-occupancy-system:app:${process.pid}`)
|
import Debug from 'debug'
|
||||||
|
const debug = Debug(`lot-occupancy-system:app:${process.pid}`)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* INITIALIZE THE DATABASE
|
* INITIALIZE THE DATABASE
|
||||||
|
|
@ -71,7 +71,7 @@ if (!configFunctions.getProperty('reverseProxy.disableCompression')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
app.use((request, _response, next) => {
|
app.use((request, _response, next) => {
|
||||||
debugApp(`${request.method} ${request.url}`)
|
debug(`${request.method} ${request.url}`)
|
||||||
next()
|
next()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -108,7 +108,7 @@ app.use(
|
||||||
const urlPrefix = configFunctions.getProperty('reverseProxy.urlPrefix')
|
const urlPrefix = configFunctions.getProperty('reverseProxy.urlPrefix')
|
||||||
|
|
||||||
if (urlPrefix !== '') {
|
if (urlPrefix !== '') {
|
||||||
debugApp('urlPrefix = ' + urlPrefix)
|
debug('urlPrefix = ' + urlPrefix)
|
||||||
}
|
}
|
||||||
|
|
||||||
app.use(urlPrefix, express.static(path.join('public')))
|
app.use(urlPrefix, express.static(path.join('public')))
|
||||||
|
|
@ -161,7 +161,7 @@ app.use(
|
||||||
session({
|
session({
|
||||||
store: new FileStoreSession({
|
store: new FileStoreSession({
|
||||||
path: './data/sessions',
|
path: './data/sessions',
|
||||||
logFn: debug(`lot-occupancy-system:session:${process.pid}`),
|
logFn: Debug(`lot-occupancy-system:session:${process.pid}`),
|
||||||
retries: 20
|
retries: 20
|
||||||
}),
|
}),
|
||||||
name: sessionCookieName,
|
name: sessionCookieName,
|
||||||
|
|
@ -280,7 +280,7 @@ app.get(urlPrefix + '/logout', (request, response) => {
|
||||||
|
|
||||||
// Catch 404 and forward to error handler
|
// Catch 404 and forward to error handler
|
||||||
app.use((request, _response, next) => {
|
app.use((request, _response, next) => {
|
||||||
debugApp(request.url)
|
debug(request.url)
|
||||||
next(createError(404, 'File not found: ' + request.url))
|
next(createError(404, 'File not found: ' + request.url))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue