@hvedinich/utils 0.0.52 → 0.0.54

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hvedinich/utils",
3
- "version": "0.0.52",
3
+ "version": "0.0.54",
4
4
  "description": "utils module",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -12,6 +12,15 @@ const guestCtx = {
12
12
  uid: 'guest-user',
13
13
  };
14
14
 
15
+ const healthCheckStatuses = {
16
+ INIT_VIBER_WEBHOOK: 'INIT_VIBER_WEBHOOK',
17
+ INIT_TELEGRAM_WEBHOOK: 'INIT_TELEGRAM_WEBHOOK',
18
+ SUBSCRIBE_MQ: 'SUBSCRIBE_MQ',
19
+ INIT_QUEUE: 'INIT_QUEUE',
20
+ TELEGRAM_HEALTH_CHECK: 'TELEGRAM_HEALTH_CHECK',
21
+ DB_CONNECT: 'DB_CONNECT',
22
+ };
23
+
15
24
  const auth = {
16
25
  permission: {
17
26
  SYSTEM_USER,
@@ -21,6 +30,7 @@ const auth = {
21
30
  };
22
31
 
23
32
  module.exports = {
33
+ healthCheckStatuses,
24
34
  serverCtx,
25
35
  guestCtx,
26
36
  token,
@@ -19,9 +19,9 @@ class ServerError extends Error {
19
19
 
20
20
  class Unauthorized extends ServerError {
21
21
  constructor({
22
- error, sanitized, ctx, message,
22
+ error, sanitized, ctx, message, code = 401,
23
23
  }) {
24
- super(ctx, 'Unauthorized', 401, error, sanitized, message);
24
+ super(ctx, 'Unauthorized', 401, error, sanitized, message, code);
25
25
  }
26
26
  }
27
27
 
@@ -0,0 +1,15 @@
1
+ const status = {
2
+ status: true,
3
+ };
4
+
5
+ const checkIsAlive = () => Object.values(status).every(e => e === true);
6
+
7
+ const setStatus = (key, value) => {
8
+ status[key] = !!value;
9
+ };
10
+
11
+ module.exports = {
12
+ checkIsAlive,
13
+ setStatus,
14
+ status,
15
+ };
@@ -5,6 +5,7 @@ const mappers = require('./mappers');
5
5
  const common = require('./common');
6
6
  const permission = require('./permission');
7
7
  const config = require('./config');
8
+ const healthCheck = require('./healthCheck');
8
9
 
9
10
  module.exports = {
10
11
  context,
@@ -14,4 +15,5 @@ module.exports = {
14
15
  permission,
15
16
  config,
16
17
  common,
18
+ healthCheck
17
19
  };