Add authentication endpoints with logic

This commit is contained in:
ruihildt committed 2019-08-01 08:55:37 +02:00
1 parent 6c562ee7f6
commit d97221e522
5 files changed
+114 -2

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
const db = require('../../data/dbConfig');
module.exports = {
add,
findBy,
findById,
};
function findBy(filter) {
return db('users')
.where(filter);
}
async function add(user) {
const [id] = await db('users')
.insert(user);
return findById(id);
}
function findById(id) {
return db('users')
.where({ id })
.first()
.select('id', 'email', 'username');
}