File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ const server = require ( './server' ) ;
2+ const port = process . env . PORT || 3000 ;
3+
4+ server . listen ( port , function startServer ( ) {
5+ console . log (
6+ `Webservice is ready to start listening requests on http://localhost:${ port } `
7+ ) ;
8+ } ) ;
Original file line number Diff line number Diff line change 1+ const http = require ( 'http' ) ;
2+
3+ const server = http . createServer ( function getRequest ( request , response ) {
4+ if ( request . method !== 'POST' ) {
5+ response . statusCode = 405 ;
6+ return response . end ( ) ;
7+ }
8+
9+ request . setEncoding ( 'utf8' ) ;
10+
11+ let data = '' ;
12+
13+ request . on ( 'data' , function getData ( chunk ) {
14+ data += chunk ;
15+ } ) ;
16+
17+ request . on ( 'end' , function getServerResponse ( ) {
18+ console . log (
19+ `Writing the error in the stdout, waiting that an hipotetic tool like influxdb read the info and save it:
20+ ${ data }
21+ `
22+ ) ;
23+ response . statusCode = 201 ;
24+ response . end ( ) ;
25+ } ) ;
26+ } ) ;
27+
28+ module . exports = server ;
You can’t perform that action at this time.
0 commit comments