@@ -3,7 +3,6 @@ var bodyParser = require("body-parser");
3
3
var expressLogging = require ( "express-logging" ) ;
4
4
var queryString = require ( "querystring" ) ;
5
5
var path = require ( "path" ) ;
6
- var base64 = require ( "base-64" ) ;
7
6
var conf = require ( "./config" ) ;
8
7
9
8
function handleErr ( err , response ) {
@@ -26,7 +25,7 @@ function createCallback(response) {
26
25
}
27
26
response . write (
28
27
lambdaResponse . isBase64Encoded
29
- ? base64 . decode ( lambdaResponse . body )
28
+ ? Buffer . from ( lambdaResponse . body , "base64" )
30
29
: lambdaResponse . body
31
30
) ;
32
31
response . end ( ) ;
@@ -35,8 +34,8 @@ function createCallback(response) {
35
34
36
35
function promiseCallback ( promise , callback ) {
37
36
if ( ! promise ) return ;
38
- if ( typeof promise . then !== ' function' ) return ;
39
- if ( typeof callback !== ' function' ) return ;
37
+ if ( typeof promise . then !== " function" ) return ;
38
+ if ( typeof callback !== " function" ) return ;
40
39
41
40
promise . then (
42
41
function ( data ) { callback ( null , data ) } ,
@@ -47,7 +46,7 @@ function promiseCallback(promise, callback) {
47
46
function createHandler ( dir , static ) {
48
47
return function ( request , response ) {
49
48
// handle proxies without path re-writes (http-servr)
50
- var cleanPath = request . path . replace ( / ^ \/ .n e t l i f y \/ f u n c t i o n s / , '' )
49
+ var cleanPath = request . path . replace ( / ^ \/ .n e t l i f y \/ f u n c t i o n s / , "" )
51
50
52
51
var func = cleanPath . split ( "/" ) . filter ( function ( e ) {
53
52
return e ;
@@ -72,7 +71,7 @@ function createHandler(dir, static) {
72
71
httpMethod : request . method ,
73
72
queryStringParameters : queryString . parse ( request . url . split ( "?" ) [ 1 ] ) ,
74
73
headers : request . headers ,
75
- body : isBase64 ? base64 . encode ( request . body ) : request . body ,
74
+ body : isBase64 ? Buffer . from ( request . body . toString ( ) , "utf8" ) . toString ( "base64" ) : request . body ,
76
75
isBase64Encoded : isBase64
77
76
} ;
78
77
@@ -89,7 +88,7 @@ exports.listen = function(port, static) {
89
88
app . use ( bodyParser . raw ( { limit : "6mb" } ) ) ;
90
89
app . use ( bodyParser . text ( { limit : "6mb" , type : "*/*" } ) ) ;
91
90
app . use ( expressLogging ( console , {
92
- blacklist : [ ' /favicon.ico' ] ,
91
+ blacklist : [ " /favicon.ico" ] ,
93
92
} ) ) ;
94
93
95
94
app . get ( "/favicon.ico" , function ( req , res ) {
0 commit comments