diff --git a/functions/account/create.ts b/functions/account/create.ts index 99618bf..d9dc618 100644 --- a/functions/account/create.ts +++ b/functions/account/create.ts @@ -4,6 +4,8 @@ import { createAccount, setDB } from '../../src/backend/api'; import type { RequestContext } from '../../src/backend/context'; import { checkBody, error, parseError, response } from '../../src/backend/utils'; +export { onRequestOptions } from '../../src/backend/utils'; + export async function onRequest({ env, request }: RequestContext): Promise { try { setDB(env.DB); diff --git a/functions/account/delete.ts b/functions/account/delete.ts index 237039a..e95b715 100644 --- a/functions/account/delete.ts +++ b/functions/account/delete.ts @@ -4,6 +4,8 @@ import { deleteAccount, setDB } from '../../src/backend/api'; import type { RequestContext } from '../../src/backend/context'; import { checkAuth, checkBody, error, getAccountFromTokenOrID, response } from '../../src/backend/utils'; +export { onRequestOptions } from '../../src/backend/utils'; + export async function onRequest({ env, request }: RequestContext): Promise { try { setDB(env.DB); diff --git a/functions/account/index.ts b/functions/account/index.ts index 4a9708b..a25c627 100644 --- a/functions/account/index.ts +++ b/functions/account/index.ts @@ -1,6 +1,8 @@ import { StatusCodes } from 'http-status-codes'; import { response } from '../../src/backend/utils'; +export { onRequestOptions } from '../../src/backend/utils'; + export function onRequest(): Response { return response(StatusCodes.OK, {}); } diff --git a/functions/account/info.ts b/functions/account/info.ts index 6f732cb..65c8682 100644 --- a/functions/account/info.ts +++ b/functions/account/info.ts @@ -5,6 +5,8 @@ import type { RequestContext } from '../../src/backend/context'; import { checkAuth, checkBody, checkParams, error, response } from '../../src/backend/utils'; import { Access } from '../../src/generic'; +export { onRequestOptions } from '../../src/backend/utils'; + export async function onRequest({ env, request }: RequestContext): Promise { try { setDB(env.DB); diff --git a/functions/account/login.ts b/functions/account/login.ts index 84db8c0..31a7e0a 100644 --- a/functions/account/login.ts +++ b/functions/account/login.ts @@ -4,6 +4,8 @@ import { getAccount, hash, login, setDB } from '../../src/backend/api'; import type { RequestContext } from '../../src/backend/context'; import { checkBody, error, parseError, response } from '../../src/backend/utils'; +export { onRequestOptions } from '../../src/backend/utils'; + export async function onRequest({ env, request }: RequestContext): Promise { try { setDB(env.DB); diff --git a/functions/account/logout.ts b/functions/account/logout.ts index 80d73f8..64055a4 100644 --- a/functions/account/logout.ts +++ b/functions/account/logout.ts @@ -4,6 +4,8 @@ import { logout, setDB } from '../../src/backend/api'; import type { RequestContext } from '../../src/backend/context'; import { checkAuth, checkBody, error, getAccountFromTokenOrID, parseError, response } from '../../src/backend/utils'; +export { onRequestOptions } from '../../src/backend/utils'; + export async function onRequest({ env, request }: RequestContext): Promise { try { setDB(env.DB); diff --git a/functions/account/num.ts b/functions/account/num.ts index c7075c4..1f7638b 100644 --- a/functions/account/num.ts +++ b/functions/account/num.ts @@ -3,6 +3,8 @@ import { getAccountNum, setDB } from '../../src/backend/api'; import type { RequestContext } from '../../src/backend/context'; import { error, response } from '../../src/backend/utils'; +export { onRequestOptions } from '../../src/backend/utils'; + export async function onRequest({ env }: RequestContext) { try { setDB(env.DB); diff --git a/functions/account/update.ts b/functions/account/update.ts index e7b0393..6113911 100644 --- a/functions/account/update.ts +++ b/functions/account/update.ts @@ -4,6 +4,8 @@ import { setAccountAttribute, setDB } from '../../src/backend/api'; import type { RequestContext } from '../../src/backend/context'; import { checkAuth, checkBody, error, getAccountFromTokenOrID, parseError, response } from '../../src/backend/utils'; +export { onRequestOptions } from '../../src/backend/utils'; + const requiredTypeForChange: { [K in keyof FullAccount]: AccountType } = { ...(Object.fromEntries(accountAttributes.map(k => [k, AccountType.MOD])) as { [K in keyof FullAccount]: AccountType.MOD }), username: AccountType.DEV, diff --git a/src/backend/utils.ts b/src/backend/utils.ts index d2a1ac4..aa70ac8 100644 --- a/src/backend/utils.ts +++ b/src/backend/utils.ts @@ -1,4 +1,4 @@ -import type { Request as CFRequest } from '@cloudflare/workers-types'; +import type { Request as CFRequest, PagesFunction } from '@cloudflare/workers-types'; import { ReasonPhrases, StatusCodes } from 'http-status-codes'; import { AccountType, type Account } from '../accounts'; import { Access, type Response as APIResponse } from '../generic'; @@ -138,3 +138,15 @@ export async function getAccountFromTokenOrID