chore: use monorepo organization
This commit is contained in:
parent
deaf7d6ecc
commit
a687827f7e
1099 changed files with 8184 additions and 11535 deletions
15
packages/server/lib/auth-tokens.js
Normal file
15
packages/server/lib/auth-tokens.js
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
const crypto = require('crypto')
|
||||
|
||||
const constants = require('./constants')
|
||||
const db = require('./db')
|
||||
|
||||
function createAuthToken (userID, type) {
|
||||
const token = crypto.randomBytes(32).toString('hex')
|
||||
const sql = `INSERT INTO auth_tokens (token, type, user_id) VALUES ($1, $2, $3) ON CONFLICT (user_id, type) DO UPDATE SET token=$1, expire=now() + interval '${constants.AUTH_TOKEN_EXPIRATION_TIME}' RETURNING *`
|
||||
|
||||
return db.one(sql, [token, type, userID])
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
createAuthToken
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue