1414
1515import { restify_5 } from '../../src/plugins/types' ;
1616
17- import {
18- WebFramework ,
19- WebFrameworkAddHandlerOptions ,
20- WebFrameworkResponse ,
21- } from './base' ;
17+ import { WebFramework , WebFrameworkAddHandlerOptions } from './base' ;
2218
2319export class Restify implements WebFramework {
2420 server : restify_5 . Server ;
@@ -35,31 +31,24 @@ export class Restify implements WebFramework {
3531 ) ;
3632 }
3733 if ( options . hasResponse ) {
38- this . server . get ( options . path , async ( req , res , next ) => {
39- let response : WebFrameworkResponse ;
40- try {
41- response = await options . fn ( req . headers ) ;
42- } catch ( e ) {
43- next ( e ) ;
44- return ;
45- }
46- res . statusCode = response . statusCode ;
47- res . end ( response . message ) ;
48- next ( ) ;
34+ this . server . get ( options . path , ( req , res , next ) => {
35+ Promise . resolve ( )
36+ . then ( ( ) => options . fn ( req . headers ) )
37+ . then ( response => {
38+ res . statusCode = response . statusCode ;
39+ res . end ( response . message ) ;
40+ } )
41+ . then ( ( ) => next ( ) , next ) ;
4942 } ) ;
5043 } else {
51- this . server . use ( async ( req , res , next ) => {
44+ this . server . use ( ( req , res , next ) => {
5245 if ( req . getPath ( ) !== options . path ) {
5346 next ( ) ;
5447 return ;
5548 }
56- try {
57- await options . fn ( req . headers ) ;
58- } catch ( e ) {
59- next ( e ) ;
60- return ;
61- }
62- next ( ) ;
49+ Promise . resolve ( )
50+ . then ( ( ) => options . fn ( req . headers ) )
51+ . then ( ( ) => next ( ) , next ) ;
6352 } ) ;
6453 }
6554 }
@@ -91,3 +80,6 @@ export const Restify5 = makeRestifyClass(5);
9180export const Restify6 = makeRestifyClass ( 6 ) ;
9281export const Restify7 = makeRestifyClass ( 7 ) ;
9382export const Restify8 = makeRestifyClass ( 8 ) ;
83+ export const Restify9 = makeRestifyClass ( 9 , '>12' ) ;
84+ export const Restify10 = makeRestifyClass ( 10 , '>12' ) ;
85+ export const Restify11 = makeRestifyClass ( 11 , '>12' ) ;
0 commit comments