diff --git a/src/lib/server/db/category.js b/src/lib/server/db/category.js index 44bd866..88c0746 100644 --- a/src/lib/server/db/category.js +++ b/src/lib/server/db/category.js @@ -68,7 +68,7 @@ export async function getCategories(category_ids = undefined) { /** * @param {number} category_id - * @returns {Promise} + * @returns {Promise} */ export async function getCategoryCached(category_id) { const categories = await getCategoriesCached([category_id]); diff --git a/src/lib/server/db/post.js b/src/lib/server/db/post.js index 222ed5c..0abf4ac 100644 --- a/src/lib/server/db/post.js +++ b/src/lib/server/db/post.js @@ -96,7 +96,7 @@ export async function getPosts(opts = {}) { * @param {{ * withMetrics?: boolean * }} opts - * @returns {Promise} + * @returns {Promise} */ export async function getPost(post_id, opts = {}) { const { diff --git a/src/lib/server/db/user.js b/src/lib/server/db/user.js index 6483682..d974c81 100644 --- a/src/lib/server/db/user.js +++ b/src/lib/server/db/user.js @@ -1,6 +1,8 @@ import { createCache } from '$lib/cache.server'; -import { genSalt } from 'bcrypt'; import { cacheUpdater, cachedMethod, refExtendCachedMethod } from './root'; +import { sql } from '$lib/db.server'; +import { argon2id, hash, verify } from 'argon2'; +import { PostgresError } from 'postgres'; const cache = createCache(); @@ -32,7 +34,6 @@ function parseUserFromRow(row) { const updateUserCache = cacheUpdater(cache); /** - * @param {import('postgres').Sql} sql * @param {number[]} user_ids * @returns {Promise>} */ @@ -41,11 +42,10 @@ export const getUsersCached = cachedMethod(cache, getUsers); export const getUsersCachedByRef = refExtendCachedMethod(getUsersCached); /** - * @param {import('postgres').Sql} sql * @param {number[]} user_ids * @returns {Promise>} */ -export async function getUsers(sql, user_ids) { +export async function getUsers(user_ids) { if (user_ids.length == 0) return new Map(); const query = sql` @@ -68,12 +68,11 @@ export async function getUsers(sql, user_ids) { } /** - * @param {import('postgres').Sql} sql * @param {number} user_id - * @returns {Promise} + * @returns {Promise} */ -export async function getUser(sql, user_id) { - const users = await getUsers(sql, [user_id]); +export async function getUser(user_id) { + const users = await getUsers([user_id]); return users.get(user_id) || { error: true, @@ -82,10 +81,9 @@ export async function getUser(sql, user_id) { } /** - * @param {import('postgres').Sql} sql * @param {string} username * @param {string} password - * @returns {Promise} + * @returns {Promise} */ export async function registerUser(sql, username, password) { // const users = await getUsers(sql, [user_id]); diff --git a/src/types/error.ts b/src/types/error.ts deleted file mode 100644 index a644d06..0000000 --- a/src/types/error.ts +++ /dev/null @@ -1,4 +0,0 @@ -export type Error = { - error: boolean, - msg: string -}; diff --git a/src/types/status.ts b/src/types/status.ts new file mode 100644 index 0000000..87ee3e9 --- /dev/null +++ b/src/types/status.ts @@ -0,0 +1,8 @@ +export type Error = { + error: boolean, + msg: string, +}; + +export type Success = { + success: boolean, +};