@@ -7,28 +7,28 @@ const Session = require('./session.js');
77
88const routing = {
99 '/' : async ( ) => '<h1>welcome to homepage</h1><hr>' ,
10- '/start' : async client => {
10+ '/start' : async ( client ) => {
1111 Session . start ( client ) ;
1212 return `Session token is: ${ client . token } ` ;
1313 } ,
14- '/destroy' : async client => {
14+ '/destroy' : async ( client ) => {
1515 const result = `Session destroyed: ${ client . token } ` ;
1616 Session . delete ( client ) ;
1717 return result ;
1818 } ,
19- '/api/method1' : async client => {
19+ '/api/method1' : async ( client ) => {
2020 if ( client . session ) {
2121 client . session . set ( 'method1' , 'called' ) ;
2222 return { data : 'example result' } ;
2323 } else {
2424 return { data : 'access is denied' } ;
2525 }
2626 } ,
27- '/api/method2' : async client => ( {
27+ '/api/method2' : async ( client ) => ( {
2828 url : client . req . url ,
2929 headers : client . req . headers ,
3030 } ) ,
31- '/api/method3' : async client => {
31+ '/api/method3' : async ( client ) => {
3232 if ( client . session ) {
3333 return [ ...client . session . entries ( ) ]
3434 . map ( ( [ key , value ] ) => `<b>${ key } </b>: ${ value } <br>` )
@@ -40,8 +40,8 @@ const routing = {
4040
4141const types = {
4242 object : JSON . stringify ,
43- string : s => s ,
44- number : n => n . toString ( ) ,
43+ string : ( s ) => s ,
44+ number : ( n ) => n . toString ( ) ,
4545 undefined : ( ) => 'not found' ,
4646} ;
4747
@@ -58,13 +58,13 @@ http.createServer(async (req, res) => {
5858 res . end ( 'Not found 404' ) ;
5959 return ;
6060 }
61- handler ( client ) . then ( data => {
61+ handler ( client ) . then ( ( data ) => {
6262 const type = typeof data ;
6363 const serializer = types [ type ] ;
6464 const result = serializer ( data ) ;
6565 client . sendCookie ( ) ;
6666 res . end ( result ) ;
67- } , err => {
67+ } , ( err ) => {
6868 res . statusCode = 500 ;
6969 res . end ( 'Internal Server Error 500' ) ;
7070 console . log ( err ) ;
0 commit comments