UNPKG

1.8 kBJavaScriptView Raw
1"use strict";
2var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3 return new (P || (P = Promise))(function (resolve, reject) {
4 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6 function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
7 step((generator = generator.apply(thisArg, _arguments || [])).next());
8 });
9};
10Object.defineProperty(exports, "__esModule", { value: true });
11const config_1 = require("./config");
12const jwt_1 = require("./auth/jwt");
13const api_1 = require("./swagger/api");
14const config_2 = require("./swagger/config");
15/**
16 * Register JWT & Swagger routes
17 */
18function registerAuth(app, config, params, jwtIgnoreSwaggerUrl) {
19 return __awaiter(this, void 0, void 0, function* () {
20 // Normalize the config
21 config = config_1.normalizeAuth(config);
22 // register for JWT parser (every requests after this will need JWT auth header)
23 jwt_1.registerJwtInternal(app, config.jwt, (!jwtIgnoreSwaggerUrl || !config.swagger.baseUrl) ? params.jwtIgnoreUrls : !params.jwtIgnoreUrls ? [config.swagger.baseUrl] : params.jwtIgnoreUrls.concat([config.swagger.baseUrl]));
24 // Register Swagger API Routes
25 yield api_1.registerSwaggerApiInternal(app, config, params.swaggerBaseDir, config.swagger.outputDirs);
26 // Register Swagger API Routes
27 return config_2.registerSwaggerConfigInternal(app, config, params.swaggerBaseDir);
28 });
29}
30exports.registerAuth = registerAuth;
31//# sourceMappingURL=register.js.map
\No newline at end of file