1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | function normalizeAuth(config) {
|
4 | if (!config.jwt)
|
5 | config.jwt = {};
|
6 | if (typeof (process.env.JWT_HEADERFIELD) === 'string')
|
7 | config.jwt.headerField = process.env.JWT_HEADERFIELD;
|
8 | else if (!config.jwt.headerField)
|
9 | config.jwt.headerField = 'x-token';
|
10 | if (typeof (process.env.JWT_BODYFIELD) === 'string')
|
11 | config.jwt.bodyField = process.env.JWT_BODYFIELD;
|
12 | else if (!config.jwt.bodyField)
|
13 | config.jwt.bodyField = 'token';
|
14 | if (typeof (process.env.JWT_QUERYFIELD) === 'string')
|
15 | config.jwt.queryField = process.env.JWT_QUERYFIELD;
|
16 | else if (!config.jwt.queryField)
|
17 | config.jwt.queryField = 'token';
|
18 | if (typeof (process.env.JWT_SECRET) === 'string')
|
19 | config.jwt.secret = process.env.JWT_SECRET;
|
20 | else if (!config.jwt.secret)
|
21 | config.jwt.secret = 'secret';
|
22 | if (typeof (process.env.JWT_PATHS) === 'string')
|
23 | config.jwt.paths = process.env.JWT_PATHS.split(',');
|
24 | else if (!config.jwt.paths)
|
25 | config.jwt.paths = ['/web', '/api'];
|
26 | if (!config.swagger)
|
27 | config.swagger = {};
|
28 | if (typeof (process.env.SWAGGER_OUTPUTDIRS) === 'string')
|
29 | config.swagger.outputDirs = process.env.SWAGGER_OUTPUTDIRS.split(',');
|
30 | else if (!config.swagger.outputDirs)
|
31 | config.swagger.outputDirs = ['../swagger/output'];
|
32 | if (typeof (process.env.SWAGGER_BASEURL) === 'string')
|
33 | config.swagger.baseUrl = process.env.SWAGGER_BASEURL;
|
34 | else if (!config.swagger.baseUrl)
|
35 | config.swagger.baseUrl = '/swagger';
|
36 | else {
|
37 | if (config.swagger.baseUrl.endsWith('/')) {
|
38 | config.swagger.baseUrl = config.swagger.baseUrl.substr(0, config.swagger.baseUrl.length - 1);
|
39 | }
|
40 | }
|
41 | return config;
|
42 | }
|
43 | exports.normalizeAuth = normalizeAuth;
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
\ | No newline at end of file |