mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
chore: ⚰️ Remove dead code and unused imports
This commit is contained in:
parent
3a37790315
commit
f87bcbd0da
|
|
@ -30,7 +30,7 @@ export default class EmojiAdd extends BaseCommand<typeof EmojiAdd> {
|
||||||
static override flags = {};
|
static override flags = {};
|
||||||
|
|
||||||
public async run(): Promise<void> {
|
public async run(): Promise<void> {
|
||||||
const { flags, args } = await this.parse(EmojiAdd);
|
const { args } = await this.parse(EmojiAdd);
|
||||||
|
|
||||||
// Check if emoji already exists
|
// Check if emoji already exists
|
||||||
const existingEmoji = await db.query.Emojis.findFirst({
|
const existingEmoji = await db.query.Emojis.findFirst({
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import confirm from "@inquirer/confirm";
|
import confirm from "@inquirer/confirm";
|
||||||
import { Args, Flags } from "@oclif/core";
|
import { Flags } from "@oclif/core";
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import { and, eq, inArray, isNull } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
import ora from "ora";
|
import ora from "ora";
|
||||||
import { EmojiFinderCommand } from "~/cli/classes";
|
import { EmojiFinderCommand } from "~/cli/classes";
|
||||||
import { formatArray } from "~/cli/utils/format";
|
import { formatArray } from "~/cli/utils/format";
|
||||||
|
|
@ -34,7 +34,7 @@ export default class EmojiDelete extends EmojiFinderCommand<
|
||||||
};
|
};
|
||||||
|
|
||||||
public async run(): Promise<void> {
|
public async run(): Promise<void> {
|
||||||
const { flags, args } = await this.parse(EmojiDelete);
|
const { flags } = await this.parse(EmojiDelete);
|
||||||
|
|
||||||
const emojis = await this.findEmojis();
|
const emojis = await this.findEmojis();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ export default class EmojiImport extends BaseCommand<typeof EmojiImport> {
|
||||||
};
|
};
|
||||||
|
|
||||||
public async run(): Promise<void> {
|
public async run(): Promise<void> {
|
||||||
const { flags, args } = await this.parse(EmojiImport);
|
const { args } = await this.parse(EmojiImport);
|
||||||
|
|
||||||
// Check if path ends in .zip, warn the user if it doesn't
|
// Check if path ends in .zip, warn the user if it doesn't
|
||||||
if (!args.path.endsWith(".zip")) {
|
if (!args.path.endsWith(".zip")) {
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ export default class UserDelete extends UserFinderCommand<typeof UserDelete> {
|
||||||
};
|
};
|
||||||
|
|
||||||
public async run(): Promise<void> {
|
public async run(): Promise<void> {
|
||||||
const { flags, args } = await this.parse(UserDelete);
|
const { flags } = await this.parse(UserDelete);
|
||||||
|
|
||||||
const users = await this.findUsers();
|
const users = await this.findUsers();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ export default class UserReset extends UserFinderCommand<typeof UserReset> {
|
||||||
};
|
};
|
||||||
|
|
||||||
public async run(): Promise<void> {
|
public async run(): Promise<void> {
|
||||||
const { flags, args } = await this.parse(UserReset);
|
const { flags } = await this.parse(UserReset);
|
||||||
|
|
||||||
const users = await this.findUsers();
|
const users = await this.findUsers();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ import { db } from "~/drizzle/db";
|
||||||
import { Relationships } from "~/drizzle/schema";
|
import { Relationships } from "~/drizzle/schema";
|
||||||
import type { User } from "~/packages/database-interface/user";
|
import type { User } from "~/packages/database-interface/user";
|
||||||
import type { Relationship as APIRelationship } from "~/types/mastodon/relationship";
|
import type { Relationship as APIRelationship } from "~/types/mastodon/relationship";
|
||||||
import type { UserType } from "./User";
|
|
||||||
|
|
||||||
export type Relationship = InferSelectModel<typeof Relationships>;
|
export type Relationship = InferSelectModel<typeof Relationships>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,6 @@ import {
|
||||||
exactly,
|
exactly,
|
||||||
global,
|
global,
|
||||||
letter,
|
letter,
|
||||||
maybe,
|
|
||||||
oneOrMore,
|
|
||||||
} from "magic-regexp";
|
} from "magic-regexp";
|
||||||
import MarkdownIt from "markdown-it";
|
import MarkdownIt from "markdown-it";
|
||||||
import markdownItAnchor from "markdown-it-anchor";
|
import markdownItAnchor from "markdown-it-anchor";
|
||||||
|
|
|
||||||
3
index.ts
3
index.ts
|
|
@ -11,7 +11,6 @@ import { bait } from "~/middlewares/bait";
|
||||||
import { boundaryCheck } from "~/middlewares/boundary-check";
|
import { boundaryCheck } from "~/middlewares/boundary-check";
|
||||||
import { ipBans } from "~/middlewares/ip-bans";
|
import { ipBans } from "~/middlewares/ip-bans";
|
||||||
import { logger } from "~/middlewares/logger";
|
import { logger } from "~/middlewares/logger";
|
||||||
import { urlCheck } from "~/middlewares/url-check";
|
|
||||||
import { Note } from "~/packages/database-interface/note";
|
import { Note } from "~/packages/database-interface/note";
|
||||||
import { handleGlitchRequest } from "~/packages/glitch-server/main";
|
import { handleGlitchRequest } from "~/packages/glitch-server/main";
|
||||||
import { routes } from "~/routes";
|
import { routes } from "~/routes";
|
||||||
|
|
@ -122,7 +121,7 @@ app.use(boundaryCheck);
|
||||||
// app.use(urlCheck);
|
// app.use(urlCheck);
|
||||||
|
|
||||||
// Inject own filesystem router
|
// Inject own filesystem router
|
||||||
for (const [route, path] of Object.entries(routes)) {
|
for (const [, path] of Object.entries(routes)) {
|
||||||
// use app.get(path, handler) to add routes
|
// use app.get(path, handler) to add routes
|
||||||
const route: APIRouteExports = await import(path);
|
const route: APIRouteExports = await import(path);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { oauthRedirectUri } from "@/constants";
|
import { oauthRedirectUri } from "@/constants";
|
||||||
import { errorResponse, response } from "@/response";
|
import { response } from "@/response";
|
||||||
import type { InferInsertModel } from "drizzle-orm";
|
import type { InferInsertModel } from "drizzle-orm";
|
||||||
import {
|
import {
|
||||||
type AuthorizationServer,
|
type AuthorizationServer,
|
||||||
|
|
|
||||||
|
|
@ -295,7 +295,7 @@ describe("LocalMediaBackend", () => {
|
||||||
// deleteByUrl
|
// deleteByUrl
|
||||||
const mockHash = "test-hash";
|
const mockHash = "test-hash";
|
||||||
spyOn(mockMediaHasher, "getMediaHash").mockResolvedValue(mockHash);
|
spyOn(mockMediaHasher, "getMediaHash").mockResolvedValue(mockHash);
|
||||||
const result = await localMediaBackend.addFile(mockFile);
|
await localMediaBackend.addFile(mockFile);
|
||||||
const rmMock = jest.fn().mockResolvedValue(Promise.resolve());
|
const rmMock = jest.fn().mockResolvedValue(Promise.resolve());
|
||||||
|
|
||||||
// Spy on fs/promises rm
|
// Spy on fs/promises rm
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { applyConfig, handleZodError } from "@/api";
|
import { applyConfig, handleZodError } from "@/api";
|
||||||
import { errorResponse, redirect, response } from "@/response";
|
import { errorResponse, response } from "@/response";
|
||||||
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 type { Hono } from "hono";
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ export default (app: Hono) =>
|
||||||
auth(meta.auth),
|
auth(meta.auth),
|
||||||
async (context) => {
|
async (context) => {
|
||||||
const { id } = context.req.valid("param");
|
const { id } = context.req.valid("param");
|
||||||
const { user } = context.req.valid("header");
|
|
||||||
const { max_id, since_id, min_id, limit } =
|
const { max_id, since_id, min_id, limit } =
|
||||||
context.req.valid("query");
|
context.req.valid("query");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ export default (app: Hono) =>
|
||||||
auth(meta.auth),
|
auth(meta.auth),
|
||||||
async (context) => {
|
async (context) => {
|
||||||
const { id } = context.req.valid("param");
|
const { id } = context.req.valid("param");
|
||||||
const { user } = context.req.valid("header");
|
|
||||||
const { max_id, since_id, min_id } = context.req.valid("query");
|
const { max_id, since_id, min_id } = context.req.valid("query");
|
||||||
|
|
||||||
const otherUser = await User.fromId(id);
|
const otherUser = await User.fromId(id);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { applyConfig, auth, handleZodError, idValidator } from "@/api";
|
import { applyConfig, auth, handleZodError } from "@/api";
|
||||||
import { errorResponse, jsonResponse } from "@/response";
|
import { errorResponse, jsonResponse } from "@/response";
|
||||||
import { zValidator } from "@hono/zod-validator";
|
import { zValidator } from "@hono/zod-validator";
|
||||||
import type { Hono } from "hono";
|
import type { Hono } from "hono";
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,8 @@ export default (app: Hono) =>
|
||||||
async (context) => {
|
async (context) => {
|
||||||
const { id } = context.req.valid("param");
|
const { id } = context.req.valid("param");
|
||||||
const { user } = context.req.valid("header");
|
const { user } = context.req.valid("header");
|
||||||
const { notifications, duration } = context.req.valid("json");
|
// TODO: Add duration support
|
||||||
|
const { notifications } = context.req.valid("json");
|
||||||
|
|
||||||
if (!user) return errorResponse("Unauthorized", 401);
|
if (!user) return errorResponse("Unauthorized", 401);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { applyConfig, auth, handleZodError, idValidator } from "@/api";
|
import { applyConfig, auth, handleZodError } from "@/api";
|
||||||
import { errorResponse, jsonResponse } from "@/response";
|
import { errorResponse, jsonResponse } from "@/response";
|
||||||
import { zValidator } from "@hono/zod-validator";
|
import { zValidator } from "@hono/zod-validator";
|
||||||
import { and, eq } from "drizzle-orm";
|
import { and, eq } from "drizzle-orm";
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { applyConfig, auth, handleZodError, idValidator, qsQuery } from "@/api";
|
import { applyConfig, auth, handleZodError, qsQuery } from "@/api";
|
||||||
import { errorResponse, jsonResponse } from "@/response";
|
import { errorResponse, jsonResponse } from "@/response";
|
||||||
import { zValidator } from "@hono/zod-validator";
|
import { zValidator } from "@hono/zod-validator";
|
||||||
import { inArray } from "drizzle-orm";
|
import { inArray } from "drizzle-orm";
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,10 @@
|
||||||
import {
|
import { afterEach, describe, expect, test } from "bun:test";
|
||||||
afterAll,
|
|
||||||
afterEach,
|
|
||||||
beforeAll,
|
|
||||||
describe,
|
|
||||||
expect,
|
|
||||||
test,
|
|
||||||
} from "bun:test";
|
|
||||||
import { randomBytes } from "node:crypto";
|
import { randomBytes } from "node:crypto";
|
||||||
import { config } from "config-manager";
|
import { config } from "config-manager";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
import { db } from "~/drizzle/db";
|
import { db } from "~/drizzle/db";
|
||||||
import { Users } from "~/drizzle/schema";
|
import { Users } from "~/drizzle/schema";
|
||||||
import { getTestStatuses, getTestUsers, sendTestRequest } from "~/tests/utils";
|
import { sendTestRequest } from "~/tests/utils";
|
||||||
import type { Account as APIAccount } from "~/types/mastodon/account";
|
|
||||||
import { meta } from "./index";
|
import { meta } from "./index";
|
||||||
|
|
||||||
const username = randomBytes(10).toString("hex");
|
const username = randomBytes(10).toString("hex");
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ export default (app: Hono) =>
|
||||||
auth(meta.auth),
|
auth(meta.auth),
|
||||||
async (context) => {
|
async (context) => {
|
||||||
const form = context.req.valid("form");
|
const form = context.req.valid("form");
|
||||||
const { username, email, password, agreement, locale, reason } =
|
const { username, email, password, agreement, locale } =
|
||||||
context.req.valid("form");
|
context.req.valid("form");
|
||||||
|
|
||||||
if (!config.signups.registration) {
|
if (!config.signups.registration) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { applyConfig, auth, handleZodError, idValidator, qsQuery } from "@/api";
|
import { applyConfig, auth, handleZodError, qsQuery } from "@/api";
|
||||||
import { errorResponse, jsonResponse } from "@/response";
|
import { errorResponse, jsonResponse } from "@/response";
|
||||||
import { zValidator } from "@hono/zod-validator";
|
import { zValidator } from "@hono/zod-validator";
|
||||||
import type { Hono } from "hono";
|
import type { Hono } from "hono";
|
||||||
|
|
|
||||||
|
|
@ -35,10 +35,6 @@ export default (app: Hono) =>
|
||||||
and(isNull(Users.instanceId), eq(Users.isAdmin, true)),
|
and(isNull(Users.instanceId), eq(Users.isAdmin, true)),
|
||||||
);
|
);
|
||||||
|
|
||||||
const monthlyActiveUsers = await User.getActiveInPeriod(
|
|
||||||
30 * 24 * 60 * 60 * 1000,
|
|
||||||
);
|
|
||||||
|
|
||||||
const knownDomainsCount = (
|
const knownDomainsCount = (
|
||||||
await db
|
await db
|
||||||
.select({
|
.select({
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,8 @@
|
||||||
import {
|
import { applyConfig, auth, handleZodError, idValidator } from "@/api";
|
||||||
applyConfig,
|
|
||||||
auth,
|
|
||||||
handleZodError,
|
|
||||||
idValidator,
|
|
||||||
qs,
|
|
||||||
qsQuery,
|
|
||||||
} from "@/api";
|
|
||||||
import { errorResponse, jsonResponse } from "@/response";
|
import { errorResponse, jsonResponse } from "@/response";
|
||||||
import { zValidator } from "@hono/zod-validator";
|
import { zValidator } from "@hono/zod-validator";
|
||||||
import { and, count, eq } from "drizzle-orm";
|
import { and, count, eq } from "drizzle-orm";
|
||||||
import type { Hono } from "hono";
|
import type { Hono } from "hono";
|
||||||
import { validator } from "hono/validator";
|
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { db } from "~/drizzle/db";
|
import { db } from "~/drizzle/db";
|
||||||
import { Markers } from "~/drizzle/schema";
|
import { Markers } from "~/drizzle/schema";
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,7 @@ export default (app: Hono) =>
|
||||||
zValidator("form", schemas.form, handleZodError),
|
zValidator("form", schemas.form, handleZodError),
|
||||||
auth(meta.auth),
|
auth(meta.auth),
|
||||||
async (context) => {
|
async (context) => {
|
||||||
const { file, thumbnail, description, focus } =
|
const { file, thumbnail, description } = context.req.valid("form");
|
||||||
context.req.valid("form");
|
|
||||||
|
|
||||||
if (file.size > config.validation.max_media_size) {
|
if (file.size > config.validation.max_media_size) {
|
||||||
return errorResponse(
|
return errorResponse(
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { applyConfig, auth, handleZodError, idValidator } from "@/api";
|
import { applyConfig, auth, handleZodError } from "@/api";
|
||||||
import { errorResponse, jsonResponse } from "@/response";
|
import { errorResponse, jsonResponse } from "@/response";
|
||||||
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";
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
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 { zValidator } from "@hono/zod-validator";
|
import { zValidator } from "@hono/zod-validator";
|
||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ afterAll(async () => {
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
for (const status of timeline) {
|
for (const status of timeline) {
|
||||||
const res = await sendTestRequest(
|
await sendTestRequest(
|
||||||
new Request(
|
new Request(
|
||||||
new URL(
|
new URL(
|
||||||
`/api/v1/statuses/${status.id}/favourite`,
|
`/api/v1/statuses/${status.id}/favourite`,
|
||||||
|
|
@ -66,7 +66,7 @@ describe(meta.route, () => {
|
||||||
const objects = (await response.json()) as APIAccount[];
|
const objects = (await response.json()) as APIAccount[];
|
||||||
|
|
||||||
expect(objects.length).toBe(1);
|
expect(objects.length).toBe(1);
|
||||||
for (const [index, status] of objects.entries()) {
|
for (const [, status] of objects.entries()) {
|
||||||
expect(status.id).toBe(users[1].id);
|
expect(status.id).toBe(users[1].id);
|
||||||
expect(status.username).toBe(users[1].getUser().username);
|
expect(status.username).toBe(users[1].getUser().username);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ describe(meta.route, () => {
|
||||||
const objects = (await response.json()) as APIAccount[];
|
const objects = (await response.json()) as APIAccount[];
|
||||||
|
|
||||||
expect(objects.length).toBe(1);
|
expect(objects.length).toBe(1);
|
||||||
for (const [index, status] of objects.entries()) {
|
for (const [, status] of objects.entries()) {
|
||||||
expect(status.id).toBe(users[1].id);
|
expect(status.id).toBe(users[1].id);
|
||||||
expect(status.username).toBe(users[1].getUser().username);
|
expect(status.username).toBe(users[1].getUser().username);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { applyConfig, auth, handleZodError, jsonOrForm, qs } from "@/api";
|
import { applyConfig, auth, handleZodError, jsonOrForm } from "@/api";
|
||||||
import { errorResponse, jsonResponse } from "@/response";
|
import { errorResponse, jsonResponse } from "@/response";
|
||||||
import { zValidator } from "@hono/zod-validator";
|
import { zValidator } from "@hono/zod-validator";
|
||||||
import { config } from "config-manager";
|
import { config } from "config-manager";
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import { config } from "config-manager";
|
||||||
import { getTestUsers, sendTestRequest } from "~/tests/utils";
|
import { getTestUsers, sendTestRequest } from "~/tests/utils";
|
||||||
import { meta } from "./index";
|
import { meta } from "./index";
|
||||||
|
|
||||||
const { users, tokens, deleteUsers } = await getTestUsers(2);
|
const { tokens, deleteUsers } = await getTestUsers(2);
|
||||||
|
|
||||||
const response = await sendTestRequest(
|
const response = await sendTestRequest(
|
||||||
new Request(new URL("/api/v2/filters", config.http.base_url), {
|
new Request(new URL("/api/v2/filters", config.http.base_url), {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { applyConfig, auth, handleZodError, jsonOrForm, qs } from "@/api";
|
import { applyConfig, auth, handleZodError, jsonOrForm } from "@/api";
|
||||||
import { errorResponse, jsonResponse } from "@/response";
|
import { errorResponse, jsonResponse } from "@/response";
|
||||||
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";
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import { config } from "config-manager";
|
||||||
import { getTestUsers, sendTestRequest } from "~/tests/utils";
|
import { getTestUsers, sendTestRequest } from "~/tests/utils";
|
||||||
import { meta } from "./index";
|
import { meta } from "./index";
|
||||||
|
|
||||||
const { users, tokens, deleteUsers } = await getTestUsers(2);
|
const { tokens, deleteUsers } = await getTestUsers(2);
|
||||||
|
|
||||||
afterAll(async () => {
|
afterAll(async () => {
|
||||||
await deleteUsers();
|
await deleteUsers();
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
import { applyConfig, auth, handleZodError, jsonOrForm, qs } from "@/api";
|
import { applyConfig, auth, handleZodError, jsonOrForm } from "@/api";
|
||||||
import { errorResponse, jsonResponse } from "@/response";
|
import { errorResponse, jsonResponse } from "@/response";
|
||||||
import { zValidator } from "@hono/zod-validator";
|
import { zValidator } from "@hono/zod-validator";
|
||||||
import type { Hono } from "hono";
|
import type { Hono } from "hono";
|
||||||
import { validator } from "hono/validator";
|
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { db } from "~/drizzle/db";
|
import { db } from "~/drizzle/db";
|
||||||
import { FilterKeywords, Filters } from "~/drizzle/schema";
|
import { FilterKeywords, Filters } from "~/drizzle/schema";
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,7 @@ export default (app: Hono) =>
|
||||||
zValidator("form", schemas.form, handleZodError),
|
zValidator("form", schemas.form, handleZodError),
|
||||||
auth(meta.auth),
|
auth(meta.auth),
|
||||||
async (context) => {
|
async (context) => {
|
||||||
const { file, thumbnail, description, focus } =
|
const { file, thumbnail, description } = context.req.valid("form");
|
||||||
context.req.valid("form");
|
|
||||||
|
|
||||||
if (file.size > config.validation.max_media_size) {
|
if (file.size > config.validation.max_media_size) {
|
||||||
return errorResponse(
|
return errorResponse(
|
||||||
|
|
|
||||||
|
|
@ -84,15 +84,8 @@ export default (app: Hono) =>
|
||||||
zValidator("query", schemas.query, handleZodError),
|
zValidator("query", schemas.query, handleZodError),
|
||||||
zValidator("form", schemas.form, handleZodError),
|
zValidator("form", schemas.form, handleZodError),
|
||||||
async (context) => {
|
async (context) => {
|
||||||
const {
|
const { scope, redirect_uri, response_type, client_id, state } =
|
||||||
scope,
|
context.req.valid("form");
|
||||||
redirect_uri,
|
|
||||||
response_type,
|
|
||||||
client_id,
|
|
||||||
state,
|
|
||||||
code_challenge,
|
|
||||||
code_challenge_method,
|
|
||||||
} = context.req.valid("form");
|
|
||||||
|
|
||||||
const body = context.req.valid("form");
|
const body = context.req.valid("form");
|
||||||
|
|
||||||
|
|
@ -234,7 +227,6 @@ export default (app: Hono) =>
|
||||||
const scopeIncludesProfile = scope?.split(" ").includes("profile");
|
const scopeIncludesProfile = scope?.split(" ").includes("profile");
|
||||||
const scopeIncludesEmail = scope?.split(" ").includes("email");
|
const scopeIncludesEmail = scope?.split(" ").includes("email");
|
||||||
if (scope) {
|
if (scope) {
|
||||||
const scopes = scope.split(" ");
|
|
||||||
if (scopeIncludesOpenID) {
|
if (scopeIncludesOpenID) {
|
||||||
// Include the standard OpenID claims
|
// Include the standard OpenID claims
|
||||||
idTokenPayload = {
|
idTokenPayload = {
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@
|
||||||
"@/*": ["./utils/*"],
|
"@/*": ["./utils/*"],
|
||||||
"~/*": ["./*"],
|
"~/*": ["./*"],
|
||||||
"+/*": ["./server/api/*"]
|
"+/*": ["./server/api/*"]
|
||||||
}
|
},
|
||||||
|
"noUnusedLocals": true
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"*.ts",
|
"*.ts",
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
import { consoleLogger } from "@/loggers";
|
|
||||||
import { errorResponse } from "@/response";
|
import { errorResponse } from "@/response";
|
||||||
import chalk from "chalk";
|
import chalk from "chalk";
|
||||||
import { config } from "config-manager";
|
import { config } from "config-manager";
|
||||||
|
|
|
||||||
|
|
@ -27,19 +27,6 @@ export const response = (
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
export const clientResponse = (
|
|
||||||
data: BodyInit | null = null,
|
|
||||||
status = 200,
|
|
||||||
headers: Record<string, string> = {},
|
|
||||||
) => {
|
|
||||||
return response(data, status, {
|
|
||||||
"Content-Security-Policy":
|
|
||||||
"default-src 'none'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src *; font-src 'self'; connect-src 'self'; media-src *; object-src 'none'; prefetch-src 'none'; child-src 'none'; frame-src 'none'; worker-src 'self'; frame-ancestors 'none'; form-action 'self'; upgrade-insecure-requests; block-all-mixed-content; base-uri 'self'; manifest-src 'self'",
|
|
||||||
"Access-Control-Allow-Origin": "null",
|
|
||||||
...headers,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
export const jsonResponse = (
|
export const jsonResponse = (
|
||||||
data: object,
|
data: object,
|
||||||
status = 200,
|
status = 200,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue