@@ -20,6 +20,7 @@ import { generateRouteSchema } from './schemas/generator.js';
2020
2121import dns from 'dns' ;
2222import { createServer , IncomingMessage , ServerResponse , Server } from 'http' ;
23+ import { createServer as createServerHTTPS , ServerOptions as ServerHTTPSOptions } from 'https' ;
2324
2425type Middleware = ( flow : BareRequest ) => Promise < void > | void ;
2526type Handler < H extends { [ key : string ] : string | undefined } > = ( flow : BareRequest < H > ) => any ;
@@ -109,6 +110,10 @@ type BareOptions<A extends IP> = {
109110 * Enable Cors
110111 */
111112 cors ?: boolean | CorsOptions ;
113+ /**
114+ * Custom HTTPS options for the server
115+ */
116+ httpsOptions ?: ServerHTTPSOptions ;
112117} ;
113118
114119type ExtractRouteParams < T extends string > = T extends `${string } :${infer Param } /${infer Rest } `
@@ -162,7 +167,11 @@ export class BareServer<A extends IP> {
162167
163168 constructor ( private bareOptions : BareOptions < A > = { } ) {
164169 // init
165- this . server = createServer ( this . #listener. bind ( this ) ) ;
170+ if ( bareOptions . httpsOptions ) {
171+ this . server = createServerHTTPS ( bareOptions . httpsOptions , this . #onRequest) ;
172+ } else {
173+ this . server = createServer ( this . #onRequest) ;
174+ }
166175 this . attachGracefulHandlers ( ) ;
167176 this . attachRoutesDeclarator ( ) ;
168177 this . applyLaunchOptions ( ) ;
@@ -192,6 +201,7 @@ export class BareServer<A extends IP> {
192201 } ) ;
193202 } ;
194203
204+ #onRequest = this . #listener. bind ( this ) ;
195205 /**
196206 * This function generates previously defined middlewares for the sequential execution
197207 */
0 commit comments