File tree Expand file tree Collapse file tree 7 files changed +207
-1
lines changed
servers/express-body-parser Expand file tree Collapse file tree 7 files changed +207
-1
lines changed Original file line number Diff line number Diff line change 44 "exports" : {
55 "./get-basic-paths" : " ./get-basic-paths.mjs" ,
66 "./get-slash" : " ./get-slash.mjs" ,
7- "./get-query" : " ./get-query.mjs"
7+ "./get-query" : " ./get-query.mjs" ,
8+ "./post-json" : " ./post-json.mjs"
89 },
910 "scripts" : {
1011 "test" : " echo \" Error: no test specified\" && exit 1" ,
Original file line number Diff line number Diff line change 1+ export default [
2+ {
3+ method : 'POST' ,
4+ path : '/json' ,
5+ headers : {
6+ 'content-type' : 'application/json'
7+ } ,
8+ // small json body
9+ body : JSON . stringify ( {
10+ small : 'json body'
11+ } )
12+ } ,
13+
14+ {
15+ method : 'POST' ,
16+ path : '/json' ,
17+ headers : {
18+ 'content-type' : 'application/json'
19+ } ,
20+ // medium json body
21+ // (yes I stole this from the first google result for "example json payload")
22+ body : JSON . stringify ( {
23+ rowset : {
24+ coldesc : [ {
25+ type : 'string' ,
26+ name : 'Identifier'
27+ } , {
28+ type : 'string' ,
29+ name : 'Node'
30+ } , {
31+ type : 'string' ,
32+ name : 'Manager'
33+ } , {
34+ type : 'string' ,
35+ name : 'Agent'
36+ } , {
37+ type : 'string' ,
38+ name : 'AlertKey'
39+ } , {
40+ type : 'integer' ,
41+ name : 'Severity'
42+ } , {
43+ type : 'integer' ,
44+ name : 'Type'
45+ } , {
46+ type : 'string' ,
47+ name : 'Summary'
48+ } , {
49+ type : 'integer' ,
50+ name : 'Acknowledged'
51+ } , {
52+ type : 'string' ,
53+ name : 'Location'
54+ } , {
55+ type : 'utc' ,
56+ name : 'FirstOccurrence'
57+ } , {
58+ type : 'utc' ,
59+ name : 'LastOccurrence'
60+ } , {
61+ type : 'integer' ,
62+ name : 'OwnerUID'
63+ } , {
64+ type : 'integer' ,
65+ name : 'OwnerGID'
66+ } ] ,
67+ rows : [ {
68+ FirstOccurrence : 1341412087 ,
69+ Node : 'localhost' ,
70+ AlertKey : 'JUnitEventInstance' ,
71+ Agent : 'createEventNew()' ,
72+ Summary : 'This is a test event generated by the JUnit REST Event Tests.(0)' ,
73+ LastOccurrence : 1341412087 ,
74+ Acknowledged : 0 ,
75+ Identifier : 'JUnitEventTestInstance####0' ,
76+ Manager : 'com.ibm.netcool.omnibus.ws.junit.rest.schema.utils.TableRowEvent' ,
77+ OwnerGID : 0 ,
78+ Location : 'NOT UPDATED' ,
79+ Type : 1 ,
80+ Severity : 4 ,
81+ OwnerUID : 0
82+ } ] ,
83+ affectedRows : 0
84+ }
85+ } )
86+ } ,
87+
88+ {
89+ method : 'POST' ,
90+ path : '/json' ,
91+ headers : {
92+ 'content-type' : 'application/json'
93+ } ,
94+ // large json body
95+ body : JSON . stringify ( ( ( ) => {
96+ const body = { } ;
97+ for ( let i = 0 ; i ++ ; i < 1000 ) {
98+ body [ `${ i } k` ] = { [ i ] : 'v' . repeat ( i ) } ;
99+ }
100+ return body ;
101+ } ) ( ) )
102+ }
103+ ] ;
Original file line number Diff line number Diff line change 1+ export async function requests ( ) {
2+ return ( await import ( '@expressjs/perf-requests/post-json' ) ) . default ;
3+ }
4+
5+ export function server ( ) {
6+ return import ( '@expressjs/perf-servers-express-body-parser' ) ;
7+ }
8+
9+ if ( import . meta. main || import . meta. filename === process . argv [ 1 ] ) {
10+ await server ( ) ;
11+ }
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " @expressjs/perf-load-body-parser" ,
3+ "version" : " 1.0.0" ,
4+ "main" : " index.mjs" ,
5+ "scripts" : {
6+ "setup" : " npm i --no-workspaces --install-links"
7+ },
8+ "keywords" : [],
9+ "author" : " " ,
10+ "license" : " ISC" ,
11+ "description" : " " ,
12+ "dependencies" : {
13+ "@expressjs/perf-requests" : " file:../../../packages/requests" ,
14+ "@expressjs/perf-servers-express-helloworld" : " file:../../../servers/express-helloworld"
15+ }
16+ }
Original file line number Diff line number Diff line change 1+ const start = process . hrtime ( ) ;
2+ const express = require ( 'express' ) ;
3+ const expressVersion = require ( 'express/package.json' ) . version ;
4+
5+ const app = express ( ) ;
6+ app . use ( express . json ( ) ) ;
7+ app . use ( express . urlencoded ( ) ) ;
8+ app . use ( express . text ( ) ) ;
9+ app . use ( express . raw ( ) ) ;
10+ app . post ( expressVersion . startsWith ( '4.' ) ? '*' : '*path' , ( req , res ) => {
11+ res . status ( 200 ) . json ( {
12+ hello : 'body!' ,
13+ url : req . url ,
14+ headers : req . headers ,
15+ body : req . body
16+ } ) ;
17+ } ) ;
18+ app . use ( ( req , res ) => {
19+ console . log ( '404:' , req . url . toString ( ) ) ;
20+ res . status ( 404 ) . json ( {
21+ what : 'world?' ,
22+ url : req . url ,
23+ headers : req . headers ,
24+ query : req . query
25+ } ) ;
26+ } ) ;
27+ app . use ( ( err , req , res ) => {
28+ console . log ( err ) ;
29+ console . log ( '500:' , req . url . toString ( ) ) ;
30+ res . status ( 500 ) . json ( {
31+ goodbye : 'cruel world!' ,
32+ url : req . url ,
33+ headers : req . headers ,
34+ query : req . query
35+ } ) ;
36+ } ) ;
37+
38+ app . listen ( process . env . PORT || 3000 , ( ) => {
39+ console . log ( `startup: ${ process . hrtime ( start ) } ` ) ;
40+ } ) ;
Original file line number Diff line number Diff line change 1+ {
2+ "name" : " @expressjs/perf-servers-express-body-parser" ,
3+ "version" : " 1.0.0" ,
4+ "main" : " index.js" ,
5+ "scripts" : {
6+ "setup" : " npm i"
7+ },
8+ "dependencies" : {
9+ "express" : " ^5.1.0"
10+ }
11+ }
You can’t perform that action at this time.
0 commit comments