Skip to content

Commit

Permalink
c-common api an ws fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
axbuglak committed Dec 6, 2023
1 parent d4a5976 commit 17b0bd6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions JavaScript/c-commonjs/api/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ const users = db.crud('users');

module.exports = {
async read(id) {
return users.read(id, ['id', 'login']);
return await users.read(id, ['id', 'login']);
},

async create({ login, password }) {
const passwordHash = await common.hash(password);
return users.create({ login, password: passwordHash });
return await users.create({ login, password: passwordHash });
},

async update(id, { login, password }) {
const passwordHash = await common.hash(password);
return users.update(id, { login, password: passwordHash });
return await users.update(id, { login, password: passwordHash });
},

async delete(id) {
return users.delete(id);
return await users.delete(id);
},

async find(mask) {
const sql = 'SELECT login from users where login like $1';
return users.query(sql, [mask]);
return await users.query(sql, [mask]);
},
};
2 changes: 1 addition & 1 deletion JavaScript/c-commonjs/static/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ const scaffold = (url) => {
}
});
const data = await api.user.read();
console.log({ data });
console.dir({ data });
})();
2 changes: 1 addition & 1 deletion JavaScript/c-commonjs/transport/ws.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ module.exports = (routing, port, console) => {
try {
const result = await handler(...args);
connection.send(
JSON.stringify(result.rows ? result.rows : result), { binary: false }
JSON.stringify(result), { binary: false }
);
} catch (err) {
console.error(err);
Expand Down

0 comments on commit 17b0bd6

Please sign in to comment.