File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict'
2
+
3
+ const gateway = require ( './../index' )
4
+ const PORT = process . env . PORT || 4443
5
+ const https = require ( 'https' )
6
+ const pem = require ( 'pem' )
7
+
8
+ pem . createCertificate ( {
9
+ days : 1 ,
10
+ selfSigned : true
11
+ } , ( err , keys ) => {
12
+ if ( err ) console . error ( err )
13
+
14
+ gateway ( {
15
+ restana : {
16
+ server : https . createServer ( {
17
+ key : keys . serviceKey ,
18
+ cert : keys . certificate
19
+ } )
20
+ } ,
21
+ middlewares : [
22
+ ] ,
23
+
24
+ routes : [ {
25
+ prefix : '/api' ,
26
+ target : 'http://localhost:3000'
27
+ } ]
28
+ } ) . start ( PORT ) . then ( server => {
29
+ console . log ( `API Gateway listening on ${ PORT } port!` )
30
+ } )
31
+
32
+ const api = require ( 'restana' ) ( { } )
33
+ api . get ( '/ssl-protected' , ( req , res ) => {
34
+ res . send ( 'SSL Terminated!' )
35
+ } )
36
+
37
+ api . start ( 3000 ) . then ( ( ) => console . log ( 'API service listening on 3000 port!' ) )
38
+ } )
Original file line number Diff line number Diff line change 56
56
"mocha" : " ^8.4.0" ,
57
57
"nyc" : " ^15.1.0" ,
58
58
"opossum" : " ^6.1.0" ,
59
+ "pem" : " ^1.14.4" ,
59
60
"request-ip" : " ^2.1.3" ,
60
61
"response-time" : " ^2.3.2" ,
61
62
"supertest" : " ^6.1.3"
You can’t perform that action at this time.
0 commit comments