refactor: ⬆️ Upgrade dependencies, use JSR for Hono

This commit is contained in:
Jesse Wierzbinski 2024-07-11 12:56:28 +02:00
parent 57b295ccf2
commit 939815510c
No known key found for this signature in database
109 changed files with 183 additions and 180 deletions

1
.npmrc Normal file
View file

@ -0,0 +1 @@
@jsr:registry=https://npm.jsr.io

4
app.ts
View file

@ -1,7 +1,7 @@
import { errorResponse, response } from "@/response";
import { Hono } from "@hono/hono";
import { getLogger } from "@logtape/logtape";
import { config } from "config-manager";
import { Hono } from "hono";
import { agentBans } from "./middlewares/agent-bans";
import { bait } from "./middlewares/bait";
import { boundaryCheck } from "./middlewares/boundary-check";
@ -95,3 +95,5 @@ export const appFactory = async () => {
return app;
};
export type App = Awaited<ReturnType<typeof appFactory>>;

BIN
bun.lockb

Binary file not shown.

View file

@ -1,5 +1,5 @@
import { errorResponse } from "@/response";
import { createMiddleware } from "hono/factory";
import { createMiddleware } from "@hono/hono/factory";
import { config } from "~/packages/config-manager";
export const agentBans = createMiddleware(async (context, next) => {

View file

@ -1,7 +1,7 @@
import { response } from "@/response";
import { createMiddleware } from "@hono/hono/factory";
import { getLogger } from "@logtape/logtape";
import type { SocketAddress } from "bun";
import { createMiddleware } from "hono/factory";
import { matches } from "ip-matching";
import { config } from "~/packages/config-manager";

View file

@ -1,5 +1,5 @@
import { errorResponse } from "@/response";
import { createMiddleware } from "hono/factory";
import { createMiddleware } from "@hono/hono/factory";
export const boundaryCheck = createMiddleware(async (context, next) => {
// Checks that FormData boundary is present

View file

@ -1,7 +1,7 @@
import { errorResponse } from "@/response";
import { createMiddleware } from "@hono/hono/factory";
import { getLogger } from "@logtape/logtape";
import type { SocketAddress } from "bun";
import { createMiddleware } from "hono/factory";
import { matches } from "ip-matching";
import { config } from "~/packages/config-manager";

View file

@ -1,5 +1,5 @@
import { debugRequest } from "@/api";
import { createMiddleware } from "hono/factory";
import { createMiddleware } from "@hono/hono/factory";
import { config } from "~/packages/config-manager";
export const logger = createMiddleware(async (context, next) => {

View file

@ -1,5 +1,5 @@
import { errorResponse } from "@/response";
import { createMiddleware } from "hono/factory";
import { createMiddleware } from "@hono/hono/factory";
import { config } from "~/packages/config-manager";
export const urlCheck = createMiddleware(async (context, next) => {

View file

@ -38,7 +38,6 @@
"cli": "bun run cli/index.ts",
"prune": "ts-prune | grep -v server/ | grep -v dist/ | grep -v '(used in module)'",
"check": "bunx tsc -p .",
"postinstall": "bun run patches/patch.ts",
"prepare": "bunx husky"
},
"trustedDependencies": [
@ -78,19 +77,19 @@
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@types/bun": "^1.1.6",
"@types/cli-progress": "^3.11.5",
"@types/cli-progress": "^3.11.6",
"@types/cli-table": "^0.3.4",
"@types/html-to-text": "^9.0.4",
"@types/ioredis": "^5.0.0",
"@types/jsonld": "^1.5.14",
"@types/jsonld": "^1.5.15",
"@types/markdown-it-container": "^2.0.10",
"@types/mime-types": "^2.1.4",
"@types/pg": "^8.11.6",
"@types/qs": "^6.9.15",
"drizzle-kit": "^0.22.8",
"oclif": "^4.13.12",
"oclif": "^4.14.0",
"ts-prune": "^0.10.3",
"typescript": "^5.5.2"
"typescript": "^5.5.3"
},
"peerDependencies": {
"typescript": "^5.3.2"
@ -98,30 +97,32 @@
"dependencies": {
"@bradenmacdonald/s3-lite-client": "npm:@jsr/bradenmacdonald__s3-lite-client",
"@hackmd/markdown-it-task-lists": "^2.1.4",
"@hono/hono": "npm:@jsr/hono__hono",
"hono": "npm:@jsr/hono__hono",
"@hono/zod-validator": "^0.2.2",
"@inquirer/confirm": "^3.1.11",
"@inquirer/input": "^2.1.11",
"@inquirer/confirm": "^3.1.14",
"@inquirer/input": "^2.2.1",
"@json2csv/plainjs": "^7.0.6",
"@logtape/logtape": "npm:@jsr/logtape__logtape",
"@logtape/logtape": "npm:@jsr/logtape__logtape@0.4.1",
"@lysand-org/client": "^0.2.3",
"@lysand-org/federation": "^2.1.0",
"@oclif/core": "^4.0.7",
"@oclif/core": "^4.0.11",
"@tufjs/canonical-json": "^2.0.0",
"altcha-lib": "^0.3.0",
"blurhash": "^2.0.5",
"bullmq": "^5.8.6",
"chalk": "^5.3.0",
"cli-progress": "^3.12.0",
"cli-table": "^0.3.11",
"config-manager": "workspace:*",
"drizzle-orm": "^0.31.2",
"drizzle-orm": "^0.31.4",
"extract-zip": "^2.0.1",
"hono": "^4.4.10",
"html-to-text": "^9.0.5",
"husky": "^9.0.11",
"ioredis": "^5.4.1",
"ip-matching": "^2.1.2",
"iso-639-1": "^3.1.2",
"jose": "^5.6.2",
"jose": "^5.6.3",
"linkify-html": "^4.1.3",
"linkify-string": "^4.1.3",
"linkifyjs": "^4.1.3",
@ -134,7 +135,7 @@
"oauth4webapi": "^2.11.1",
"ora": "^8.0.1",
"pg": "^8.12.0",
"qs": "^6.12.1",
"qs": "^6.12.3",
"sharp": "^0.33.4",
"sonic-channel": "^1.3.1",
"string-comparison": "^1.3.0",

View file

@ -1,5 +0,0 @@
import { $ } from "bun";
// Replace all occurrences of 'Deno' with '{}' in node_modules/@logtape/logtape/logtape/filesink.deno.js
// LogTape assumes a Deno global exists which causes it to break in Bun
await $`sed -i 's/Deno/{}/g' '${import.meta.dir}/../node_modules/@logtape/logtape/logtape/filesink.deno.js'`;

View file

@ -1,8 +1,8 @@
import { applyConfig, handleZodError } from "@/api";
import { errorResponse, redirect } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { eq, or } from "drizzle-orm";
import type { Hono } from "hono";
import { SignJWT } from "jose";
import { z } from "zod";
import { db } from "~/drizzle/db";

View file

@ -1,9 +1,9 @@
import { applyConfig, handleZodError } from "@/api";
import { randomString } from "@/math";
import { response } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { eq } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { TokenType } from "~/classes/functions/token";
import { db } from "~/drizzle/db";

View file

@ -1,5 +1,5 @@
import { applyConfig } from "@/api";
import type { Hono } from "hono";
import type { Hono } from "@hono/hono";
import { config } from "~/packages/config-manager";
export const meta = applyConfig({

View file

@ -1,7 +1,7 @@
import { applyConfig, handleZodError } from "@/api";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, eq } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { db } from "~/drizzle/db";
import { Applications, Tokens } from "~/drizzle/schema";

View file

@ -1,8 +1,8 @@
import { applyConfig, handleZodError } from "@/api";
import { response } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { eq } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { Users } from "~/drizzle/schema";
import { config } from "~/packages/config-manager";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { eq } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { relationshipToApi } from "~/classes/functions/relationship";
import { getRelationshipToOtherUser } from "~/classes/functions/user";

View file

@ -1,7 +1,7 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import type { Hono } from "hono";
import ISO6391 from "iso-639-1";
import { z } from "zod";
import { relationshipToApi } from "~/classes/functions/relationship";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError, idValidator } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, gt, gte, lt, sql } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { RolePermissions, Users } from "~/drizzle/schema";
import { Timeline } from "~/packages/database-interface/timeline";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError, idValidator } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, gt, gte, lt, sql } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { RolePermissions, Users } from "~/drizzle/schema";
import { Timeline } from "~/packages/database-interface/timeline";

View file

@ -1,7 +1,7 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import type { Hono } from "hono";
import { z } from "zod";
import { RolePermissions } from "~/drizzle/schema";
import { User } from "~/packages/database-interface/user";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { eq } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { relationshipToApi } from "~/classes/functions/relationship";
import { getRelationshipToOtherUser } from "~/classes/functions/user";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { eq } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { relationshipToApi } from "~/classes/functions/relationship";
import { getRelationshipToOtherUser } from "~/classes/functions/user";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { eq } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { relationshipToApi } from "~/classes/functions/relationship";
import { getRelationshipToOtherUser } from "~/classes/functions/user";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, eq } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { relationshipToApi } from "~/classes/functions/relationship";
import { getRelationshipToOtherUser } from "~/classes/functions/user";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError, idValidator } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, eq, gt, gte, isNull, lt, sql } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { Notes, RolePermissions } from "~/drizzle/schema";
import { Timeline } from "~/packages/database-interface/timeline";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { eq } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { relationshipToApi } from "~/classes/functions/relationship";
import { getRelationshipToOtherUser } from "~/classes/functions/user";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { eq } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { relationshipToApi } from "~/classes/functions/relationship";
import { getRelationshipToOtherUser } from "~/classes/functions/user";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { eq } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { relationshipToApi } from "~/classes/functions/relationship";
import { getRelationshipToOtherUser } from "~/classes/functions/user";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { eq } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { relationshipToApi } from "~/classes/functions/relationship";
import { getRelationshipToOtherUser } from "~/classes/functions/user";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError, qsQuery } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { inArray } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { db } from "~/drizzle/db";
import { RolePermissions, Users } from "~/drizzle/schema";

View file

@ -1,9 +1,9 @@
import { applyConfig, auth, handleZodError, jsonOrForm } from "@/api";
import { jsonResponse, response } from "@/response";
import { tempmailDomains } from "@/tempmail";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, eq, isNull } from "drizzle-orm";
import type { Hono } from "hono";
import ISO6391 from "iso-639-1";
import { z } from "zod";
import { Users } from "~/drizzle/schema";
@ -27,7 +27,7 @@ export const meta = applyConfig({
});
export const schemas = {
form: z.object({
json: z.object({
username: z.string(),
email: z.string().toLowerCase(),
password: z.string().optional(),
@ -46,11 +46,11 @@ export default (app: Hono) =>
meta.route,
auth(meta.auth, meta.permissions, meta.challenge),
jsonOrForm(),
zValidator("form", schemas.form, handleZodError),
zValidator("json", schemas.json, handleZodError),
async (context) => {
const form = context.req.valid("form");
const form = context.req.valid("json");
const { username, email, password, agreement, locale } =
context.req.valid("form");
context.req.valid("json");
if (!config.signups.registration) {
return jsonResponse(

View file

@ -1,10 +1,10 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { SignatureConstructor } from "@lysand-org/federation";
import { FederationRequester } from "@lysand-org/federation/requester";
import { eq } from "drizzle-orm";
import type { Hono } from "hono";
import {
anyOf,
charIn,

View file

@ -1,7 +1,7 @@
import { applyConfig, auth, handleZodError, qsQuery } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import type { Hono } from "hono";
import { z } from "zod";
import {
createNewRelationship,

View file

@ -1,10 +1,10 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { SignatureConstructor } from "@lysand-org/federation";
import { FederationRequester } from "@lysand-org/federation/requester";
import { eq, like, not, or, sql } from "drizzle-orm";
import type { Hono } from "hono";
import {
anyOf,
charIn,

View file

@ -1,10 +1,10 @@
import { applyConfig, auth, handleZodError, jsonOrForm } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import { sanitizedHtmlStrip } from "@/sanitization";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { config } from "config-manager";
import { and, eq, isNull } from "drizzle-orm";
import type { Hono } from "hono";
import ISO6391 from "iso-639-1";
import { z } from "zod";
import { parseEmojis } from "~/classes/functions/emoji";
@ -33,7 +33,7 @@ export const meta = applyConfig({
});
export const schemas = {
form: z.object({
json: z.object({
display_name: z
.string()
.min(3)
@ -133,7 +133,7 @@ export default (app: Hono) =>
meta.allowedMethods,
meta.route,
jsonOrForm(),
zValidator("form", schemas.form, handleZodError),
zValidator("json", schemas.json, handleZodError),
auth(meta.auth, meta.permissions),
async (context) => {
const { user } = context.req.valid("header");
@ -148,7 +148,7 @@ export default (app: Hono) =>
discoverable,
source,
fields_attributes,
} = context.req.valid("form");
} = context.req.valid("json");
if (!user) {
return errorResponse("Unauthorized", 401);

View file

@ -1,6 +1,6 @@
import { applyConfig, auth } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "hono";
import type { Hono } from "@hono/hono";
export const meta = applyConfig({
allowedMethods: ["GET"],

View file

@ -1,8 +1,8 @@
import { applyConfig, handleZodError, jsonOrForm } from "@/api";
import { randomString } from "@/math";
import { jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import type { Hono } from "hono";
import { z } from "zod";
import { db } from "~/drizzle/db";
import { Applications, RolePermissions } from "~/drizzle/schema";
@ -23,7 +23,7 @@ export const meta = applyConfig({
});
export const schemas = {
form: z.object({
json: z.object({
client_name: z.string().trim().min(1).max(100),
redirect_uris: z
.string()
@ -49,10 +49,10 @@ export default (app: Hono) =>
meta.allowedMethods,
meta.route,
jsonOrForm(),
zValidator("form", schemas.form, handleZodError),
zValidator("json", schemas.json, handleZodError),
async (context) => {
const { client_name, redirect_uris, scopes, website } =
context.req.valid("form");
context.req.valid("json");
const app = (
await db

View file

@ -1,6 +1,6 @@
import { applyConfig, auth } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "hono";
import type { Hono } from "@hono/hono";
import { getFromToken } from "~/classes/functions/application";
import { RolePermissions } from "~/drizzle/schema";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError, idValidator } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, gt, gte, lt, sql } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { RolePermissions, Users } from "~/drizzle/schema";
import { Timeline } from "~/packages/database-interface/timeline";

View file

@ -1,7 +1,7 @@
import { applyConfig, auth } from "@/api";
import { generateChallenge } from "@/challenges";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "hono";
import type { Hono } from "@hono/hono";
import { config } from "~/packages/config-manager";
export const meta = applyConfig({

View file

@ -1,7 +1,7 @@
import { applyConfig, auth } from "@/api";
import { jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { and, eq, isNull, or } from "drizzle-orm";
import type { Hono } from "hono";
import { Emojis, RolePermissions } from "~/drizzle/schema";
import { Emoji } from "~/packages/database-interface/emoji";

View file

@ -7,9 +7,9 @@ import {
} from "@/api";
import { mimeLookup } from "@/content_types";
import { errorResponse, jsonResponse, response } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { eq } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { MediaManager } from "~/classes/media/media-manager";
import { db } from "~/drizzle/db";
@ -37,7 +37,7 @@ export const schemas = {
param: z.object({
id: z.string().uuid(),
}),
form: z
json: z
.object({
shortcode: z
.string()
@ -73,7 +73,7 @@ export default (app: Hono) =>
meta.route,
jsonOrForm(),
zValidator("param", schemas.param, handleZodError),
zValidator("form", schemas.form, handleZodError),
zValidator("json", schemas.json, handleZodError),
auth(meta.auth, meta.permissions),
async (context) => {
const { id } = context.req.valid("param");
@ -114,7 +114,7 @@ export default (app: Hono) =>
}
case "PATCH": {
const form = context.req.valid("form");
const form = context.req.valid("json");
if (!form) {
return errorResponse(

View file

@ -7,9 +7,9 @@ import {
} from "@/api";
import { mimeLookup } from "@/content_types";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, eq, isNull, or } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { MediaManager } from "~/classes/media/media-manager";
import { Emojis, RolePermissions } from "~/drizzle/schema";
@ -33,7 +33,7 @@ export const meta = applyConfig({
});
export const schemas = {
form: z.object({
json: z.object({
shortcode: z
.string()
.trim()
@ -65,11 +65,11 @@ export default (app: Hono) =>
meta.allowedMethods,
meta.route,
jsonOrForm(),
zValidator("form", schemas.form, handleZodError),
zValidator("json", schemas.json, handleZodError),
auth(meta.auth, meta.permissions),
async (context) => {
const { shortcode, element, alt, global, category } =
context.req.valid("form");
context.req.valid("json");
const { user } = context.req.valid("header");
if (!user) {

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError, idValidator } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, gt, gte, lt, sql } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { Notes, RolePermissions } from "~/drizzle/schema";
import { Timeline } from "~/packages/database-interface/timeline";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, eq } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import {
checkForBidirectionalRelationships,

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, eq } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import {
checkForBidirectionalRelationships,

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError, idValidator } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, gt, gte, lt, sql } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { RolePermissions, Users } from "~/drizzle/schema";
import { Timeline } from "~/packages/database-interface/timeline";

View file

@ -1,6 +1,6 @@
import { applyConfig } from "@/api";
import { jsonResponse } from "@/response";
import type { Hono } from "hono";
import type { Hono } from "@hono/hono";
import { config } from "~/packages/config-manager";
export const meta = applyConfig({

View file

@ -1,7 +1,7 @@
import { applyConfig, auth } from "@/api";
import { renderMarkdownInPath } from "@/markdown";
import { jsonResponse } from "@/response";
import type { Hono } from "hono";
import type { Hono } from "@hono/hono";
import { config } from "~/packages/config-manager";
export const meta = applyConfig({

View file

@ -1,7 +1,7 @@
import { applyConfig, auth } from "@/api";
import { jsonResponse, proxyUrl } from "@/response";
import type { Hono } from "@hono/hono";
import { and, eq, isNull } from "drizzle-orm";
import type { Hono } from "hono";
import { Users } from "~/drizzle/schema";
import manifest from "~/package.json";
import { config } from "~/packages/config-manager";

View file

@ -1,7 +1,7 @@
import { applyConfig, auth } from "@/api";
import { renderMarkdownInPath } from "@/markdown";
import { jsonResponse } from "@/response";
import type { Hono } from "hono";
import type { Hono } from "@hono/hono";
import { config } from "~/packages/config-manager";
export const meta = applyConfig({

View file

@ -1,6 +1,6 @@
import { applyConfig, auth } from "@/api";
import { jsonResponse } from "@/response";
import type { Hono } from "hono";
import type { Hono } from "@hono/hono";
import { config } from "~/packages/config-manager";
export const meta = applyConfig({

View file

@ -1,7 +1,7 @@
import { applyConfig, auth } from "@/api";
import { renderMarkdownInPath } from "@/markdown";
import { jsonResponse } from "@/response";
import type { Hono } from "hono";
import type { Hono } from "@hono/hono";
import { config } from "~/packages/config-manager";
export const meta = applyConfig({

View file

@ -1,9 +1,9 @@
import { applyConfig, auth, handleZodError, idValidator } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import type { Marker as ApiMarker } from "@lysand-org/client/types";
import { and, count, eq } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { db } from "~/drizzle/db";
import { Markers, RolePermissions } from "~/drizzle/schema";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError, idValidator } from "@/api";
import { errorResponse, jsonResponse, response } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { config } from "config-manager";
import type { Hono } from "hono";
import { z } from "zod";
import { MediaManager } from "~/classes/media/media-manager";
import { RolePermissions } from "~/drizzle/schema";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { config } from "config-manager";
import type { Hono } from "hono";
import sharp from "sharp";
import { z } from "zod";
import { MediaManager } from "~/classes/media/media-manager";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError, idValidator } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, gt, gte, lt, sql } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { RolePermissions, Users } from "~/drizzle/schema";
import { Timeline } from "~/packages/database-interface/timeline";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { eq } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { db } from "~/drizzle/db";
import { Notifications, RolePermissions } from "~/drizzle/schema";

View file

@ -1,7 +1,7 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import type { Hono } from "hono";
import { z } from "zod";
import { findManyNotifications } from "~/classes/functions/notification";
import { RolePermissions } from "~/drizzle/schema";

View file

@ -1,7 +1,7 @@
import { applyConfig, auth } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { eq } from "drizzle-orm";
import type { Hono } from "hono";
import { db } from "~/drizzle/db";
import { Notifications, RolePermissions } from "~/drizzle/schema";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, eq, inArray } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { db } from "~/drizzle/db";
import { Notifications, RolePermissions } from "~/drizzle/schema";

View file

@ -1,9 +1,9 @@
import { applyConfig, auth, handleZodError, idValidator } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import { fetchTimeline } from "@/timelines";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { sql } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import {
findManyNotifications,

View file

@ -1,6 +1,6 @@
import { applyConfig, auth } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "hono";
import type { Hono } from "@hono/hono";
import { RolePermissions } from "~/drizzle/schema";
export const meta = applyConfig({

View file

@ -1,6 +1,6 @@
import { applyConfig, auth } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "hono";
import type { Hono } from "@hono/hono";
import { RolePermissions } from "~/drizzle/schema";
export const meta = applyConfig({

View file

@ -1,7 +1,7 @@
import { applyConfig, auth, handleZodError, jsonOrForm } from "@/api";
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse, response } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import type { Hono } from "hono";
import { z } from "zod";
import { RolePermissions } from "~/drizzle/schema";
import { Role } from "~/packages/database-interface/role";
@ -34,7 +34,6 @@ export default (app: Hono) =>
app.on(
meta.allowedMethods,
meta.route,
jsonOrForm(),
zValidator("param", schemas.param, handleZodError),
auth(meta.auth, meta.permissions),
async (context) => {

View file

@ -1,6 +1,6 @@
import { applyConfig, auth } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "hono";
import type { Hono } from "@hono/hono";
import { Role } from "~/packages/database-interface/role";
export const meta = applyConfig({

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse, proxyUrl, response } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { eq } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { db } from "~/drizzle/db";
import { OpenIdAccounts, RolePermissions } from "~/drizzle/schema";

View file

@ -2,8 +2,8 @@ import { applyConfig, auth, handleZodError, jsonOrForm } from "@/api";
import { oauthRedirectUri } from "@/constants";
import { randomString } from "@/math";
import { errorResponse, jsonResponse, proxyUrl } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import type { Hono } from "hono";
import {
calculatePKCECodeChallenge,
discoveryRequest,
@ -35,7 +35,7 @@ export const meta = applyConfig({
});
export const schemas = {
form: z
json: z
.object({
issuer: z.string(),
})
@ -52,10 +52,10 @@ export default (app: Hono) =>
meta.allowedMethods,
meta.route,
jsonOrForm(),
zValidator("form", schemas.form, handleZodError),
zValidator("json", schemas.json, handleZodError),
auth(meta.auth, meta.permissions),
async (context) => {
const form = context.req.valid("form");
const form = context.req.valid("json");
const { user } = context.req.valid("header");
if (!user) {

View file

@ -1,7 +1,7 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import type { Hono } from "hono";
import { z } from "zod";
import { RolePermissions } from "~/drizzle/schema";
import { Note } from "~/packages/database-interface/note";

View file

@ -1,7 +1,7 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import type { Hono } from "hono";
import { z } from "zod";
import { createLike } from "~/classes/functions/like";
import { db } from "~/drizzle/db";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError, idValidator } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, gt, gte, lt, sql } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { RolePermissions, Users } from "~/drizzle/schema";
import { Note } from "~/packages/database-interface/note";

View file

@ -6,9 +6,9 @@ import {
jsonOrForm,
} from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { config } from "config-manager";
import type { Hono } from "hono";
import ISO6391 from "iso-639-1";
import { z } from "zod";
import { undoFederationRequest } from "~/classes/functions/federation";
@ -43,7 +43,7 @@ export const schemas = {
param: z.object({
id: z.string().regex(idValidator),
}),
form: z
json: z
.object({
status: z
.string()
@ -103,7 +103,7 @@ export default (app: Hono) =>
meta.route,
jsonOrForm(),
zValidator("param", schemas.param, handleZodError),
zValidator("form", schemas.form, handleZodError),
zValidator("json", schemas.json, handleZodError),
auth(meta.auth, meta.permissions),
async (context) => {
const { id } = context.req.valid("param");
@ -116,7 +116,7 @@ export default (app: Hono) =>
media_ids,
spoiler_text,
sensitive,
} = context.req.valid("form");
} = context.req.valid("json");
const note = await Note.fromId(id, user?.id);

View file

@ -1,7 +1,7 @@
import { applyConfig, auth, handleZodError, idValidator } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import type { Hono } from "hono";
import { z } from "zod";
import { db } from "~/drizzle/db";
import { RolePermissions } from "~/drizzle/schema";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError, jsonOrForm } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, eq } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { db } from "~/drizzle/db";
import { Notes, Notifications, RolePermissions } from "~/drizzle/schema";
@ -27,7 +27,7 @@ export const schemas = {
param: z.object({
id: z.string().uuid(),
}),
form: z.object({
json: z.object({
visibility: z.enum(["public", "unlisted", "private"]).default("public"),
}),
};
@ -38,11 +38,11 @@ export default (app: Hono) =>
meta.route,
jsonOrForm(),
zValidator("param", schemas.param, handleZodError),
zValidator("form", schemas.form, handleZodError),
zValidator("json", schemas.json, handleZodError),
auth(meta.auth, meta.permissions),
async (context) => {
const { id } = context.req.valid("param");
const { visibility } = context.req.valid("form");
const { visibility } = context.req.valid("json");
const { user } = context.req.valid("header");
if (!user) {

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, gt, gte, lt, sql } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { RolePermissions, Users } from "~/drizzle/schema";
import { Note } from "~/packages/database-interface/note";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import type { StatusSource as ApiStatusSource } from "@lysand-org/client/types";
import type { Hono } from "hono";
import { z } from "zod";
import { RolePermissions } from "~/drizzle/schema";
import { Note } from "~/packages/database-interface/note";

View file

@ -1,7 +1,7 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import type { Hono } from "hono";
import { z } from "zod";
import { deleteLike } from "~/classes/functions/like";
import { RolePermissions } from "~/drizzle/schema";

View file

@ -1,7 +1,7 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import type { Hono } from "hono";
import { z } from "zod";
import { RolePermissions } from "~/drizzle/schema";
import { Note } from "~/packages/database-interface/note";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, eq } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { undoFederationRequest } from "~/classes/functions/federation";
import { Notes, RolePermissions } from "~/drizzle/schema";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError, jsonOrForm } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { config } from "config-manager";
import type { Hono } from "hono";
import ISO6391 from "iso-639-1";
import { z } from "zod";
import { federateNote } from "~/classes/functions/status";
@ -26,7 +26,7 @@ export const meta = applyConfig({
});
export const schemas = {
form: z
json: z
.object({
status: z
.string()
@ -108,7 +108,7 @@ export default (app: Hono) =>
meta.allowedMethods,
meta.route,
jsonOrForm(),
zValidator("form", schemas.form, handleZodError),
zValidator("json", schemas.json, handleZodError),
auth(meta.auth, meta.permissions),
async (context) => {
const { user, application } = context.req.valid("header");
@ -127,7 +127,7 @@ export default (app: Hono) =>
visibility,
content_type,
local_only,
} = context.req.valid("form");
} = context.req.valid("json");
// Check if media attachments are all valid
if (media_ids.length > 0) {

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError, idValidator } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, eq, gt, gte, lt, or, sql } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { Notes, RolePermissions } from "~/drizzle/schema";
import { Timeline } from "~/packages/database-interface/timeline";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError, idValidator } from "@/api";
import { jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, gt, gte, lt, sql } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { Notes, RolePermissions } from "~/drizzle/schema";
import { Timeline } from "~/packages/database-interface/timeline";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError, jsonOrForm } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, eq, inArray } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { db } from "~/drizzle/db";
import { FilterKeywords, Filters, RolePermissions } from "~/drizzle/schema";
@ -26,7 +26,7 @@ export const schemas = {
param: z.object({
id: z.string().uuid(),
}),
form: z.object({
json: z.object({
title: z.string().trim().min(1).max(100).optional(),
context: z
.array(
@ -76,7 +76,7 @@ export default (app: Hono) =>
meta.route,
jsonOrForm(),
zValidator("param", schemas.param, handleZodError),
zValidator("form", schemas.form, handleZodError),
zValidator("json", schemas.json, handleZodError),
auth(meta.auth, meta.permissions),
async (context) => {
const { user } = context.req.valid("header");
@ -123,7 +123,7 @@ export default (app: Hono) =>
filter_action,
expires_in,
keywords_attributes,
} = context.req.valid("form");
} = context.req.valid("json");
await db
.update(Filters)

View file

@ -1,7 +1,7 @@
import { applyConfig, auth, handleZodError, jsonOrForm } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import type { Hono } from "hono";
import { z } from "zod";
import { db } from "~/drizzle/db";
import { FilterKeywords, Filters, RolePermissions } from "~/drizzle/schema";
@ -21,7 +21,7 @@ export const meta = applyConfig({
});
export const schemas = {
form: z
json: z
.object({
title: z.string().trim().min(1).max(100).optional(),
context: z
@ -64,7 +64,7 @@ export default (app: Hono) =>
meta.allowedMethods,
meta.route,
jsonOrForm(),
zValidator("form", schemas.form, handleZodError),
zValidator("json", schemas.json, handleZodError),
auth(meta.auth, meta.permissions),
async (context) => {
const { user } = context.req.valid("header");
@ -102,7 +102,7 @@ export default (app: Hono) =>
);
}
case "POST": {
const form = context.req.valid("form");
const form = context.req.valid("json");
if (!form) {
return errorResponse(
"Missing required Form fields",

View file

@ -1,8 +1,8 @@
import { applyConfig } from "@/api";
import { jsonResponse, proxyUrl } from "@/response";
import type { Hono } from "@hono/hono";
import type { Instance as ApiInstance } from "@lysand-org/client/types";
import { and, eq, isNull } from "drizzle-orm";
import type { Hono } from "hono";
import { Users } from "~/drizzle/schema";
import manifest from "~/package.json";
import { config } from "~/packages/config-manager";

View file

@ -1,8 +1,8 @@
import { applyConfig, auth, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { config } from "config-manager";
import type { Hono } from "hono";
import sharp from "sharp";
import { z } from "zod";
import { MediaManager } from "~/classes/media/media-manager";

View file

@ -1,10 +1,10 @@
import { applyConfig, auth, handleZodError, userAddressValidator } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { SignatureConstructor } from "@lysand-org/federation";
import { FederationRequester } from "@lysand-org/federation/requester";
import { and, eq, inArray, sql } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { searchManager } from "~/classes/search/search-manager";
import { db } from "~/drizzle/db";

View file

@ -1,7 +1,7 @@
import { applyConfig, handleZodError } from "@/api";
import { errorResponse, response } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import type { Hono } from "hono";
import { z } from "zod";
export const meta = applyConfig({

View file

@ -1,7 +1,7 @@
import { applyConfig, handleZodError } from "@/api";
import { errorResponse, response } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import type { Hono } from "hono";
import { z } from "zod";
import { config } from "~/packages/config-manager";

View file

@ -1,8 +1,8 @@
import { applyConfig, handleZodError, jsonOrForm } from "@/api";
import { randomString } from "@/math";
import { response } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import type { Hono } from "hono";
import { SignJWT, jwtVerify } from "jose";
import { z } from "zod";
import { TokenType } from "~/classes/functions/token";
@ -35,7 +35,7 @@ export const schemas = {
.optional()
.default(60 * 60 * 24 * 7),
}),
form: z.object({
json: z.object({
scope: z.string().optional(),
redirect_uri: z
.string()
@ -83,12 +83,12 @@ export default (app: Hono) =>
meta.route,
jsonOrForm(),
zValidator("query", schemas.query, handleZodError),
zValidator("form", schemas.form, handleZodError),
zValidator("json", schemas.json, handleZodError),
async (context) => {
const { scope, redirect_uri, response_type, client_id, state } =
context.req.valid("form");
context.req.valid("json");
const body = context.req.valid("form");
const body = context.req.valid("json");
const cookie = context.req.header("Cookie");

View file

@ -1,9 +1,9 @@
import { applyConfig, handleZodError } from "@/api";
import { randomString } from "@/math";
import { errorResponse, response } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, eq, isNull } from "drizzle-orm";
import type { Hono } from "hono";
import { SignJWT } from "jose";
import { z } from "zod";
import { TokenType } from "~/classes/functions/token";

View file

@ -1,8 +1,8 @@
import { applyConfig, handleZodError } from "@/api";
import { oauthRedirectUri } from "@/constants";
import { redirect, response } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import type { Hono } from "hono";
import {
calculatePKCECodeChallenge,
discoveryRequest,

View file

@ -1,8 +1,8 @@
import { applyConfig, handleZodError, jsonOrForm } from "@/api";
import { jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { eq } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { db } from "~/drizzle/db";
import { Tokens } from "~/drizzle/schema";
@ -20,7 +20,7 @@ export const meta = applyConfig({
});
export const schemas = {
form: z.object({
json: z.object({
code: z.string().optional(),
code_verifier: z.string().optional(),
grant_type: z.enum([
@ -64,10 +64,10 @@ export default (app: Hono) =>
meta.allowedMethods,
meta.route,
jsonOrForm(),
zValidator("form", schemas.form, handleZodError),
zValidator("json", schemas.json, handleZodError),
async (context) => {
const { grant_type, code, redirect_uri, client_id, client_secret } =
context.req.valid("form");
context.req.valid("json");
switch (grant_type) {
case "authorization_code": {

View file

@ -1,9 +1,9 @@
import { applyConfig, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import type { Entity } from "@lysand-org/federation/types";
import { and, eq, inArray, sql } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { type LikeType, likeToLysand } from "~/classes/functions/like";
import { db } from "~/drizzle/db";

View file

@ -1,5 +1,6 @@
import { applyConfig, debugRequest, handleZodError } from "@/api";
import { errorResponse, jsonResponse, response } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { getLogger } from "@logtape/logtape";
import {
@ -10,7 +11,6 @@ import {
import type { Entity } from "@lysand-org/federation/types";
import type { SocketAddress } from "bun";
import { and, eq } from "drizzle-orm";
import type { Hono } from "hono";
import { matches } from "ip-matching";
import { z } from "zod";
import { type ValidationError, isValidationError } from "zod-validation-error";

View file

@ -1,7 +1,7 @@
import { applyConfig, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import type { Hono } from "hono";
import { z } from "zod";
import { User } from "~/packages/database-interface/user";

View file

@ -1,8 +1,8 @@
import { applyConfig, handleZodError } from "@/api";
import { errorResponse, jsonResponse } from "@/response";
import type { Hono } from "@hono/hono";
import { zValidator } from "@hono/zod-validator";
import { and, count, eq, inArray } from "drizzle-orm";
import type { Hono } from "hono";
import { z } from "zod";
import { db } from "~/drizzle/db";
import { Notes } from "~/drizzle/schema";

View file

@ -1,6 +1,6 @@
import { applyConfig } from "@/api";
import { xmlResponse } from "@/response";
import type { Hono } from "hono";
import type { Hono } from "@hono/hono";
import { config } from "~/packages/config-manager";
export const meta = applyConfig({

View file

@ -1,6 +1,6 @@
import { applyConfig } from "@/api";
import { jsonResponse } from "@/response";
import type { Hono } from "hono";
import type { Hono } from "@hono/hono";
import { exportJWK } from "jose";
import { config } from "~/packages/config-manager";

Some files were not shown because too many files have changed in this diff Show more