Skip to content

Commit f2f236a

Browse files
committed
Fix code style
1 parent f466923 commit f2f236a

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

‎JavaScript/client.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const UNIX_EPOCH = 'Thu, 01 Jan 1970 00:00:00 GMT';
66
const COOKIE_EXPIRE = 'Fri, 01 Jan 2100 00:00:00 GMT';
77
const COOKIE_DELETE = `=deleted; Expires=${UNIX_EPOCH}; Path=/; Domain=`;
88

9-
const parseHost = host => {
9+
const parseHost = (host) => {
1010
if (!host) return 'no-host-name-in-http-headers';
1111
const portOffset = host.indexOf(':');
1212
if (portOffset > -1) host = host.substr(0, portOffset);

‎JavaScript/server.js‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,28 @@ const Session = require('./session.js');
77

88
const 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

4141
const 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);

‎JavaScript/storage.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const v8 = require('v8');
66

77
const PATH = `${__dirname}/sessions`;
88

9-
const safePath = fn => (token, ...args) => {
9+
const safePath = (fn) => (token, ...args) => {
1010
const callback = args[args.length - 1];
1111
if (typeof token !== 'string') {
1212
callback(new Error('Invalid session token'));

0 commit comments

Comments
 (0)