refactor: ♻️ Always use explicit types in every function

This commit is contained in:
Jesse Wierzbinski 2024-11-02 00:43:33 +01:00
parent 54cea29ce9
commit c1dcdc78ae
No known key found for this signature in database
62 changed files with 359 additions and 226 deletions

View file

@ -2,7 +2,7 @@ import { randomString } from "@/math.ts";
import { setCookie } from "@hono/hono/cookie";
import { createRoute, z } from "@hono/zod-openapi";
import { User, db } from "@versia/kit/db";
import { and, eq, isNull } from "@versia/kit/drizzle";
import { type SQL, and, eq, isNull } from "@versia/kit/drizzle";
import {
OpenIdAccounts,
RolePermissions,
@ -29,7 +29,7 @@ export const schemas = {
}),
};
export default (plugin: PluginType) => {
export default (plugin: PluginType): void => {
plugin.registerRoute("/oauth/sso/{issuer}/callback", (app) => {
app.openapi(
createRoute({
@ -150,7 +150,7 @@ export default (plugin: PluginType) => {
// Check if account is already linked
const account = await db.query.OpenIdAccounts.findFirst({
where: (account, { eq, and }) =>
where: (account, { eq, and }): SQL | undefined =>
and(
eq(account.serverId, sub),
eq(account.issuerId, issuer.id),
@ -188,7 +188,7 @@ export default (plugin: PluginType) => {
let userId = (
await db.query.OpenIdAccounts.findFirst({
where: (account, { eq, and }) =>
where: (account, { eq, and }): SQL | undefined =>
and(
eq(account.serverId, sub),
eq(account.issuerId, issuer.id),

View file

@ -1,7 +1,7 @@
import { jsonOrForm } from "@/api";
import { createRoute, z } from "@hono/zod-openapi";
import { db } from "@versia/kit/db";
import { eq } from "@versia/kit/drizzle";
import { type SQL, eq } from "@versia/kit/drizzle";
import { Tokens } from "@versia/kit/tables";
import type { PluginType } from "../../index.ts";
@ -13,7 +13,7 @@ export const schemas = {
}),
};
export default (plugin: PluginType) => {
export default (plugin: PluginType): void => {
plugin.registerRoute("/oauth/revoke", (app) => {
app.openapi(
createRoute({
@ -63,7 +63,7 @@ export default (plugin: PluginType) => {
context.req.valid("json");
const foundToken = await db.query.Tokens.findFirst({
where: (tokenTable, { eq, and }) =>
where: (tokenTable, { eq, and }): SQL | undefined =>
and(
eq(tokenTable.accessToken, token ?? ""),
eq(tokenTable.clientId, client_id),

View file

@ -20,7 +20,7 @@ export const schemas = {
}),
};
export default (plugin: PluginType) => {
export default (plugin: PluginType): void => {
plugin.registerRoute("/oauth/sso", (app) => {
app.openapi(
createRoute({

View file

@ -1,7 +1,7 @@
import { jsonOrForm } from "@/api";
import { createRoute, z } from "@hono/zod-openapi";
import { Application, db } from "@versia/kit/db";
import { eq } from "@versia/kit/drizzle";
import { type SQL, eq } from "@versia/kit/drizzle";
import { Tokens } from "@versia/kit/tables";
import type { PluginType } from "../../index.ts";
@ -38,7 +38,7 @@ export const schemas = {
}),
};
export default (plugin: PluginType) => {
export default (plugin: PluginType): void => {
plugin.registerRoute("/oauth/token", (app) => {
app.openapi(
createRoute({
@ -155,7 +155,7 @@ export default (plugin: PluginType) => {
}
const token = await db.query.Tokens.findFirst({
where: (token, { eq, and }) =>
where: (token, { eq, and }): SQL | undefined =>
and(
eq(token.code, code),
eq(