@lazyapps/express 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -27,6 +27,12 @@ export const adminHandler = (context) => (req, res) => {
27
27
  })
28
28
  .catch((err) => {
29
29
  log.error(`Error: ${err}`);
30
- res.sendStatus(500);
30
+ if (err.name === 'ValidationError') {
31
+ res.sendStatus(400);
32
+ } else if (err.name === 'AuthorizationError') {
33
+ res.sendStatus(403);
34
+ } else {
35
+ res.sendStatus(500);
36
+ }
31
37
  });
32
38
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lazyapps/express",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Express HTTP bindings for LazyApps command receiver, read model queries, and change notification listener",
5
5
  "main": "index.js",
6
6
  "files": [
@@ -28,6 +28,12 @@ export const createApiHandler =
28
28
  req.body,
29
29
  )}: ${err}`,
30
30
  );
31
- res.sendStatus(500);
31
+ if (err.name === 'ValidationError') {
32
+ res.sendStatus(400);
33
+ } else if (err.name === 'AuthorizationError') {
34
+ res.sendStatus(403);
35
+ } else {
36
+ res.sendStatus(500);
37
+ }
32
38
  });
33
39
  };