deepsource-autofix-76c6eb20
Dan Gowans 2022-10-31 12:03:28 -04:00
parent 52d1e87c4e
commit 78344b4e35
8 changed files with 35 additions and 27 deletions

View File

@ -21,6 +21,7 @@
], ],
"rules": { "rules": {
"node/no-missing-import": "off", "node/no-missing-import": "off",
"node/no-unpublished-import": "off",
"unicorn/consistent-function-scoping": "warn", "unicorn/consistent-function-scoping": "warn",
"unicorn/empty-brace-spaces": "off", "unicorn/empty-brace-spaces": "off",
"unicorn/filename-case": [ "unicorn/filename-case": [

8
app.js
View File

@ -130,10 +130,10 @@ app.all(urlPrefix + "/keepAlive", (_request, response) => {
app.use(urlPrefix + "/login", routerLogin); app.use(urlPrefix + "/login", routerLogin);
app.get(urlPrefix + "/logout", (request, response) => { app.get(urlPrefix + "/logout", (request, response) => {
if (request.session.user && request.cookies[sessionCookieName]) { if (request.session.user && request.cookies[sessionCookieName]) {
request.session.destroy(null); request.session.destroy(() => {
request.session = undefined; response.clearCookie(sessionCookieName);
response.clearCookie(sessionCookieName); response.redirect(urlPrefix + "/");
response.redirect(urlPrefix + "/"); });
} }
else { else {
response.redirect(urlPrefix + "/login"); response.redirect(urlPrefix + "/login");

9
app.ts
View File

@ -233,11 +233,10 @@ app.use(urlPrefix + "/login", routerLogin);
app.get(urlPrefix + "/logout", (request, response) => { app.get(urlPrefix + "/logout", (request, response) => {
if (request.session.user && request.cookies[sessionCookieName]) { if (request.session.user && request.cookies[sessionCookieName]) {
// eslint-disable-next-line unicorn/no-null request.session.destroy(() => {
request.session.destroy(null); response.clearCookie(sessionCookieName);
request.session = undefined; response.redirect(urlPrefix + "/");
response.clearCookie(sessionCookieName); });
response.redirect(urlPrefix + "/");
} else { } else {
response.redirect(urlPrefix + "/login"); response.redirect(urlPrefix + "/login");
} }

View File

@ -10,20 +10,25 @@ const onError = (error) => {
throw error; throw error;
} }
switch (error.code) { switch (error.code) {
case "EACCES": case "EACCES": {
debugWWW("Requires elevated privileges"); debugWWW("Requires elevated privileges");
process.exit(1); process.exit(1);
case "EADDRINUSE": }
case "EADDRINUSE": {
debugWWW("Port is already in use."); debugWWW("Port is already in use.");
process.exit(1); process.exit(1);
default: }
default: {
throw error; throw error;
}
} }
}; };
const onListening = (server) => { const onListening = (server) => {
const addr = server.address(); const addr = server.address();
const bind = typeof addr === "string" ? "pipe " + addr : "port " + addr.port.toString(); if (addr) {
debugWWW("Listening on " + bind); const bind = typeof addr === "string" ? "pipe " + addr : "port " + addr.port.toString();
debugWWW("Listening on " + bind);
}
}; };
const httpPort = configFunctions.getProperty("application.httpPort"); const httpPort = configFunctions.getProperty("application.httpPort");
if (httpPort) { if (httpPort) {
@ -39,6 +44,5 @@ exitHook(() => {
if (httpServer) { if (httpServer) {
debugWWW("Closing HTTP"); debugWWW("Closing HTTP");
httpServer.close(); httpServer.close();
httpServer = undefined;
} }
}); });

View File

@ -26,29 +26,33 @@ const onError = (error: ServerError) => {
// handle specific listen errors with friendly messages // handle specific listen errors with friendly messages
switch (error.code) { switch (error.code) {
// eslint-disable-next-line no-fallthrough // eslint-disable-next-line no-fallthrough
case "EACCES": case "EACCES": {
debugWWW("Requires elevated privileges"); debugWWW("Requires elevated privileges");
process.exit(1); process.exit(1);
// break; // break;
}
// eslint-disable-next-line no-fallthrough // eslint-disable-next-line no-fallthrough
case "EADDRINUSE": case "EADDRINUSE": {
debugWWW("Port is already in use."); debugWWW("Port is already in use.");
process.exit(1); process.exit(1);
// break; // break;
}
// eslint-disable-next-line no-fallthrough // eslint-disable-next-line no-fallthrough
default: default: {
throw error; throw error;
}
} }
}; };
const onListening = (server: http.Server) => { const onListening = (server: http.Server) => {
const addr = server.address(); const addr = server.address();
const bind = typeof addr === "string" ? "pipe " + addr : "port " + addr.port.toString(); if (addr) {
const bind = typeof addr === "string" ? "pipe " + addr : "port " + addr.port.toString();
debugWWW("Listening on " + bind); debugWWW("Listening on " + bind);
}
}; };
/** /**
@ -74,6 +78,5 @@ exitHook(() => {
if (httpServer) { if (httpServer) {
debugWWW("Closing HTTP"); debugWWW("Closing HTTP");
httpServer.close(); httpServer.close();
httpServer = undefined;
} }
}); });

View File

@ -1,5 +1,3 @@
/* eslint-disable node/no-unpublished-import */
import { defineConfig } from "cypress"; import { defineConfig } from "cypress";
export default defineConfig({ export default defineConfig({

View File

@ -65,7 +65,7 @@ router
isAuthenticated = await authenticationFunctions.authenticate(userName, passwordPlain); isAuthenticated = await authenticationFunctions.authenticate(userName, passwordPlain);
} }
let userObject: recordTypes.User; let userObject: recordTypes.User | undefined;
if (isAuthenticated) { if (isAuthenticated) {
const userNameLowerCase = userName.toLowerCase(); const userNameLowerCase = userName.toLowerCase();

View File

@ -4,9 +4,12 @@ export interface LOS {
mapKey: string, mapKey: string,
contextualClass: "success" | "danger" contextualClass: "success" | "danger"
) => void; ) => void;
initializeDatePickers: (containerElement: HTMLElement) => void; initializeDatePickers: (containerElement: HTMLElement) => void;
initializeTimePickers: (containerElement: HTMLElement) => void; initializeTimePickers: (containerElement: HTMLElement) => void;
initializeUnlockFieldButtons: (containerElement: HTMLElement) => void; initializeUnlockFieldButtons: (containerElement: HTMLElement) => void;
populateAliases: (containerElement: HTMLElement) => void; populateAliases: (containerElement: HTMLElement) => void;
getRandomColor: (seedString: string) => string; getRandomColor: (seedString: string) => string;
} }