File tree 4 files changed +239
-182
lines changed
4 files changed +239
-182
lines changed Original file line number Diff line number Diff line change 28
28
"reflect-metadata" : " ^0.1.12"
29
29
},
30
30
"dependencies" : {
31
- "@hapi/ joi" : " ^17.1.1 " ,
31
+ "joi" : " ^17.4.2 " ,
32
32
"@nestjs/common" : " ^8.0.0" ,
33
33
"@nestjs/swagger" : " ^5.0.0" ,
34
34
"express-basic-auth" : " ^1.2.0" ,
43
43
"@nestjs/testing" : " ^8.0.0" ,
44
44
"@types/express" : " ^4.17.8" ,
45
45
"@types/express-handlebars" : " ^3.1.0" ,
46
- "@types/hapi__joi " : " ^17.1.6 " ,
46
+ "@types/joi " : " ^17.2.3 " ,
47
47
"@types/jest" : " ^26.0.15" ,
48
48
"@types/node" : " ^14.14.6" ,
49
49
"@types/supertest" : " ^2.0.10" ,
Original file line number Diff line number Diff line change 1
- import Joi = require( '@hapi/ joi' ) ;
1
+ import Joi = require( 'joi' ) ;
2
2
import { OpenAPIObject } from '@nestjs/swagger' ;
3
3
4
4
export const schema = ( document : OpenAPIObject ) =>
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ import handlebars from 'express-handlebars';
7
7
import pathModule from 'path' ;
8
8
import { resolve } from 'url' ;
9
9
import { LogoOptions , RedocDocument , RedocOptions } from './interfaces' ;
10
- import { schema } from './model/options.model ' ;
10
+ import { schema } from './model' ;
11
11
12
12
export class RedocModule {
13
13
/**
@@ -121,10 +121,16 @@ export class RedocModule {
121
121
'views' ,
122
122
'redoc.handlebars'
123
123
) ;
124
+
124
125
// get handlebars rendered HTML
125
126
const redocHTML = await hbs . render ( redocFilePath , renderData ) ;
126
127
// Serve ReDoc Frontend
127
128
httpAdapter . get ( finalPath , async ( req : Request , res : Response ) => {
129
+ if ( ! req . url . endsWith ( '/' ) ) {
130
+ res . redirect ( 301 , req . url + '/' ) ;
131
+ return ;
132
+ }
133
+
128
134
const sendPage = ( ) => {
129
135
// Content-Security-Policy: worker-src 'self' blob:
130
136
res . setHeader (
@@ -147,6 +153,7 @@ export class RedocModule {
147
153
sendPage ( ) ;
148
154
}
149
155
} ) ;
156
+
150
157
// Serve swagger spec json
151
158
httpAdapter . get ( docUrl , ( req : Request , res : Response ) => {
152
159
res . setHeader ( 'Content-Type' , 'application/json' ) ;
You can’t perform that action at this time.
0 commit comments