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 = {};
|
||||
|
||||
public async run(): Promise<void> {
|
||||
const { flags, args } = await this.parse(EmojiAdd);
|
||||
const { args } = await this.parse(EmojiAdd);
|
||||
|
||||
// Check if emoji already exists
|
||||
const existingEmoji = await db.query.Emojis.findFirst({
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import confirm from "@inquirer/confirm";
|
||||
import { Args, Flags } from "@oclif/core";
|
||||
import { Flags } from "@oclif/core";
|
||||
import chalk from "chalk";
|
||||
import { and, eq, inArray, isNull } from "drizzle-orm";
|
||||
import { eq } from "drizzle-orm";
|
||||
import ora from "ora";
|
||||
import { EmojiFinderCommand } from "~/cli/classes";
|
||||
import { formatArray } from "~/cli/utils/format";
|
||||
|
|
@ -34,7 +34,7 @@ export default class EmojiDelete extends EmojiFinderCommand<
|
|||
};
|
||||
|
||||
public async run(): Promise<void> {
|
||||
const { flags, args } = await this.parse(EmojiDelete);
|
||||
const { flags } = await this.parse(EmojiDelete);
|
||||
|
||||
const emojis = await this.findEmojis();
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ export default class EmojiImport extends BaseCommand<typeof EmojiImport> {
|
|||
};
|
||||
|
||||
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
|
||||
if (!args.path.endsWith(".zip")) {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ export default class UserDelete extends UserFinderCommand<typeof UserDelete> {
|
|||
};
|
||||
|
||||
public async run(): Promise<void> {
|
||||
const { flags, args } = await this.parse(UserDelete);
|
||||
const { flags } = await this.parse(UserDelete);
|
||||
|
||||
const users = await this.findUsers();
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ export default class UserReset extends UserFinderCommand<typeof UserReset> {
|
|||
};
|
||||
|
||||
public async run(): Promise<void> {
|
||||
const { flags, args } = await this.parse(UserReset);
|
||||
const { flags } = await this.parse(UserReset);
|
||||
|
||||
const users = await this.findUsers();
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import { db } from "~/drizzle/db";
|
|||
import { Relationships } from "~/drizzle/schema";
|
||||
import type { User } from "~/packages/database-interface/user";
|
||||
import type { Relationship as APIRelationship } from "~/types/mastodon/relationship";
|
||||
import type { UserType } from "./User";
|
||||
|
||||
export type Relationship = InferSelectModel<typeof Relationships>;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ import {
|
|||
exactly,
|
||||
global,
|
||||
letter,
|
||||
maybe,
|
||||
oneOrMore,
|
||||
} from "magic-regexp";
|
||||
import MarkdownIt from "markdown-it";
|
||||
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 { ipBans } from "~/middlewares/ip-bans";
|
||||
import { logger } from "~/middlewares/logger";
|
||||
import { urlCheck } from "~/middlewares/url-check";
|
||||
import { Note } from "~/packages/database-interface/note";
|
||||
import { handleGlitchRequest } from "~/packages/glitch-server/main";
|
||||
import { routes } from "~/routes";
|
||||
|
|
@ -122,7 +121,7 @@ app.use(boundaryCheck);
|
|||
// app.use(urlCheck);
|
||||
|
||||
// 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
|
||||
const route: APIRouteExports = await import(path);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { oauthRedirectUri } from "@/constants";
|
||||
import { errorResponse, response } from "@/response";
|
||||
import { response } from "@/response";
|
||||
import type { InferInsertModel } from "drizzle-orm";
|
||||
import {
|
||||
type AuthorizationServer,
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ describe("LocalMediaBackend", () => {
|
|||
// deleteByUrl
|
||||
const mockHash = "test-hash";
|
||||
spyOn(mockMediaHasher, "getMediaHash").mockResolvedValue(mockHash);
|
||||
const result = await localMediaBackend.addFile(mockFile);
|
||||
await localMediaBackend.addFile(mockFile);
|
||||
const rmMock = jest.fn().mockResolvedValue(Promise.resolve());
|
||||
|
||||
// Spy on fs/promises rm
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { applyConfig, handleZodError } from "@/api";
|
||||
import { errorResponse, redirect, response } from "@/response";
|
||||
import { errorResponse, response } from "@/response";
|
||||
import { zValidator } from "@hono/zod-validator";
|
||||
import { eq, or } from "drizzle-orm";
|
||||
import type { Hono } from "hono";
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ export default (app: Hono) =>
|
|||
auth(meta.auth),
|
||||
async (context) => {
|
||||
const { id } = context.req.valid("param");
|
||||
const { user } = context.req.valid("header");
|
||||
const { max_id, since_id, min_id, limit } =
|
||||
context.req.valid("query");
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ export default (app: Hono) =>
|
|||
auth(meta.auth),
|
||||
async (context) => {
|
||||
const { id } = context.req.valid("param");
|
||||
const { user } = context.req.valid("header");
|
||||
const { max_id, since_id, min_id } = context.req.valid("query");
|
||||
|
||||
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 { zValidator } from "@hono/zod-validator";
|
||||
import type { Hono } from "hono";
|
||||
|
|
|
|||
|
|
@ -48,7 +48,8 @@ export default (app: Hono) =>
|
|||
async (context) => {
|
||||
const { id } = context.req.valid("param");
|
||||
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);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { applyConfig, auth, handleZodError, idValidator } from "@/api";
|
||||
import { applyConfig, auth, handleZodError } from "@/api";
|
||||
import { errorResponse, jsonResponse } from "@/response";
|
||||
import { zValidator } from "@hono/zod-validator";
|
||||
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 { zValidator } from "@hono/zod-validator";
|
||||
import { inArray } from "drizzle-orm";
|
||||
|
|
|
|||
|
|
@ -1,18 +1,10 @@
|
|||
import {
|
||||
afterAll,
|
||||
afterEach,
|
||||
beforeAll,
|
||||
describe,
|
||||
expect,
|
||||
test,
|
||||
} from "bun:test";
|
||||
import { afterEach, describe, expect, test } from "bun:test";
|
||||
import { randomBytes } from "node:crypto";
|
||||
import { config } from "config-manager";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { db } from "~/drizzle/db";
|
||||
import { Users } from "~/drizzle/schema";
|
||||
import { getTestStatuses, getTestUsers, sendTestRequest } from "~/tests/utils";
|
||||
import type { Account as APIAccount } from "~/types/mastodon/account";
|
||||
import { sendTestRequest } from "~/tests/utils";
|
||||
import { meta } from "./index";
|
||||
|
||||
const username = randomBytes(10).toString("hex");
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ export default (app: Hono) =>
|
|||
auth(meta.auth),
|
||||
async (context) => {
|
||||
const form = context.req.valid("form");
|
||||
const { username, email, password, agreement, locale, reason } =
|
||||
const { username, email, password, agreement, locale } =
|
||||
context.req.valid("form");
|
||||
|
||||
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 { zValidator } from "@hono/zod-validator";
|
||||
import type { Hono } from "hono";
|
||||
|
|
|
|||
|
|
@ -35,10 +35,6 @@ export default (app: Hono) =>
|
|||
and(isNull(Users.instanceId), eq(Users.isAdmin, true)),
|
||||
);
|
||||
|
||||
const monthlyActiveUsers = await User.getActiveInPeriod(
|
||||
30 * 24 * 60 * 60 * 1000,
|
||||
);
|
||||
|
||||
const knownDomainsCount = (
|
||||
await db
|
||||
.select({
|
||||
|
|
|
|||
|
|
@ -1,16 +1,8 @@
|
|||
import {
|
||||
applyConfig,
|
||||
auth,
|
||||
handleZodError,
|
||||
idValidator,
|
||||
qs,
|
||||
qsQuery,
|
||||
} from "@/api";
|
||||
import { applyConfig, auth, handleZodError, idValidator } from "@/api";
|
||||
import { errorResponse, jsonResponse } from "@/response";
|
||||
import { zValidator } from "@hono/zod-validator";
|
||||
import { and, count, eq } from "drizzle-orm";
|
||||
import type { Hono } from "hono";
|
||||
import { validator } from "hono/validator";
|
||||
import { z } from "zod";
|
||||
import { db } from "~/drizzle/db";
|
||||
import { Markers } from "~/drizzle/schema";
|
||||
|
|
|
|||
|
|
@ -45,8 +45,7 @@ export default (app: Hono) =>
|
|||
zValidator("form", schemas.form, handleZodError),
|
||||
auth(meta.auth),
|
||||
async (context) => {
|
||||
const { file, thumbnail, description, focus } =
|
||||
context.req.valid("form");
|
||||
const { file, thumbnail, description } = context.req.valid("form");
|
||||
|
||||
if (file.size > config.validation.max_media_size) {
|
||||
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 { zValidator } from "@hono/zod-validator";
|
||||
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 { zValidator } from "@hono/zod-validator";
|
||||
import { eq } from "drizzle-orm";
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ afterAll(async () => {
|
|||
|
||||
beforeAll(async () => {
|
||||
for (const status of timeline) {
|
||||
const res = await sendTestRequest(
|
||||
await sendTestRequest(
|
||||
new Request(
|
||||
new URL(
|
||||
`/api/v1/statuses/${status.id}/favourite`,
|
||||
|
|
@ -66,7 +66,7 @@ describe(meta.route, () => {
|
|||
const objects = (await response.json()) as APIAccount[];
|
||||
|
||||
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.username).toBe(users[1].getUser().username);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ describe(meta.route, () => {
|
|||
const objects = (await response.json()) as APIAccount[];
|
||||
|
||||
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.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 { zValidator } from "@hono/zod-validator";
|
||||
import { config } from "config-manager";
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { config } from "config-manager";
|
|||
import { getTestUsers, sendTestRequest } from "~/tests/utils";
|
||||
import { meta } from "./index";
|
||||
|
||||
const { users, tokens, deleteUsers } = await getTestUsers(2);
|
||||
const { tokens, deleteUsers } = await getTestUsers(2);
|
||||
|
||||
const response = await sendTestRequest(
|
||||
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 { zValidator } from "@hono/zod-validator";
|
||||
import { and, eq, inArray } from "drizzle-orm";
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { config } from "config-manager";
|
|||
import { getTestUsers, sendTestRequest } from "~/tests/utils";
|
||||
import { meta } from "./index";
|
||||
|
||||
const { users, tokens, deleteUsers } = await getTestUsers(2);
|
||||
const { tokens, deleteUsers } = await getTestUsers(2);
|
||||
|
||||
afterAll(async () => {
|
||||
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 { zValidator } from "@hono/zod-validator";
|
||||
import type { Hono } from "hono";
|
||||
import { validator } from "hono/validator";
|
||||
import { z } from "zod";
|
||||
import { db } from "~/drizzle/db";
|
||||
import { FilterKeywords, Filters } from "~/drizzle/schema";
|
||||
|
|
|
|||
|
|
@ -45,8 +45,7 @@ export default (app: Hono) =>
|
|||
zValidator("form", schemas.form, handleZodError),
|
||||
auth(meta.auth),
|
||||
async (context) => {
|
||||
const { file, thumbnail, description, focus } =
|
||||
context.req.valid("form");
|
||||
const { file, thumbnail, description } = context.req.valid("form");
|
||||
|
||||
if (file.size > config.validation.max_media_size) {
|
||||
return errorResponse(
|
||||
|
|
|
|||
|
|
@ -84,15 +84,8 @@ export default (app: Hono) =>
|
|||
zValidator("query", schemas.query, handleZodError),
|
||||
zValidator("form", schemas.form, handleZodError),
|
||||
async (context) => {
|
||||
const {
|
||||
scope,
|
||||
redirect_uri,
|
||||
response_type,
|
||||
client_id,
|
||||
state,
|
||||
code_challenge,
|
||||
code_challenge_method,
|
||||
} = context.req.valid("form");
|
||||
const { scope, redirect_uri, response_type, client_id, state } =
|
||||
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 scopeIncludesEmail = scope?.split(" ").includes("email");
|
||||
if (scope) {
|
||||
const scopes = scope.split(" ");
|
||||
if (scopeIncludesOpenID) {
|
||||
// Include the standard OpenID claims
|
||||
idTokenPayload = {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,8 @@
|
|||
"@/*": ["./utils/*"],
|
||||
"~/*": ["./*"],
|
||||
"+/*": ["./server/api/*"]
|
||||
}
|
||||
},
|
||||
"noUnusedLocals": true
|
||||
},
|
||||
"include": [
|
||||
"*.ts",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
import { consoleLogger } from "@/loggers";
|
||||
import { errorResponse } from "@/response";
|
||||
import chalk from "chalk";
|
||||
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 = (
|
||||
data: object,
|
||||
status = 200,
|
||||
|
|
|
|||
Loading…
Reference in a new issue