diff options
Diffstat (limited to 'src/server/ApiManagers/GeneralGoogleManager.ts')
-rw-r--r-- | src/server/ApiManagers/GeneralGoogleManager.ts | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/server/ApiManagers/GeneralGoogleManager.ts b/src/server/ApiManagers/GeneralGoogleManager.ts index 629684e0c..3617779d5 100644 --- a/src/server/ApiManagers/GeneralGoogleManager.ts +++ b/src/server/ApiManagers/GeneralGoogleManager.ts @@ -38,16 +38,19 @@ export default class GeneralGoogleManager extends ApiManager { register({ method: Method.POST, - subscription: new RouteSubscriber("/googleDocs").add("sector", "action"), + subscription: new RouteSubscriber("googleDocs").add("sector", "action"), onValidation: async ({ req, res, user }) => { - let sector: GoogleApiServerUtils.Service = req.params.sector as GoogleApiServerUtils.Service; - let action: GoogleApiServerUtils.Action = req.params.action as GoogleApiServerUtils.Action; + const sector: GoogleApiServerUtils.Service = req.params.sector as GoogleApiServerUtils.Service; + const action: GoogleApiServerUtils.Action = req.params.action as GoogleApiServerUtils.Action; const endpoint = await GoogleApiServerUtils.GetEndpoint(GoogleApiServerUtils.Service[sector], user.id); - let handler = EndpointHandlerMap.get(action); + const handler = EndpointHandlerMap.get(action); if (endpoint && handler) { - handler(endpoint, req.body) - .then(response => res.send(response.data)) - .catch(exception => res.send(exception)); + try { + const response = await handler(endpoint, req.body); + res.send(response.data); + } catch (e) { + res.send(e); + } return; } res.send(undefined); |