docs: add JSDoc headers to all externally exported store functions
This commit is contained in:
@@ -1,5 +1,16 @@
|
||||
import { ADD } from '../../sql/google_auth.js';
|
||||
|
||||
/**
|
||||
* Adds a new allowed Google auth email.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that adds an allowed email.
|
||||
*
|
||||
* @example
|
||||
* const fn = add(pool);
|
||||
* const id = await fn('user@example.com');
|
||||
* // => 1
|
||||
*/
|
||||
export default function add(pool) {
|
||||
return async (email) => {
|
||||
const result = await pool
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
import { GET_BY_EMAIL } from '../../sql/google_auth.js';
|
||||
|
||||
/**
|
||||
* Returns a Google auth row by email.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that fetches a Google auth row by email.
|
||||
*
|
||||
* @example
|
||||
* const fn = getByEmail(pool);
|
||||
* const auth = await fn('user@example.com');
|
||||
* // => { id, email, ... }
|
||||
*/
|
||||
export default function getByEmail(pool) {
|
||||
return async (email) => {
|
||||
const result = await pool
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
import { GET_BY_ID } from '../../sql/google_auth.js';
|
||||
|
||||
/**
|
||||
* Returns a Google auth row by its id.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that fetches a Google auth row by id.
|
||||
*
|
||||
* @example
|
||||
* const fn = getById(pool);
|
||||
* const auth = await fn(42);
|
||||
* // => { id, email, ... }
|
||||
*/
|
||||
export default function getById(pool) {
|
||||
return async (googleAuthId) => {
|
||||
const result = await pool
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
import { LIST_ALLOWED_EMAILS } from '../../sql/google_auth.js';
|
||||
|
||||
/**
|
||||
* Lists all allowed Google auth emails.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that lists allowed emails.
|
||||
*
|
||||
* @example
|
||||
* const fn = listAllowedEmails(pool);
|
||||
* const emails = await fn();
|
||||
* // => [{ id, email }]
|
||||
*/
|
||||
export default function listAllowedEmails(pool) {
|
||||
return async () => {
|
||||
const result = await pool.request().query(LIST_ALLOWED_EMAILS);
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
import { REMOVE_ALLOWED_EMAIL } from '../../sql/google_auth.js';
|
||||
|
||||
/**
|
||||
* Removes an allowed Google auth email.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that removes an allowed email.
|
||||
*
|
||||
* @example
|
||||
* const fn = removeAllowedEmail(pool);
|
||||
* await fn('user@example.com');
|
||||
*/
|
||||
export default function removeAllowedEmail(pool) {
|
||||
return async (email) => {
|
||||
await pool
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
import { SET_PROFILE } from '../../sql/google_auth.js';
|
||||
|
||||
/**
|
||||
* Updates the profile (picture, picture binary, sub) of a Google auth user.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that sets the user profile.
|
||||
*
|
||||
* @example
|
||||
* const fn = setProfile(pool);
|
||||
* await fn(42, { picture: 'url', pictureBinary: buffer, sub: 'sub' });
|
||||
*/
|
||||
export default function setProfile(pool) {
|
||||
return async (
|
||||
googleAuthId,
|
||||
|
||||
@@ -1,5 +1,15 @@
|
||||
import { SET_SELECTED_COMPANY } from '../../sql/google_auth.js';
|
||||
|
||||
/**
|
||||
* Sets the currently selected company for a Google auth user.
|
||||
*
|
||||
* @param {object} pool - The mssql connection pool.
|
||||
* @returns {Function} An async function that sets the selected company.
|
||||
*
|
||||
* @example
|
||||
* const fn = setSelectedCompany(pool);
|
||||
* await fn(42, 1);
|
||||
*/
|
||||
export default function setSelectedCompany(pool) {
|
||||
return async (googleAuthId, companyId) => {
|
||||
await pool
|
||||
|
||||
Reference in New Issue
Block a user