@paralect/hive 0.0.25 → 0.0.28

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": "@paralect/hive",
3
- "version": "0.0.25",
3
+ "version": "0.0.28",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -23,6 +23,8 @@ if (process.env.HIVE_SRC) {
23
23
  const env = process.env.APP_ENV || "development";
24
24
 
25
25
  const config = {
26
+ _hive: {
27
+ },
26
28
  env,
27
29
  port: process.env.PORT || 3001,
28
30
  domain: env === 'production' ? 'https://api.yourapp.com': process.env.DOMAIN || '',
@@ -1,3 +1,4 @@
1
+ const config = require('app-config');
1
2
  const userService = require('db').services.users;
2
3
  const tokenService = require('db').services.tokens;
3
4
 
@@ -5,11 +6,15 @@ const storeTokenToState = async (ctx) => {
5
6
  let accessToken = ctx.cookies.get('access_token');
6
7
 
7
8
  const { authorization } = ctx.headers;
8
-
9
+
9
10
  if (!accessToken && authorization) {
10
11
  accessToken = authorization.replace('Bearer', '').trim();
11
12
  }
12
13
 
14
+ if (!accessToken && config._hive.authHeaderName && ctx.headers[config._hive.authHeaderName]) {
15
+ accessToken = ctx.headers[config._hive.authHeaderName];
16
+ }
17
+
13
18
  ctx.state.accessToken = accessToken;
14
19
  };
15
20
 
@@ -6,7 +6,7 @@ const users = Joi.object({
6
6
  updatedOn: Joi.date(),
7
7
 
8
8
  email: Joi.string().email().required(),
9
- username: Joi.string().required(),
9
+ username: Joi.string(),
10
10
  fullName: Joi.string(),
11
11
  avatarUrl: Joi.string().uri(),
12
12
 
@@ -13,7 +13,7 @@ const routeErrorHandler = async (ctx, next) => {
13
13
 
14
14
  logger.error(errors);
15
15
 
16
- if (serverError && process.env.APP_ENV === "production") {
16
+ if (serverError && (error.status === 500 || !error.status) && process.env.APP_ENV === "production") {
17
17
  serverError.global = "Something went wrong";
18
18
  }
19
19