aboutsummaryrefslogtreecommitdiff
path: root/src/server
diff options
context:
space:
mode:
Diffstat (limited to 'src/server')
-rw-r--r--src/server/ActionUtilities.ts2
-rw-r--r--src/server/ApiManagers/UploadManager.ts12
-rw-r--r--src/server/ApiManagers/UserManager.ts2
-rw-r--r--src/server/DashSession/DashSessionAgent.ts2
-rw-r--r--src/server/DashSession/Session/agents/monitor.ts2
-rw-r--r--src/server/DashSession/Session/agents/promisified_ipc_manager.ts2
-rw-r--r--src/server/DashSession/Session/agents/server_worker.ts2
-rw-r--r--src/server/DashUploadUtils.ts4
-rw-r--r--src/server/Search.ts2
-rw-r--r--src/server/apis/google/GoogleApiServerUtils.ts4
-rw-r--r--src/server/remapUrl.ts2
-rw-r--r--src/server/server_Initialization.ts12
12 files changed, 28 insertions, 20 deletions
diff --git a/src/server/ActionUtilities.ts b/src/server/ActionUtilities.ts
index d237869ed..bc8fd6f87 100644
--- a/src/server/ActionUtilities.ts
+++ b/src/server/ActionUtilities.ts
@@ -62,7 +62,7 @@ export async function log_execution<T>({ startMessage, endMessage, action, color
log_helper(`${startMessage}...`, resolvedColor);
try {
result = await action();
- } catch (e) {
+ } catch (e: any) {
error = e;
} finally {
log_helper(typeof endMessage === "string" ? endMessage : endMessage({ result, error }), resolvedColor);
diff --git a/src/server/ApiManagers/UploadManager.ts b/src/server/ApiManagers/UploadManager.ts
index 8da08fe33..bfa07d47a 100644
--- a/src/server/ApiManagers/UploadManager.ts
+++ b/src/server/ApiManagers/UploadManager.ts
@@ -48,10 +48,9 @@ export default class UploadManager extends ApiManager {
method: Method.POST,
subscription: "/uploadFormData",
secureHandler: async ({ req, res }) => {
- const form = new formidable.IncomingForm({
- keepExtensions: true,
- uploadDir: pathToDirectory(Directory.parsed_files)
- });
+ const form = new formidable.IncomingForm();
+ form.keepExtensions = true;
+ form.uploadDir = pathToDirectory(Directory.parsed_files);
return new Promise<void>(resolve => {
form.parse(req, async (_err, _fields, files) => {
const results: Upload.FileResponse[] = [];
@@ -144,7 +143,8 @@ export default class UploadManager extends ApiManager {
subscription: "/uploadDoc",
secureHandler: ({ req, res }) => {
- const form = new formidable.IncomingForm({ keepExtensions: true });
+ const form = new formidable.IncomingForm();
+ form.keepExtensions = true;
// let path = req.body.path;
const ids: { [id: string]: string } = {};
let remap = true;
@@ -222,7 +222,7 @@ export default class UploadManager extends ApiManager {
id = getId(data.id);
const docs = Object.keys(datadocs).map(key => datadocs[key]);
docs.forEach(mapFn);
- await Promise.all(docs.map((doc: any) => new Promise(res => {
+ await Promise.all(docs.map((doc: any) => new Promise<void>(res => {
Database.Instance.replace(doc.id, doc, (err, r) => {
err && console.log(err);
res();
diff --git a/src/server/ApiManagers/UserManager.ts b/src/server/ApiManagers/UserManager.ts
index fe80c6a7c..7be8a1e9f 100644
--- a/src/server/ApiManagers/UserManager.ts
+++ b/src/server/ApiManagers/UserManager.ts
@@ -22,7 +22,7 @@ export default class UserManager extends ApiManager {
secureHandler: async ({ res }) => {
const cursor = await Database.Instance.query({}, { email: 1, linkDatabaseId: 1, sharingDocumentId: 1 }, "users");
const results = await cursor.toArray();
- res.send(results.map(user => ({ email: user.email, linkDatabaseId: user.linkDatabaseId, sharingDocumentId: user.sharingDocumentId })));
+ res.send(results.map((user: any) => ({ email: user.email, linkDatabaseId: user.linkDatabaseId, sharingDocumentId: user.sharingDocumentId })));
}
});
diff --git a/src/server/DashSession/DashSessionAgent.ts b/src/server/DashSession/DashSessionAgent.ts
index 03ba33fee..1a5934d8f 100644
--- a/src/server/DashSession/DashSessionAgent.ts
+++ b/src/server/DashSession/DashSessionAgent.ts
@@ -214,7 +214,7 @@ export class DashSessionAgent extends AppliedSessionAgent {
// indicate success or failure
mainLog(`${error === null ? green("successfully dispatched") : red("failed to dispatch")} ${zipName} to ${cyan(to)}`);
error && mainLog(red(error.message));
- } catch (error) {
+ } catch (error: any) {
mainLog(red("unable to dispatch zipped backup..."));
mainLog(red(error.message));
}
diff --git a/src/server/DashSession/Session/agents/monitor.ts b/src/server/DashSession/Session/agents/monitor.ts
index 0fdaf07ff..9cb5ab576 100644
--- a/src/server/DashSession/Session/agents/monitor.ts
+++ b/src/server/DashSession/Session/agents/monitor.ts
@@ -178,7 +178,7 @@ export class Monitor extends IPCMessageReceiver {
// ensure all necessary and no excess information is specified by the configuration file
validate(config, configurationSchema, options);
config = Utilities.preciseAssign({}, defaultConfig, config);
- } catch (error) {
+ } catch (error: any) {
if (error instanceof ValidationError) {
console.log(red("\nSession configuration failed."));
console.log("The given session.config.json configuration file is invalid.");
diff --git a/src/server/DashSession/Session/agents/promisified_ipc_manager.ts b/src/server/DashSession/Session/agents/promisified_ipc_manager.ts
index 95aa686e6..f6c8de521 100644
--- a/src/server/DashSession/Session/agents/promisified_ipc_manager.ts
+++ b/src/server/DashSession/Session/agents/promisified_ipc_manager.ts
@@ -157,7 +157,7 @@ export class PromisifiedIPCManager {
if (registered) {
results = await Promise.all(registered.map(handler => handler(args)));
}
- } catch (e) {
+ } catch (e: any) {
error = e;
}
if (!this.isDestroyed && this.target.send) {
diff --git a/src/server/DashSession/Session/agents/server_worker.ts b/src/server/DashSession/Session/agents/server_worker.ts
index 84d35b40e..634b0113d 100644
--- a/src/server/DashSession/Session/agents/server_worker.ts
+++ b/src/server/DashSession/Session/agents/server_worker.ts
@@ -138,7 +138,7 @@ export class ServerWorker extends IPCMessageReceiver {
this.isInitialized = true;
}
this.shouldServerBeResponsive = true;
- } catch (error) {
+ } catch (error: any) {
// if we expect the server to be unavailable, i.e. during compilation,
// the listening variable is false, activeExit will return early and the child
// process will continue
diff --git a/src/server/DashUploadUtils.ts b/src/server/DashUploadUtils.ts
index 7073ee90b..552ab57a5 100644
--- a/src/server/DashUploadUtils.ts
+++ b/src/server/DashUploadUtils.ts
@@ -244,7 +244,7 @@ export namespace DashUploadUtils {
// Use the request library to parse out file level image information in the headers
const { headers } = (await new Promise<any>((resolve, reject) => {
request.head(resolvedUrl, (error, res) => error ? reject(error) : resolve(res));
- }).catch(error => console.error(error)));
+ }).catch(console.error));
try {
// Compute the native width and height ofthe image with an npm module
const { width: nativeWidth, height: nativeHeight } = await requestImageSize(resolvedUrl);
@@ -258,7 +258,7 @@ export namespace DashUploadUtils {
filename,
...results
};
- } catch (e) {
+ } catch (e: any) {
console.log(e);
return e;
}
diff --git a/src/server/Search.ts b/src/server/Search.ts
index 68f61deb2..25bd8badf 100644
--- a/src/server/Search.ts
+++ b/src/server/Search.ts
@@ -49,7 +49,7 @@ export namespace Search {
},
json: true
});
- } catch (e) {
+ } catch (e: any) {
console.log(red("Unable to clear search..."));
console.log(red(e.message));
}
diff --git a/src/server/apis/google/GoogleApiServerUtils.ts b/src/server/apis/google/GoogleApiServerUtils.ts
index 64bafe7fb..4453b83bf 100644
--- a/src/server/apis/google/GoogleApiServerUtils.ts
+++ b/src/server/apis/google/GoogleApiServerUtils.ts
@@ -128,7 +128,7 @@ export namespace GoogleApiServerUtils {
* @param userId the id of the Dash user making the request to the API
* @returns the relevant 'googleapis' wrapper, if any
*/
- export async function GetEndpoint(sector: string, userId: string): Promise<Opt<Endpoint>> {
+ export async function GetEndpoint(sector: string, userId: string): Promise<Endpoint | void> {
return new Promise(async resolve => {
const auth = await retrieveOAuthClient(userId);
if (!auth) {
@@ -157,7 +157,7 @@ export namespace GoogleApiServerUtils {
* npm-installed API wrappers that use authenticated client instances rather than access codes for
* security.
*/
- export async function retrieveOAuthClient(userId: string): Promise<OAuth2Client> {
+ export async function retrieveOAuthClient(userId: string): Promise<OAuth2Client | void> {
return new Promise(async resolve => {
const { credentials, refreshed } = await retrieveCredentials(userId);
if (!credentials) {
diff --git a/src/server/remapUrl.ts b/src/server/remapUrl.ts
index e9f9da25a..b8e17ec66 100644
--- a/src/server/remapUrl.ts
+++ b/src/server/remapUrl.ts
@@ -47,7 +47,7 @@ async function update() {
await cursor.forEach(updateDoc);
await Promise.all(updates.map(doc => {
console.log(doc[0], doc[1]);
- return new Promise(res => Database.Instance.update(doc[0], doc[1], () => {
+ return new Promise<void>(res => Database.Instance.update(doc[0], doc[1], () => {
console.log("wrote " + JSON.stringify(doc[1]));
res();
}, false));
diff --git a/src/server/server_Initialization.ts b/src/server/server_Initialization.ts
index 06c701468..a10cd4983 100644
--- a/src/server/server_Initialization.ts
+++ b/src/server/server_Initialization.ts
@@ -31,7 +31,7 @@ const compiler = webpack(config);
/* RouteSetter is a wrapper around the server that prevents the server
from being exposed. */
export type RouteSetter = (server: RouteManager) => void;
-export let disconnect: Function;
+//export let disconnect: Function;
export let resolvedPorts: { server: number, socket: number } = { server: 1050, socket: 4321 };
export let resolvedServerUrl: string;
@@ -40,6 +40,14 @@ export default async function InitializeServer(routeSetter: RouteSetter) {
const isRelease = determineEnvironment();
const app = buildWithMiddleware(express());
+ const compiler = webpack(config);
+
+ app.use(require("webpack-dev-middleware")(compiler, {
+ publicPath: config.output.publicPath
+ }));
+
+ app.use(require("webpack-hot-middleware")(compiler));
+
// route table managed by express. routes are tested sequentially against each of these map rules. when a match is found, the handler is called to process the request
app.get(new RegExp(/^\/+$/), (req, res) => res.redirect(req.user ? "/home" : "/login")); // target urls that consist of one or more '/'s with nothing in between
app.use(express.static(publicDirectory, { setHeaders: res => res.setHeader("Access-Control-Allow-Origin", "*") })); //all urls that start with dash's public directory: /files/ (e.g., /files/images, /files/audio, etc)
@@ -66,7 +74,7 @@ export default async function InitializeServer(routeSetter: RouteSetter) {
// a field on one client, that change must be broadcast to all other clients)
await WebSocket.initialize(isRelease, app);
- disconnect = async () => new Promise<Error>(resolve => server.close(resolve));
+ //disconnect = async () => new Promise<Error>(resolve => server.close(resolve));
return isRelease;
}