Skip to content

Commit b07c96c

Browse files
committed
linter changes
1 parent 85a6939 commit b07c96c

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

JavaScript/c-commonjs/db.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ const pg = require('pg');
44

55
let pool = null;
66

7-
const init = options => {
7+
const init = (options) => {
88
pool = new pg.Pool(options);
99
};
1010

11-
const crud = table => ({
11+
const crud = (table) => ({
1212
async query(sql, args) {
1313
const result = await pool.query(sql, args);
1414
return result.rows;

JavaScript/c-commonjs/static.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ module.exports = (root, port, console) => {
1818
}).listen(port);
1919

2020
console.log(`Static on port ${port}`);
21-
};
21+
};

JavaScript/c-commonjs/static/client.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const transport = {};
44

5-
transport.http = url => structure => {
5+
transport.http = (url) => (structure) => {
66
const api = {};
77
const services = Object.keys(structure);
88
for (const name of services) {
@@ -15,7 +15,7 @@ transport.http = url => structure => {
1515
method: 'POST',
1616
headers: { 'Content-Type': 'application/json' },
1717
body: JSON.stringify({ args }),
18-
}).then(res => {
18+
}).then((res) => {
1919
if (res.status === 200) resolve(res.json());
2020
else reject(new Error(`Status Code: ${res.status}`));
2121
});
@@ -25,7 +25,7 @@ transport.http = url => structure => {
2525
return Promise.resolve(api);
2626
};
2727

28-
transport.ws = url => structure => {
28+
transport.ws = (url) => (structure) => {
2929
const socket = new WebSocket(url);
3030
const api = {};
3131
const services = Object.keys(structure);
@@ -34,22 +34,22 @@ transport.ws = url => structure => {
3434
const service = structure[name];
3535
const methods = Object.keys(service);
3636
for (const method of methods) {
37-
api[name][method] = (...args) => new Promise(resolve => {
37+
api[name][method] = (...args) => new Promise((resolve) => {
3838
const packet = { name, method, args };
3939
socket.send(JSON.stringify(packet));
40-
socket.onmessage = event => {
40+
socket.onmessage = (event) => {
4141
const data = JSON.parse(event.data);
4242
resolve(data);
4343
};
4444
});
4545
}
4646
}
47-
return new Promise(resolve => {
47+
return new Promise((resolve) => {
4848
socket.addEventListener('open', () => resolve(api));
4949
});
5050
};
5151

52-
const scaffold = url => {
52+
const scaffold = (url) => {
5353
const protocol = url.startsWith('ws:') ? 'ws' : 'http';
5454
return transport[protocol](url);
5555
};
@@ -73,5 +73,5 @@ const scaffold = url => {
7373
}
7474
});
7575
const data = await api.talks.say('hello');
76-
console.dir({ data });
76+
console.log({ data });
7777
})();

JavaScript/c-commonjs/transport/http.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const HEADERS = {
1212
'Content-Type': 'application/json; charset=UTF-8',
1313
};
1414

15-
const receiveArgs = async req => {
15+
const receiveArgs = async (req) => {
1616
const buffers = [];
1717
for await (const chunk of req) buffers.push(chunk);
1818
const data = Buffer.concat(buffers).toString();

JavaScript/c-commonjs/transport/ws.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = (routing, port, console) => {
77

88
ws.on('connection', (connection, req) => {
99
const ip = req.socket.remoteAddress;
10-
connection.on('message', async message => {
10+
connection.on('message', async (message) => {
1111
const obj = JSON.parse(message);
1212
const { name, method, args = [] } = obj;
1313
const entity = routing[name];
@@ -25,7 +25,9 @@ module.exports = (routing, port, console) => {
2525
console.log(`${ip} ${name}.${method}(${parameters})`);
2626
try {
2727
const result = await handler(...args);
28-
connection.send(JSON.stringify(result.rows ? result.rows : result), { binary: false });
28+
connection.send(
29+
JSON.stringify(result.rows ? result.rows : result), { binary: false }
30+
);
2931
} catch (err) {
3032
console.error(err);
3133
connection.send('"Server error"', { binary: false });

0 commit comments

Comments
 (0)