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 { errorResponse, response } from "@/response";
import { Hono } from "@hono/hono";
import { getLogger } from "@logtape/logtape"; import { getLogger } from "@logtape/logtape";
import { config } from "config-manager"; import { config } from "config-manager";
import { Hono } from "hono";
import { agentBans } from "./middlewares/agent-bans"; import { agentBans } from "./middlewares/agent-bans";
import { bait } from "./middlewares/bait"; import { bait } from "./middlewares/bait";
import { boundaryCheck } from "./middlewares/boundary-check"; import { boundaryCheck } from "./middlewares/boundary-check";
@ -95,3 +95,5 @@ export const appFactory = async () => {
return app; 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 { errorResponse } from "@/response";
import { createMiddleware } from "hono/factory"; import { createMiddleware } from "@hono/hono/factory";
import { config } from "~/packages/config-manager"; import { config } from "~/packages/config-manager";
export const agentBans = createMiddleware(async (context, next) => { export const agentBans = createMiddleware(async (context, next) => {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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