File tree Expand file tree Collapse file tree 2 files changed +3
-14
lines changed Expand file tree Collapse file tree 2 files changed +3
-14
lines changed Original file line number Diff line number Diff line change 3
3
const express = require ( "express" ) ;
4
4
const { Receiver } = require ( "cloudevents" ) ;
5
5
const app = express ( ) ;
6
-
7
- app . use ( ( req , res , next ) => {
8
- let data = "" ;
9
-
10
- req . setEncoding ( "utf8" ) ;
11
- req . on ( "data" , function ( chunk ) {
12
- data += chunk ;
13
- } ) ;
14
-
15
- req . on ( "end" , function ( ) {
16
- req . body = data ;
17
- next ( ) ;
18
- } ) ;
19
- } ) ;
6
+ const bodyParser = require ( 'body-parser' )
7
+ app . use ( bodyParser . json ( ) )
20
8
21
9
app . post ( "/" , ( req , res ) => {
22
10
console . log ( "HEADERS" , req . headers ) ;
Original file line number Diff line number Diff line change 14
14
"author" : " fabiojose@gmail.com" ,
15
15
"license" : " Apache-2.0" ,
16
16
"dependencies" : {
17
+ "body-parser" : " ^1.19.0" ,
17
18
"cloudevents" : " ^3.1.0" ,
18
19
"express" : " ^4.17.1"
19
20
}
You can’t perform that action at this time.
0 commit comments