Skip to content
Permalink
Browse files
npm installs and adding findByUsername to users route
  • Loading branch information
skondram committed Nov 24, 2021
1 parent 9c67cd5 commit 8944f636898e0782af508801cf8671bf9f504e1a
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 0 deletions.

Some generated files are not rendered by default. Learn more.

@@ -15,7 +15,9 @@
"dependencies": {
"koa": "^2.13.4",
"koa-bodyparser": "^4.3.0",
"koa-passport": "^4.1.4",
"koa-router": "^10.1.1",
"passport-http": "^0.3.0",
"promise-mysql": "^5.0.4",
"uuid": "^8.3.2"
}
@@ -26,6 +26,14 @@ async function getById(ctx) {
}
}

//get a single user by the (unique) username
exports.findByUsername = async function getByUsername(username) {
const query = "SELECT * FROM users WHERE username = ?;";
const user = await db.run_query(query, username);
return user;
}


async function createUser(ctx) {
const body = ctx.request.body;
const result = await model.add(body);

0 comments on commit 8944f63

Please sign in to comment.