@flowerforce/flowerbase 1.6.2-beta.0 → 1.6.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 1.6.2 (2026-01-30)
2
+
3
+
4
+ ### 🩹 Fixes
5
+
6
+ - trigger auth check providers ([636809e](https://github.com/flowerforce/flowerbase/commit/636809e))
7
+
8
+ - check providers auth disabled ([85f3988](https://github.com/flowerforce/flowerbase/commit/85f3988))
9
+
10
+ - add env swagger enable ([0ca2a5a](https://github.com/flowerforce/flowerbase/commit/0ca2a5a))
11
+
1
12
  ## 1.6.1 (2026-01-30)
2
13
 
3
14
 
package/README.md CHANGED
@@ -92,8 +92,8 @@ Ensure the following environment variables are set in your .env file or deployme
92
92
  | ---------------------- | --------------------------------------------------------------------------- | -------------------------------------------------- |
93
93
  | `PROJECT_ID` | A unique ID to identify your project. This value can be freely invented — it's preserved mainly for compatibility with the old Realm-style project structure. | `my-flowerbase-app` |
94
94
  | `PORT` | The port on which the server will run. | `3000` |
95
- | `DB_CONNECTION_STRING` | MongoDB connection URI, including username, password, and database name. | `mongodb+srv://user:pass@cluster.mongodb.net/mydb` |
96
- | `APP_SECRET` | Secret used to sign and verify JWT tokens (choose a strong secret). | `supersecretkey123!` |
95
+ | `MONGODB_URL` | MongoDB connection URI, including username, password, and database name. | `mongodb+srv://user:pass@cluster.mongodb.net/mydb` |
96
+ | `JWT_SECRET` | Secret used to sign and verify JWT tokens (choose a strong secret). | `supersecretkey123!` |
97
97
  | `HOST` | The host address the server binds to (usually `0.0.0.0` for public access). | `0.0.0.0` |
98
98
  | `HTTPS_SCHEMA` | The schema for your server requests (usually `https` or `http`). | `http` |
99
99
  | `RESET_PASSWORD_TTL_SECONDS` | Time-to-live for password reset tokens (in seconds). | `3600` |
@@ -101,6 +101,7 @@ Ensure the following environment variables are set in your .env file or deployme
101
101
  | `AUTH_LOGIN_MAX_ATTEMPTS` | Max login attempts per window. | `10` |
102
102
  | `AUTH_RESET_MAX_ATTEMPTS` | Max reset requests per window. | `5` |
103
103
  | `REFRESH_TOKEN_TTL_DAYS` | Refresh token time-to-live (in days). | `60` |
104
+ | `SWAGGER_ENABLED` | Enable Swagger UI and spec routes (disabled by default). | `true` |
104
105
  | `SWAGGER_UI_USER` | Basic Auth username for Swagger UI (optional). | `admin` |
105
106
  | `SWAGGER_UI_PASSWORD` | Basic Auth password for Swagger UI (optional). | `change-me` |
106
107
 
@@ -109,8 +110,8 @@ Example:
109
110
  ```env
110
111
  PROJECT_ID=your-project-id
111
112
  PORT=3000
112
- DB_CONNECTION_STRING=mongodb+srv://username:password@cluster.mongodb.net/dbname
113
- APP_SECRET=your-jwt-secret
113
+ MONGODB_URL=mongodb+srv://username:password@cluster.mongodb.net/dbname
114
+ JWT_SECRET=your-jwt-secret
114
115
  HOST=0.0.0.0
115
116
  HTTPS_SCHEMA=http
116
117
  RESET_PASSWORD_TTL_SECONDS=3600
@@ -118,6 +119,7 @@ AUTH_RATE_LIMIT_WINDOW_MS=900000
118
119
  AUTH_LOGIN_MAX_ATTEMPTS=10
119
120
  AUTH_RESET_MAX_ATTEMPTS=5
120
121
  REFRESH_TOKEN_TTL_DAYS=60
122
+ SWAGGER_ENABLED=true
121
123
  SWAGGER_UI_USER=admin
122
124
  SWAGGER_UI_PASSWORD=change-me
123
125
  ```
@@ -134,8 +136,8 @@ import { initialize } from '@flowerforce/flowerbase';
134
136
 
135
137
  const projectId = process.env.PROJECT_ID ?? "my-project-id"
136
138
  const port = process.env.PORT ? Number(process.env.PORT) : undefined
137
- const mongodbUrl = process.env.DB_CONNECTION_STRING
138
- const jwtSecret = process.env.APP_SECRET
139
+ const mongodbUrl = process.env.MONGODB_URL
140
+ const jwtSecret = process.env.JWT_SECRET
139
141
  const host = process.env.HOST
140
142
 
141
143
  initialize({
@@ -401,8 +403,8 @@ import { initialize } from '@flowerforce/flowerbase';
401
403
 
402
404
  const projectId = process.env.PROJECT_ID ?? "my-project-id"
403
405
  const port = process.env.PORT ? Number(process.env.PORT) : undefined
404
- const mongodbUrl = process.env.DB_CONNECTION_STRING
405
- const jwtSecret = process.env.APP_SECRET
406
+ const mongodbUrl = process.env.MONGODB_URL
407
+ const jwtSecret = process.env.JWT_SECRET
406
408
  const host = process.env.HOST
407
409
 
408
410
  initialize({
@@ -422,8 +424,8 @@ Ensure the following environment variables are set in your .env file or deployme
422
424
  | ---------------------- | --------------------------------------------------------------------------- | -------------------------------------------------- |
423
425
  | `PROJECT_ID` | A unique ID to identify your project. This value can be freely invented — it's preserved mainly for compatibility with the old Realm-style project structure. | `my-flowerbase-app` |
424
426
  | `PORT` | The port on which the server will run. | `3000` |
425
- | `DB_CONNECTION_STRING` | MongoDB connection URI, including username, password, and database name. | `mongodb+srv://user:pass@cluster.mongodb.net/mydb` |
426
- | `APP_SECRET` | Secret used to sign and verify JWT tokens (choose a strong secret). | `supersecretkey123!` |
427
+ | `MONGODB_URL` | MongoDB connection URI, including username, password, and database name. | `mongodb+srv://user:pass@cluster.mongodb.net/mydb` |
428
+ | `JWT_SECRET` | Secret used to sign and verify JWT tokens (choose a strong secret). | `supersecretkey123!` |
427
429
  | `HOST` | The host address the server binds to (usually `0.0.0.0` for public access). | `0.0.0.0` |
428
430
  | `HTTPS_SCHEMA` | The schema for your server requests (usually `https` or `http`). | `http` |
429
431
  | `RESET_PASSWORD_TTL_SECONDS` | Time-to-live for password reset tokens (in seconds). | `3600` |
@@ -431,6 +433,7 @@ Ensure the following environment variables are set in your .env file or deployme
431
433
  | `AUTH_LOGIN_MAX_ATTEMPTS` | Max login attempts per window. | `10` |
432
434
  | `AUTH_RESET_MAX_ATTEMPTS` | Max reset requests per window. | `5` |
433
435
  | `REFRESH_TOKEN_TTL_DAYS` | Refresh token time-to-live (in days). | `60` |
436
+ | `SWAGGER_ENABLED` | Enable Swagger UI and spec routes (disabled by default). | `true` |
434
437
  | `SWAGGER_UI_USER` | Basic Auth username for Swagger UI (optional). | `admin` |
435
438
  | `SWAGGER_UI_PASSWORD` | Basic Auth password for Swagger UI (optional). | `change-me` |
436
439
 
@@ -439,8 +442,8 @@ Example:
439
442
  ```env
440
443
  PROJECT_ID=your-project-id
441
444
  PORT=3000
442
- DB_CONNECTION_STRING=mongodb+srv://username:password@cluster.mongodb.net/dbname
443
- APP_SECRET=your-jwt-secret
445
+ MONGODB_URL=mongodb+srv://username:password@cluster.mongodb.net/dbname
446
+ JWT_SECRET=your-jwt-secret
444
447
  HOST=0.0.0.0
445
448
  HTTPS_SCHEMA=http
446
449
  RESET_PASSWORD_TTL_SECONDS=3600
@@ -448,6 +451,7 @@ AUTH_RATE_LIMIT_WINDOW_MS=900000
448
451
  AUTH_LOGIN_MAX_ATTEMPTS=10
449
452
  AUTH_RESET_MAX_ATTEMPTS=5
450
453
  REFRESH_TOKEN_TTL_DAYS=60
454
+ SWAGGER_ENABLED=true
451
455
  SWAGGER_UI_USER=admin
452
456
  SWAGGER_UI_PASSWORD=change-me
453
457
  ```
@@ -14,6 +14,7 @@ export declare const DEFAULT_CONFIG: {
14
14
  AUTH_RESET_MAX_ATTEMPTS: number;
15
15
  REFRESH_TOKEN_TTL_DAYS: number;
16
16
  ANON_USER_TTL_SECONDS: number;
17
+ SWAGGER_ENABLED: boolean;
17
18
  SWAGGER_UI_USER: string;
18
19
  SWAGGER_UI_PASSWORD: string;
19
20
  CORS_OPTIONS: {
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAA;AAUpC,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;iBAmBsB,eAAe,EAAE;;CAEjE,CAAA;AACD,eAAO,MAAM,WAAW,QAA8C,CAAA;AACtE,eAAO,MAAM,YAAY,QAA8B,CAAA;AACvD,eAAO,MAAM,OAAO,QAAgB,CAAA;AAEpC,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAAA;AAE7E,eAAO,MAAM,WAAW;;;;;;;mBAOqB,aAAa;;;;;;;;;CAOzD,CAAA;AAID,eAAO,MAAM,SAAS;;;CAGrB,CAAA"}
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAA;AAepC,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;iBAoBsB,eAAe,EAAE;;CAEjE,CAAA;AACD,eAAO,MAAM,WAAW,QAA8C,CAAA;AACtE,eAAO,MAAM,YAAY,QAA8B,CAAA;AACvD,eAAO,MAAM,OAAO,QAAgB,CAAA;AAEpC,KAAK,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAAA;AAE7E,eAAO,MAAM,WAAW;;;;;;;mBAOqB,aAAa;;;;;;;;;CAOzD,CAAA;AAID,eAAO,MAAM,SAAS;;;CAGrB,CAAA"}
package/dist/constants.js CHANGED
@@ -14,6 +14,11 @@ var _a, _b, _c;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.S3_CONFIG = exports.AUTH_CONFIG = exports.DB_NAME = exports.HTTPS_SCHEMA = exports.API_VERSION = exports.DEFAULT_CONFIG = void 0;
16
16
  const utils_1 = require("./auth/utils");
17
+ const parseBoolean = (value) => {
18
+ if (!value)
19
+ return false;
20
+ return ['1', 'true', 'yes', 'on'].includes(value.toLowerCase());
21
+ };
17
22
  const { database_name, collection_name = 'users', user_id_field = 'id', on_user_creation_function_name } = (0, utils_1.loadCustomUserData)();
18
23
  const _d = (0, utils_1.loadAuthConfig)(), { auth_collection = 'auth_users' } = _d, configuration = __rest(_d, ["auth_collection"]);
19
24
  exports.DEFAULT_CONFIG = {
@@ -31,6 +36,7 @@ exports.DEFAULT_CONFIG = {
31
36
  AUTH_RESET_MAX_ATTEMPTS: Number(process.env.AUTH_RESET_MAX_ATTEMPTS) || 5,
32
37
  REFRESH_TOKEN_TTL_DAYS: Number(process.env.REFRESH_TOKEN_TTL_DAYS) || 60,
33
38
  ANON_USER_TTL_SECONDS: Number(process.env.ANON_USER_TTL_SECONDS) || 3 * 60 * 60,
39
+ SWAGGER_ENABLED: parseBoolean(process.env.SWAGGER_ENABLED),
34
40
  SWAGGER_UI_USER: process.env.SWAGGER_UI_USER || '',
35
41
  SWAGGER_UI_PASSWORD: process.env.SWAGGER_UI_PASSWORD || '',
36
42
  CORS_OPTIONS: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;AActB,cAAc,SAAS,CAAA;AAGvB,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAA;AAE/D,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,eAAe,EAAE,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAAC,EAC/B,SAAS,EACT,IAA0B,EAC1B,SAAqC,EACrC,IAA0B,EAC1B,UAAuC,EACvC,UAAwC,EACxC,QAAQ,EACT,EAAE,gBAAgB,iBA6GlB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAA;AActB,cAAc,SAAS,CAAA;AAGvB,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAA;AAE/D,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,eAAe,EAAE,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;;;;;;GAOG;AACH,wBAAsB,UAAU,CAAC,EAC/B,SAAS,EACT,IAA0B,EAC1B,SAAqC,EACrC,IAA0B,EAC1B,UAAuC,EACvC,UAAwC,EACxC,QAAQ,EACT,EAAE,gBAAgB,iBA+GlB"}
package/dist/index.js CHANGED
@@ -108,48 +108,50 @@ function initialize(_a) {
108
108
  services: services_1.services
109
109
  };
110
110
  Object.entries(stateConfig).forEach(([key, value]) => state_1.StateManager.setData(key, value));
111
- yield fastify.register(Promise.resolve().then(() => __importStar(require('@fastify/swagger'))));
112
- yield fastify.register(Promise.resolve().then(() => __importStar(require('@fastify/swagger-ui'))), {
113
- routePrefix: '/documentation',
114
- uiConfig: {
115
- docExpansion: 'full',
116
- deepLinking: false
117
- },
118
- uiHooks: {
119
- onRequest: function (request, reply, next) {
120
- const swaggerUser = constants_1.DEFAULT_CONFIG.SWAGGER_UI_USER;
121
- const swaggerPassword = constants_1.DEFAULT_CONFIG.SWAGGER_UI_PASSWORD;
122
- if (!swaggerUser && !swaggerPassword) {
111
+ if (constants_1.DEFAULT_CONFIG.SWAGGER_ENABLED) {
112
+ yield fastify.register(Promise.resolve().then(() => __importStar(require('@fastify/swagger'))));
113
+ yield fastify.register(Promise.resolve().then(() => __importStar(require('@fastify/swagger-ui'))), {
114
+ routePrefix: '/documentation',
115
+ uiConfig: {
116
+ docExpansion: 'full',
117
+ deepLinking: false
118
+ },
119
+ uiHooks: {
120
+ onRequest: function (request, reply, next) {
121
+ const swaggerUser = constants_1.DEFAULT_CONFIG.SWAGGER_UI_USER;
122
+ const swaggerPassword = constants_1.DEFAULT_CONFIG.SWAGGER_UI_PASSWORD;
123
+ if (!swaggerUser && !swaggerPassword) {
124
+ next();
125
+ return;
126
+ }
127
+ const authHeader = request.headers.authorization;
128
+ if (!authHeader || !authHeader.startsWith('Basic ')) {
129
+ reply
130
+ .code(401)
131
+ .header('WWW-Authenticate', 'Basic realm="Swagger UI"')
132
+ .send({ message: 'Unauthorized' });
133
+ return;
134
+ }
135
+ const encoded = authHeader.slice('Basic '.length);
136
+ const decoded = Buffer.from(encoded, 'base64').toString('utf8');
137
+ const [user, pass] = decoded.split(':');
138
+ if (user !== swaggerUser || pass !== swaggerPassword) {
139
+ reply
140
+ .code(401)
141
+ .header('WWW-Authenticate', 'Basic realm="Swagger UI"')
142
+ .send({ message: 'Unauthorized' });
143
+ return;
144
+ }
123
145
  next();
124
- return;
125
- }
126
- const authHeader = request.headers.authorization;
127
- if (!authHeader || !authHeader.startsWith('Basic ')) {
128
- reply
129
- .code(401)
130
- .header('WWW-Authenticate', 'Basic realm="Swagger UI"')
131
- .send({ message: 'Unauthorized' });
132
- return;
133
- }
134
- const encoded = authHeader.slice('Basic '.length);
135
- const decoded = Buffer.from(encoded, 'base64').toString('utf8');
136
- const [user, pass] = decoded.split(':');
137
- if (user !== swaggerUser || pass !== swaggerPassword) {
138
- reply
139
- .code(401)
140
- .header('WWW-Authenticate', 'Basic realm="Swagger UI"')
141
- .send({ message: 'Unauthorized' });
142
- return;
143
- }
144
- next();
146
+ },
147
+ preHandler: function (request, reply, next) { next(); }
145
148
  },
146
- preHandler: function (request, reply, next) { next(); }
147
- },
148
- staticCSP: true,
149
- transformStaticCSP: (header) => header,
150
- transformSpecification: (swaggerObject) => { return swaggerObject; },
151
- transformSpecificationClone: true
152
- });
149
+ staticCSP: true,
150
+ transformStaticCSP: (header) => header,
151
+ transformSpecification: (swaggerObject) => { return swaggerObject; },
152
+ transformSpecificationClone: true
153
+ });
154
+ }
153
155
  yield (0, registerPlugins_1.registerPlugins)({
154
156
  register: fastify.register,
155
157
  mongodbUrl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowerforce/flowerbase",
3
- "version": "1.6.2-beta.0",
3
+ "version": "1.6.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/constants.ts CHANGED
@@ -1,6 +1,11 @@
1
1
  import { loadAuthConfig, loadCustomUserData } from './auth/utils'
2
2
  import { ALLOWED_METHODS } from './'
3
3
 
4
+ const parseBoolean = (value?: string) => {
5
+ if (!value) return false
6
+ return ['1', 'true', 'yes', 'on'].includes(value.toLowerCase())
7
+ }
8
+
4
9
  const {
5
10
  database_name,
6
11
  collection_name = 'users',
@@ -24,6 +29,7 @@ export const DEFAULT_CONFIG = {
24
29
  AUTH_RESET_MAX_ATTEMPTS: Number(process.env.AUTH_RESET_MAX_ATTEMPTS) || 5,
25
30
  REFRESH_TOKEN_TTL_DAYS: Number(process.env.REFRESH_TOKEN_TTL_DAYS) || 60,
26
31
  ANON_USER_TTL_SECONDS: Number(process.env.ANON_USER_TTL_SECONDS) || 3 * 60 * 60,
32
+ SWAGGER_ENABLED: parseBoolean(process.env.SWAGGER_ENABLED),
27
33
  SWAGGER_UI_USER: process.env.SWAGGER_UI_USER || '',
28
34
  SWAGGER_UI_PASSWORD: process.env.SWAGGER_UI_PASSWORD || '',
29
35
  CORS_OPTIONS: {
package/src/index.ts CHANGED
@@ -91,49 +91,51 @@ export async function initialize({
91
91
  StateManager.setData(key as Parameters<typeof StateManager.setData>[0], value)
92
92
  )
93
93
 
94
- await fastify.register(import('@fastify/swagger'))
95
-
96
- await fastify.register(import('@fastify/swagger-ui'), {
97
- routePrefix: '/documentation',
98
- uiConfig: {
99
- docExpansion: 'full',
100
- deepLinking: false
101
- },
102
- uiHooks: {
103
- onRequest: function (request, reply, next) {
104
- const swaggerUser = DEFAULT_CONFIG.SWAGGER_UI_USER
105
- const swaggerPassword = DEFAULT_CONFIG.SWAGGER_UI_PASSWORD
106
- if (!swaggerUser && !swaggerPassword) {
94
+ if (DEFAULT_CONFIG.SWAGGER_ENABLED) {
95
+ await fastify.register(import('@fastify/swagger'))
96
+
97
+ await fastify.register(import('@fastify/swagger-ui'), {
98
+ routePrefix: '/documentation',
99
+ uiConfig: {
100
+ docExpansion: 'full',
101
+ deepLinking: false
102
+ },
103
+ uiHooks: {
104
+ onRequest: function (request, reply, next) {
105
+ const swaggerUser = DEFAULT_CONFIG.SWAGGER_UI_USER
106
+ const swaggerPassword = DEFAULT_CONFIG.SWAGGER_UI_PASSWORD
107
+ if (!swaggerUser && !swaggerPassword) {
108
+ next()
109
+ return
110
+ }
111
+ const authHeader = request.headers.authorization
112
+ if (!authHeader || !authHeader.startsWith('Basic ')) {
113
+ reply
114
+ .code(401)
115
+ .header('WWW-Authenticate', 'Basic realm="Swagger UI"')
116
+ .send({ message: 'Unauthorized' })
117
+ return
118
+ }
119
+ const encoded = authHeader.slice('Basic '.length)
120
+ const decoded = Buffer.from(encoded, 'base64').toString('utf8')
121
+ const [user, pass] = decoded.split(':')
122
+ if (user !== swaggerUser || pass !== swaggerPassword) {
123
+ reply
124
+ .code(401)
125
+ .header('WWW-Authenticate', 'Basic realm="Swagger UI"')
126
+ .send({ message: 'Unauthorized' })
127
+ return
128
+ }
107
129
  next()
108
- return
109
- }
110
- const authHeader = request.headers.authorization
111
- if (!authHeader || !authHeader.startsWith('Basic ')) {
112
- reply
113
- .code(401)
114
- .header('WWW-Authenticate', 'Basic realm="Swagger UI"')
115
- .send({ message: 'Unauthorized' })
116
- return
117
- }
118
- const encoded = authHeader.slice('Basic '.length)
119
- const decoded = Buffer.from(encoded, 'base64').toString('utf8')
120
- const [user, pass] = decoded.split(':')
121
- if (user !== swaggerUser || pass !== swaggerPassword) {
122
- reply
123
- .code(401)
124
- .header('WWW-Authenticate', 'Basic realm="Swagger UI"')
125
- .send({ message: 'Unauthorized' })
126
- return
127
- }
128
- next()
130
+ },
131
+ preHandler: function (request, reply, next) { next() }
129
132
  },
130
- preHandler: function (request, reply, next) { next() }
131
- },
132
- staticCSP: true,
133
- transformStaticCSP: (header) => header,
134
- transformSpecification: (swaggerObject,) => { return swaggerObject },
135
- transformSpecificationClone: true
136
- })
133
+ staticCSP: true,
134
+ transformStaticCSP: (header) => header,
135
+ transformSpecification: (swaggerObject,) => { return swaggerObject },
136
+ transformSpecificationClone: true
137
+ })
138
+ }
137
139
 
138
140
  await registerPlugins({
139
141
  register: fastify.register,