aboutsummaryrefslogtreecommitdiff
path: root/src/server/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/index.ts')
-rw-r--r--src/server/index.ts20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/server/index.ts b/src/server/index.ts
index fef26f78a..bea84c6ed 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -36,7 +36,7 @@ import { Search } from './Search';
const MongoStore = require('connect-mongo')(session);
const mongoose = require('mongoose');
-const download = (url: string, dest: fs.PathLike) => request.get(url).pipe(fs.createWriteStream(dest));;
+const download = (url: string, dest: fs.PathLike) => request.get(url).pipe(fs.createWriteStream(dest));
const mongoUrl = 'mongodb://localhost:27017/Dash';
mongoose.connect(mongoUrl);
@@ -88,9 +88,11 @@ function addSecureRoute(method: Method,
...subscribers: string[]
) {
let abstracted = (req: express.Request, res: express.Response) => {
- const dashUser: DashUserModel = req.user;
- if (!dashUser) return onRejection(res);
- handler(dashUser, res, req);
+ if (req.user) {
+ handler(req.user, res, req);
+ } else {
+ onRejection(res);
+ }
};
subscribers.forEach(route => {
switch (method) {
@@ -253,20 +255,20 @@ function barReceived(guid: String) {
clients[guid.toString()] = new Client(guid.toString());
}
-function getField([id, callback]: [string, (result: any) => void]) {
- Database.Instance.getDocument(id, (result: any) =>
+function getField([id, callback]: [string, (result?: Transferable) => void]) {
+ Database.Instance.getDocument(id, (result?: Transferable) =>
callback(result ? result : undefined));
}
-function getFields([ids, callback]: [string[], (result: any) => void]) {
+function getFields([ids, callback]: [string[], (result: Transferable[]) => void]) {
Database.Instance.getDocuments(ids, callback);
}
function setField(socket: Socket, newValue: Transferable) {
- Database.Instance.update(newValue._id, newValue, () =>
+ Database.Instance.update(newValue.id, newValue, () =>
socket.broadcast.emit(MessageStore.SetField.Message, newValue));
if (newValue.type === Types.Text) {
- Search.Instance.updateDocument({ id: newValue._id, data: (newValue as any).data });
+ Search.Instance.updateDocument({ id: newValue.id, data: (newValue as any).data });
}
}