diff --git a/api/api/auth/login/index.test.ts b/api/api/auth/login/index.test.ts
index 6b5ea302..29bf7885 100644
--- a/api/api/auth/login/index.test.ts
+++ b/api/api/auth/login/index.test.ts
@@ -3,7 +3,6 @@ import { randomString } from "@/math";
import { Application } from "@versia/kit/db";
import { config } from "~/packages/config-manager";
import { fakeRequest, getTestUsers } from "~/tests/utils";
-import { meta } from "./index.ts";
const { users, deleteUsers, passwords } = await getTestUsers(1);
@@ -22,7 +21,7 @@ afterAll(async () => {
});
// /api/auth/login
-describe(meta.route, () => {
+describe("/api/auth/login", () => {
test("should get a JWT with email", async () => {
const formData = new FormData();
diff --git a/api/api/auth/login/index.ts b/api/api/auth/login/index.ts
index 549f1e2a..5d076751 100644
--- a/api/api/auth/login/index.ts
+++ b/api/api/auth/login/index.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig } from "@/api";
+import { apiRoute } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { Application, User } from "@versia/kit/db";
import { Users } from "@versia/kit/tables";
@@ -10,17 +10,6 @@ import { z } from "zod";
import { ApiError } from "~/classes/errors/api-error";
import { config } from "~/packages/config-manager";
-export const meta = applyConfig({
- ratelimits: {
- max: 4,
- duration: 60,
- },
- route: "/api/auth/login",
- auth: {
- required: false,
- },
-});
-
export const schemas = {
form: z.object({
identifier: z
diff --git a/api/api/auth/redirect/index.ts b/api/api/auth/redirect/index.ts
index 229f1f54..6e281c8f 100644
--- a/api/api/auth/redirect/index.ts
+++ b/api/api/auth/redirect/index.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig } from "@/api";
+import { apiRoute } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { db } from "@versia/kit/db";
import { Applications, Tokens } from "@versia/kit/tables";
@@ -6,17 +6,6 @@ import { and, eq } from "drizzle-orm";
import { z } from "zod";
import { config } from "~/packages/config-manager";
-export const meta = applyConfig({
- ratelimits: {
- max: 4,
- duration: 60,
- },
- route: "/api/auth/redirect",
- auth: {
- required: false,
- },
-});
-
export const schemas = {
query: z.object({
redirect_uri: z.string().url(),
diff --git a/api/api/auth/reset/index.test.ts b/api/api/auth/reset/index.test.ts
index 9b2e6b9f..3488f267 100644
--- a/api/api/auth/reset/index.test.ts
+++ b/api/api/auth/reset/index.test.ts
@@ -3,7 +3,6 @@ import { randomString } from "@/math";
import { Application } from "@versia/kit/db";
import { config } from "~/packages/config-manager";
import { fakeRequest, getTestUsers } from "~/tests/utils";
-import { meta } from "./index.ts";
const { users, deleteUsers, passwords } = await getTestUsers(1);
const token = randomString(32, "hex");
@@ -24,7 +23,7 @@ afterAll(async () => {
});
// /api/auth/reset
-describe(meta.route, () => {
+describe("/api/auth/reset", () => {
test("should login with normal password", async () => {
const formData = new FormData();
diff --git a/api/api/auth/reset/index.ts b/api/api/auth/reset/index.ts
index 737ba1ee..fbdd6842 100644
--- a/api/api/auth/reset/index.ts
+++ b/api/api/auth/reset/index.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig } from "@/api";
+import { apiRoute } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { User } from "@versia/kit/db";
import { Users } from "@versia/kit/tables";
@@ -7,17 +7,6 @@ import type { Context } from "hono";
import { z } from "zod";
import { config } from "~/packages/config-manager";
-export const meta = applyConfig({
- ratelimits: {
- max: 4,
- duration: 60,
- },
- route: "/api/auth/reset",
- auth: {
- required: false,
- },
-});
-
export const schemas = {
form: z.object({
token: z.string().min(1),
diff --git a/api/api/v1/accounts/:id/block.test.ts b/api/api/v1/accounts/:id/block.test.ts
index 7bad98cd..c9680d68 100644
--- a/api/api/v1/accounts/:id/block.test.ts
+++ b/api/api/v1/accounts/:id/block.test.ts
@@ -1,7 +1,6 @@
import { afterAll, describe, expect, test } from "bun:test";
import type { Relationship as ApiRelationship } from "@versia/client/types";
import { fakeRequest, getTestUsers } from "~/tests/utils";
-import { meta } from "./block.ts";
const { users, tokens, deleteUsers } = await getTestUsers(2);
@@ -10,10 +9,10 @@ afterAll(async () => {
});
// /api/v1/accounts/:id/block
-describe(meta.route, () => {
+describe("/api/v1/accounts/:id/block", () => {
test("should return 401 if not authenticated", async () => {
const response = await fakeRequest(
- meta.route.replace(":id", users[1].id),
+ `/api/v1/accounts/${users[1].id}/block`,
{
method: "POST",
},
@@ -23,7 +22,7 @@ describe(meta.route, () => {
test("should return 404 if user not found", async () => {
const response = await fakeRequest(
- meta.route.replace(":id", "00000000-0000-0000-0000-000000000000"),
+ "/api/v1/accounts/00000000-0000-0000-0000-000000000000/block",
{
method: "POST",
headers: {
@@ -36,7 +35,7 @@ describe(meta.route, () => {
test("should block user", async () => {
const response = await fakeRequest(
- meta.route.replace(":id", users[1].id),
+ `/api/v1/accounts/${users[1].id}/block`,
{
method: "POST",
headers: {
@@ -52,7 +51,7 @@ describe(meta.route, () => {
test("should return 200 if user already blocked", async () => {
const response = await fakeRequest(
- meta.route.replace(":id", users[1].id),
+ `/api/v1/accounts/${users[1].id}/block`,
{
method: "POST",
headers: {
diff --git a/api/api/v1/accounts/:id/block.ts b/api/api/v1/accounts/:id/block.ts
index 57fc0f3e..2855a77d 100644
--- a/api/api/v1/accounts/:id/block.ts
+++ b/api/api/v1/accounts/:id/block.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig, auth } from "@/api";
+import { apiRoute, auth } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { Relationship, User } from "@versia/kit/db";
import { RolePermissions } from "@versia/kit/tables";
@@ -6,24 +6,6 @@ import { z } from "zod";
import { ApiError } from "~/classes/errors/api-error";
import { ErrorSchema } from "~/types/api";
-export const meta = applyConfig({
- ratelimits: {
- max: 30,
- duration: 60,
- },
- route: "/api/v1/accounts/:id/block",
- auth: {
- required: true,
- oauthPermissions: ["write:blocks"],
- },
- permissions: {
- required: [
- RolePermissions.ManageOwnBlocks,
- RolePermissions.ViewAccounts,
- ],
- },
-});
-
export const schemas = {
param: z.object({
id: z.string().uuid(),
diff --git a/api/api/v1/accounts/:id/follow.test.ts b/api/api/v1/accounts/:id/follow.test.ts
index a8c5efcf..d6d828b0 100644
--- a/api/api/v1/accounts/:id/follow.test.ts
+++ b/api/api/v1/accounts/:id/follow.test.ts
@@ -1,7 +1,6 @@
import { afterAll, describe, expect, test } from "bun:test";
import type { Relationship as ApiRelationship } from "@versia/client/types";
import { fakeRequest, getTestUsers } from "~/tests/utils";
-import { meta } from "./follow.ts";
const { users, tokens, deleteUsers } = await getTestUsers(2);
@@ -10,10 +9,10 @@ afterAll(async () => {
});
// /api/v1/accounts/:id/follow
-describe(meta.route, () => {
+describe("/api/v1/accounts/:id/follow", () => {
test("should return 401 if not authenticated", async () => {
const response = await fakeRequest(
- meta.route.replace(":id", users[1].id),
+ `/api/v1/accounts/${users[1].id}/follow`,
{
method: "POST",
headers: {
@@ -27,7 +26,7 @@ describe(meta.route, () => {
test("should return 404 if user not found", async () => {
const response = await fakeRequest(
- meta.route.replace(":id", "00000000-0000-0000-0000-000000000000"),
+ "/api/v1/accounts/00000000-0000-0000-0000-000000000000/follow",
{
method: "POST",
headers: {
@@ -42,7 +41,7 @@ describe(meta.route, () => {
test("should follow user", async () => {
const response = await fakeRequest(
- meta.route.replace(":id", users[1].id),
+ `/api/v1/accounts/${users[1].id}/follow`,
{
method: "POST",
headers: {
@@ -60,7 +59,7 @@ describe(meta.route, () => {
test("should return 200 if user already followed", async () => {
const response = await fakeRequest(
- meta.route.replace(":id", users[1].id),
+ `/api/v1/accounts/${users[1].id}/follow`,
{
method: "POST",
headers: {
diff --git a/api/api/v1/accounts/:id/follow.ts b/api/api/v1/accounts/:id/follow.ts
index a90e1408..d4ad42bf 100644
--- a/api/api/v1/accounts/:id/follow.ts
+++ b/api/api/v1/accounts/:id/follow.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig, auth } from "@/api";
+import { apiRoute, auth } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { Relationship, User } from "@versia/kit/db";
import { RolePermissions } from "@versia/kit/tables";
@@ -7,24 +7,6 @@ import { z } from "zod";
import { ApiError } from "~/classes/errors/api-error";
import { ErrorSchema } from "~/types/api";
-export const meta = applyConfig({
- ratelimits: {
- max: 30,
- duration: 60,
- },
- route: "/api/v1/accounts/:id/follow",
- auth: {
- required: true,
- oauthPermissions: ["write:follows"],
- },
- permissions: {
- required: [
- RolePermissions.ManageOwnFollows,
- RolePermissions.ViewAccounts,
- ],
- },
-});
-
export const schemas = {
param: z.object({
id: z.string().uuid(),
diff --git a/api/api/v1/accounts/:id/followers.test.ts b/api/api/v1/accounts/:id/followers.test.ts
index b356e528..017c97d9 100644
--- a/api/api/v1/accounts/:id/followers.test.ts
+++ b/api/api/v1/accounts/:id/followers.test.ts
@@ -1,7 +1,6 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import type { Account as ApiAccount } from "@versia/client/types";
import { fakeRequest, getTestUsers } from "~/tests/utils";
-import { meta } from "./followers.ts";
const { users, tokens, deleteUsers } = await getTestUsers(5);
@@ -27,10 +26,10 @@ beforeAll(async () => {
});
// /api/v1/accounts/:id/followers
-describe(meta.route, () => {
+describe("/api/v1/accounts/:id/followers", () => {
test("should return 200 with followers", async () => {
const response = await fakeRequest(
- meta.route.replace(":id", users[1].id),
+ `/api/v1/accounts/${users[1].id}/followers`,
{
headers: {
Authorization: `Bearer ${tokens[0].data.accessToken}`,
@@ -62,7 +61,7 @@ describe(meta.route, () => {
expect(response.status).toBe(200);
const response2 = await fakeRequest(
- meta.route.replace(":id", users[1].id),
+ `/api/v1/accounts/${users[1].id}/followers`,
{
headers: {
Authorization: `Bearer ${tokens[0].data.accessToken}`,
diff --git a/api/api/v1/accounts/:id/followers.ts b/api/api/v1/accounts/:id/followers.ts
index 2e0ba0c1..01e41a63 100644
--- a/api/api/v1/accounts/:id/followers.ts
+++ b/api/api/v1/accounts/:id/followers.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig, auth, idValidator } from "@/api";
+import { apiRoute, auth, idValidator } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { Timeline, User } from "@versia/kit/db";
import { RolePermissions, Users } from "@versia/kit/tables";
@@ -7,24 +7,6 @@ import { z } from "zod";
import { ApiError } from "~/classes/errors/api-error";
import { ErrorSchema } from "~/types/api";
-export const meta = applyConfig({
- ratelimits: {
- max: 60,
- duration: 60,
- },
- route: "/api/v1/accounts/:id/followers",
- auth: {
- required: false,
- oauthPermissions: ["read:accounts"],
- },
- permissions: {
- required: [
- RolePermissions.ViewAccountFollows,
- RolePermissions.ViewAccounts,
- ],
- },
-});
-
export const schemas = {
query: z.object({
max_id: z.string().regex(idValidator).optional(),
diff --git a/api/api/v1/accounts/:id/following.test.ts b/api/api/v1/accounts/:id/following.test.ts
index a1273c1a..a0393e5c 100644
--- a/api/api/v1/accounts/:id/following.test.ts
+++ b/api/api/v1/accounts/:id/following.test.ts
@@ -1,7 +1,6 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import type { Account as ApiAccount } from "@versia/client/types";
import { fakeRequest, getTestUsers } from "~/tests/utils";
-import { meta } from "./following.ts";
const { users, tokens, deleteUsers } = await getTestUsers(5);
@@ -27,10 +26,10 @@ beforeAll(async () => {
});
// /api/v1/accounts/:id/following
-describe(meta.route, () => {
+describe("/api/v1/accounts/:id/following", () => {
test("should return 200 with following", async () => {
const response = await fakeRequest(
- meta.route.replace(":id", users[0].id),
+ `/api/v1/accounts/${users[0].id}/following`,
{
headers: {
Authorization: `Bearer ${tokens[1].data.accessToken}`,
@@ -62,7 +61,7 @@ describe(meta.route, () => {
expect(response.status).toBe(200);
const response2 = await fakeRequest(
- meta.route.replace(":id", users[0].id),
+ `/api/v1/accounts/${users[0].id}/following`,
{
headers: {
Authorization: `Bearer ${tokens[1].data.accessToken}`,
diff --git a/api/api/v1/accounts/:id/following.ts b/api/api/v1/accounts/:id/following.ts
index 6a2d36ba..d3af4254 100644
--- a/api/api/v1/accounts/:id/following.ts
+++ b/api/api/v1/accounts/:id/following.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig, auth, idValidator } from "@/api";
+import { apiRoute, auth, idValidator } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { Timeline, User } from "@versia/kit/db";
import { RolePermissions, Users } from "@versia/kit/tables";
@@ -7,24 +7,6 @@ import { z } from "zod";
import { ApiError } from "~/classes/errors/api-error";
import { ErrorSchema } from "~/types/api";
-export const meta = applyConfig({
- ratelimits: {
- max: 60,
- duration: 60,
- },
- route: "/api/v1/accounts/:id/following",
- auth: {
- required: false,
- oauthPermissions: ["read:accounts"],
- },
- permissions: {
- required: [
- RolePermissions.ViewAccountFollows,
- RolePermissions.ViewAccounts,
- ],
- },
-});
-
export const schemas = {
query: z.object({
max_id: z.string().regex(idValidator).optional(),
diff --git a/api/api/v1/accounts/:id/index.test.ts b/api/api/v1/accounts/:id/index.test.ts
index a0de3c04..aa42b7cd 100644
--- a/api/api/v1/accounts/:id/index.test.ts
+++ b/api/api/v1/accounts/:id/index.test.ts
@@ -1,7 +1,6 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import type { Account as ApiAccount } from "@versia/client/types";
import { fakeRequest, getTestStatuses, getTestUsers } from "~/tests/utils";
-import { meta } from "./index.ts";
const { users, tokens, deleteUsers } = await getTestUsers(5);
const timeline = (await getTestStatuses(40, users[0])).toReversed();
@@ -24,18 +23,14 @@ beforeAll(async () => {
});
// /api/v1/accounts/:id
-describe(meta.route, () => {
+describe("/api/v1/accounts/:id", () => {
test("should return 404 if ID is invalid", async () => {
- const response = await fakeRequest(
- meta.route.replace(":id", "invalid"),
- );
+ const response = await fakeRequest("/api/v1/accounts/invalid-id");
expect(response.status).toBe(422);
});
test("should return user", async () => {
- const response = await fakeRequest(
- meta.route.replace(":id", users[0].id),
- );
+ const response = await fakeRequest(`/api/v1/accounts/${users[0].id}`);
expect(response.status).toBe(200);
diff --git a/api/api/v1/accounts/:id/index.ts b/api/api/v1/accounts/:id/index.ts
index 60b5400f..0fbc6e67 100644
--- a/api/api/v1/accounts/:id/index.ts
+++ b/api/api/v1/accounts/:id/index.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig, auth } from "@/api";
+import { apiRoute, auth } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { User } from "@versia/kit/db";
import { RolePermissions } from "@versia/kit/tables";
@@ -6,21 +6,6 @@ import { z } from "zod";
import { ApiError } from "~/classes/errors/api-error";
import { ErrorSchema } from "~/types/api";
-export const meta = applyConfig({
- ratelimits: {
- max: 30,
- duration: 60,
- },
- route: "/api/v1/accounts/:id",
- auth: {
- required: false,
- oauthPermissions: [],
- },
- permissions: {
- required: [RolePermissions.ViewAccounts],
- },
-});
-
export const schemas = {
param: z.object({
id: z.string().uuid(),
diff --git a/api/api/v1/accounts/:id/mute.test.ts b/api/api/v1/accounts/:id/mute.test.ts
index c1b8bc3b..8a2f1cd5 100644
--- a/api/api/v1/accounts/:id/mute.test.ts
+++ b/api/api/v1/accounts/:id/mute.test.ts
@@ -1,7 +1,6 @@
import { afterAll, describe, expect, test } from "bun:test";
import type { Relationship as ApiRelationship } from "@versia/client/types";
import { fakeRequest, getTestUsers } from "~/tests/utils";
-import { meta } from "./mute.ts";
const { users, tokens, deleteUsers } = await getTestUsers(2);
@@ -10,10 +9,10 @@ afterAll(async () => {
});
// /api/v1/accounts/:id/mute
-describe(meta.route, () => {
+describe("/api/v1/accounts/:id/mute", () => {
test("should return 401 if not authenticated", async () => {
const response = await fakeRequest(
- meta.route.replace(":id", users[1].id),
+ `/api/v1/accounts/${users[1].id}/mute`,
{
method: "POST",
headers: {
@@ -27,7 +26,7 @@ describe(meta.route, () => {
test("should return 404 if user not found", async () => {
const response = await fakeRequest(
- meta.route.replace(":id", "00000000-0000-0000-0000-000000000000"),
+ "/api/v1/accounts/00000000-0000-0000-0000-000000000000/mute",
{
method: "POST",
headers: {
@@ -42,7 +41,7 @@ describe(meta.route, () => {
test("should mute user", async () => {
const response = await fakeRequest(
- meta.route.replace(":id", users[1].id),
+ `/api/v1/accounts/${users[1].id}/mute`,
{
method: "POST",
headers: {
@@ -60,7 +59,7 @@ describe(meta.route, () => {
test("should return 200 if user already muted", async () => {
const response = await fakeRequest(
- meta.route.replace(":id", users[1].id),
+ `/api/v1/accounts/${users[1].id}/mute`,
{
method: "POST",
headers: {
diff --git a/api/api/v1/accounts/:id/mute.ts b/api/api/v1/accounts/:id/mute.ts
index af10d045..07411f73 100644
--- a/api/api/v1/accounts/:id/mute.ts
+++ b/api/api/v1/accounts/:id/mute.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig, auth } from "@/api";
+import { apiRoute, auth } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { Relationship, User } from "@versia/kit/db";
import { RolePermissions } from "@versia/kit/tables";
@@ -6,24 +6,6 @@ import { z } from "zod";
import { ApiError } from "~/classes/errors/api-error";
import { ErrorSchema } from "~/types/api";
-export const meta = applyConfig({
- ratelimits: {
- max: 30,
- duration: 60,
- },
- route: "/api/v1/accounts/:id/mute",
- auth: {
- required: true,
- oauthPermissions: ["write:mutes"],
- },
- permissions: {
- required: [
- RolePermissions.ManageOwnMutes,
- RolePermissions.ViewAccounts,
- ],
- },
-});
-
export const schemas = {
param: z.object({
id: z.string().uuid(),
diff --git a/api/api/v1/accounts/:id/note.ts b/api/api/v1/accounts/:id/note.ts
index 10e95071..97f4c3f6 100644
--- a/api/api/v1/accounts/:id/note.ts
+++ b/api/api/v1/accounts/:id/note.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig, auth } from "@/api";
+import { apiRoute, auth } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { Relationship, User } from "@versia/kit/db";
import { RolePermissions } from "@versia/kit/tables";
@@ -6,24 +6,6 @@ import { z } from "zod";
import { ApiError } from "~/classes/errors/api-error";
import { ErrorSchema } from "~/types/api";
-export const meta = applyConfig({
- ratelimits: {
- max: 30,
- duration: 60,
- },
- route: "/api/v1/accounts/:id/note",
- auth: {
- required: true,
- oauthPermissions: ["write:accounts"],
- },
- permissions: {
- required: [
- RolePermissions.ManageOwnAccount,
- RolePermissions.ViewAccounts,
- ],
- },
-});
-
export const schemas = {
param: z.object({
id: z.string().uuid(),
diff --git a/api/api/v1/accounts/:id/pin.ts b/api/api/v1/accounts/:id/pin.ts
index 14970a83..44ded7cf 100644
--- a/api/api/v1/accounts/:id/pin.ts
+++ b/api/api/v1/accounts/:id/pin.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig, auth } from "@/api";
+import { apiRoute, auth } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { Relationship, User } from "@versia/kit/db";
import { RolePermissions } from "@versia/kit/tables";
@@ -6,24 +6,6 @@ import { z } from "zod";
import { ApiError } from "~/classes/errors/api-error";
import { ErrorSchema } from "~/types/api";
-export const meta = applyConfig({
- ratelimits: {
- max: 30,
- duration: 60,
- },
- route: "/api/v1/accounts/:id/pin",
- auth: {
- required: true,
- oauthPermissions: ["write:accounts"],
- },
- permissions: {
- required: [
- RolePermissions.ManageOwnAccount,
- RolePermissions.ViewAccounts,
- ],
- },
-});
-
export const schemas = {
param: z.object({
id: z.string().uuid(),
diff --git a/api/api/v1/accounts/:id/refetch.ts b/api/api/v1/accounts/:id/refetch.ts
index b4ee37fd..1768d20b 100644
--- a/api/api/v1/accounts/:id/refetch.ts
+++ b/api/api/v1/accounts/:id/refetch.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig, auth } from "@/api";
+import { apiRoute, auth } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { User } from "@versia/kit/db";
import { RolePermissions } from "@versia/kit/tables";
@@ -6,21 +6,6 @@ import { z } from "zod";
import { ApiError } from "~/classes/errors/api-error";
import { ErrorSchema } from "~/types/api";
-export const meta = applyConfig({
- ratelimits: {
- max: 4,
- duration: 60,
- },
- route: "/api/v1/accounts/:id/refetch",
- auth: {
- required: true,
- oauthPermissions: ["write:accounts"],
- },
- permissions: {
- required: [RolePermissions.ViewAccounts],
- },
-});
-
export const schemas = {
param: z.object({
id: z.string().uuid(),
diff --git a/api/api/v1/accounts/:id/remove_from_followers.ts b/api/api/v1/accounts/:id/remove_from_followers.ts
index 6e02b93f..ba86596e 100644
--- a/api/api/v1/accounts/:id/remove_from_followers.ts
+++ b/api/api/v1/accounts/:id/remove_from_followers.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig, auth } from "@/api";
+import { apiRoute, auth } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { Relationship, User } from "@versia/kit/db";
import { RolePermissions } from "@versia/kit/tables";
@@ -6,24 +6,6 @@ import { z } from "zod";
import { ApiError } from "~/classes/errors/api-error";
import { ErrorSchema } from "~/types/api";
-export const meta = applyConfig({
- ratelimits: {
- max: 30,
- duration: 60,
- },
- route: "/api/v1/accounts/:id/remove_from_followers",
- auth: {
- required: true,
- oauthPermissions: ["write:follows"],
- },
- permissions: {
- required: [
- RolePermissions.ManageOwnFollows,
- RolePermissions.ViewAccounts,
- ],
- },
-});
-
export const schemas = {
param: z.object({
id: z.string().uuid(),
diff --git a/api/api/v1/accounts/:id/roles/:role_id/index.ts b/api/api/v1/accounts/:id/roles/:role_id/index.ts
index 09f0f3fe..fb44512e 100644
--- a/api/api/v1/accounts/:id/roles/:role_id/index.ts
+++ b/api/api/v1/accounts/:id/roles/:role_id/index.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig, auth } from "@/api";
+import { apiRoute, auth } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { Role, User } from "@versia/kit/db";
import { RolePermissions } from "@versia/kit/tables";
@@ -6,24 +6,6 @@ import { z } from "zod";
import { ApiError } from "~/classes/errors/api-error";
import { ErrorSchema } from "~/types/api";
-export const meta = applyConfig({
- auth: {
- required: true,
- },
- ratelimits: {
- duration: 60,
- max: 20,
- },
- route: "/api/v1/accounts/:id/roles/:role_id",
- permissions: {
- required: [],
- methodOverrides: {
- POST: [RolePermissions.ManageRoles],
- DELETE: [RolePermissions.ManageRoles],
- },
- },
-});
-
export const schemas = {
param: z.object({
id: z.string().uuid(),
diff --git a/api/api/v1/accounts/:id/roles/index.ts b/api/api/v1/accounts/:id/roles/index.ts
index f9b497e8..cd8f3010 100644
--- a/api/api/v1/accounts/:id/roles/index.ts
+++ b/api/api/v1/accounts/:id/roles/index.ts
@@ -1,24 +1,10 @@
-import { apiRoute, applyConfig, auth } from "@/api";
+import { apiRoute, auth } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { Role, User } from "@versia/kit/db";
import { z } from "zod";
import { ApiError } from "~/classes/errors/api-error";
import { ErrorSchema } from "~/types/api";
-export const meta = applyConfig({
- auth: {
- required: false,
- },
- ratelimits: {
- duration: 60,
- max: 20,
- },
- route: "/api/v1/accounts/:id/roles",
- permissions: {
- required: [],
- },
-});
-
export const schemas = {
param: z.object({
id: z.string().uuid(),
diff --git a/api/api/v1/accounts/:id/statuses.test.ts b/api/api/v1/accounts/:id/statuses.test.ts
index 95562ae8..c65263fd 100644
--- a/api/api/v1/accounts/:id/statuses.test.ts
+++ b/api/api/v1/accounts/:id/statuses.test.ts
@@ -1,7 +1,6 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import type { Status as ApiStatus } from "@versia/client/types";
import { fakeRequest, getTestStatuses, getTestUsers } from "~/tests/utils.ts";
-import { meta } from "./statuses.ts";
const { users, tokens, deleteUsers } = await getTestUsers(5);
const timeline = (await getTestStatuses(40, users[1])).toReversed();
@@ -26,11 +25,10 @@ beforeAll(async () => {
});
// /api/v1/accounts/:id/statuses
-describe(meta.route, () => {
+describe("/api/v1/accounts/:id/statuses", () => {
test("should return 200 with statuses", async () => {
const response = await fakeRequest(
- meta.route.replace(":id", users[1].id),
-
+ `/api/v1/accounts/${users[1].id}/statuses`,
{
headers: {
Authorization: `Bearer ${tokens[0].data.accessToken}`,
@@ -49,8 +47,7 @@ describe(meta.route, () => {
test("should exclude reblogs", async () => {
const response = await fakeRequest(
- `${meta.route.replace(":id", users[1].id)}?exclude_reblogs=true`,
-
+ `/api/v1/accounts/${users[1].id}/statuses?exclude_reblogs=true`,
{
headers: {
Authorization: `Bearer ${tokens[0].data.accessToken}`,
@@ -84,8 +81,7 @@ describe(meta.route, () => {
expect(replyResponse.status).toBe(201);
const response = await fakeRequest(
- `${meta.route.replace(":id", users[1].id)}?exclude_replies=true`,
-
+ `/api/v1/accounts/${users[1].id}/statuses?exclude_replies=true`,
{
headers: {
Authorization: `Bearer ${tokens[0].data.accessToken}`,
@@ -104,8 +100,7 @@ describe(meta.route, () => {
test("should only include pins", async () => {
const response = await fakeRequest(
- `${meta.route.replace(":id", users[1].id)}?pinned=true`,
-
+ `/api/v1/accounts/${users[1].id}/statuses?pinned=true`,
{
headers: {
Authorization: `Bearer ${tokens[0].data.accessToken}`,
@@ -134,8 +129,7 @@ describe(meta.route, () => {
expect(pinResponse.status).toBe(200);
const response2 = await fakeRequest(
- `${meta.route.replace(":id", users[1].id)}?pinned=true`,
-
+ `/api/v1/accounts/${users[1].id}/statuses?pinned=true`,
{
headers: {
Authorization: `Bearer ${tokens[0].data.accessToken}`,
diff --git a/api/api/v1/accounts/:id/statuses.ts b/api/api/v1/accounts/:id/statuses.ts
index 8952df69..8b5e2a9d 100644
--- a/api/api/v1/accounts/:id/statuses.ts
+++ b/api/api/v1/accounts/:id/statuses.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig, auth, idValidator } from "@/api";
+import { apiRoute, auth, idValidator } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { Note, Timeline, User } from "@versia/kit/db";
import { Notes, RolePermissions } from "@versia/kit/tables";
@@ -7,21 +7,6 @@ import { z } from "zod";
import { ApiError } from "~/classes/errors/api-error";
import { ErrorSchema } from "~/types/api";
-export const meta = applyConfig({
- ratelimits: {
- max: 30,
- duration: 60,
- },
- route: "/api/v1/accounts/:id/statuses",
- auth: {
- required: false,
- oauthPermissions: ["read:statuses"],
- },
- permissions: {
- required: [RolePermissions.ViewNotes, RolePermissions.ViewAccounts],
- },
-});
-
export const schemas = {
param: z.object({
id: z.string().uuid(),
diff --git a/api/api/v1/accounts/:id/unblock.ts b/api/api/v1/accounts/:id/unblock.ts
index e7370bd8..8d4287e2 100644
--- a/api/api/v1/accounts/:id/unblock.ts
+++ b/api/api/v1/accounts/:id/unblock.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig, auth } from "@/api";
+import { apiRoute, auth } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { Relationship, User } from "@versia/kit/db";
import { RolePermissions } from "@versia/kit/tables";
@@ -6,24 +6,6 @@ import { z } from "zod";
import { ApiError } from "~/classes/errors/api-error";
import { ErrorSchema } from "~/types/api";
-export const meta = applyConfig({
- ratelimits: {
- max: 30,
- duration: 60,
- },
- route: "/api/v1/accounts/:id/unblock",
- auth: {
- required: true,
- oauthPermissions: ["write:blocks"],
- },
- permissions: {
- required: [
- RolePermissions.ManageOwnBlocks,
- RolePermissions.ViewAccounts,
- ],
- },
-});
-
export const schemas = {
param: z.object({
id: z.string().uuid(),
diff --git a/api/api/v1/accounts/:id/unfollow.ts b/api/api/v1/accounts/:id/unfollow.ts
index 90b87680..0e681bd7 100644
--- a/api/api/v1/accounts/:id/unfollow.ts
+++ b/api/api/v1/accounts/:id/unfollow.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig, auth } from "@/api";
+import { apiRoute, auth } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { Relationship, User } from "@versia/kit/db";
import { RolePermissions } from "@versia/kit/tables";
@@ -6,24 +6,6 @@ import { z } from "zod";
import { ApiError } from "~/classes/errors/api-error";
import { ErrorSchema } from "~/types/api";
-export const meta = applyConfig({
- ratelimits: {
- max: 30,
- duration: 60,
- },
- route: "/api/v1/accounts/:id/unfollow",
- auth: {
- required: true,
- oauthPermissions: ["write:follows"],
- },
- permissions: {
- required: [
- RolePermissions.ManageOwnFollows,
- RolePermissions.ViewAccounts,
- ],
- },
-});
-
export const schemas = {
param: z.object({
id: z.string().uuid(),
diff --git a/api/api/v1/accounts/:id/unmute.test.ts b/api/api/v1/accounts/:id/unmute.test.ts
index c7212347..9a5dde63 100644
--- a/api/api/v1/accounts/:id/unmute.test.ts
+++ b/api/api/v1/accounts/:id/unmute.test.ts
@@ -1,7 +1,6 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import type { Relationship as ApiRelationship } from "@versia/client/types";
import { fakeRequest, getTestUsers } from "~/tests/utils";
-import { meta } from "./unmute.ts";
const { users, tokens, deleteUsers } = await getTestUsers(2);
@@ -19,10 +18,10 @@ beforeAll(async () => {
});
// /api/v1/accounts/:id/unmute
-describe(meta.route, () => {
+describe("/api/v1/accounts/:id/unmute", () => {
test("should return 401 if not authenticated", async () => {
const response = await fakeRequest(
- meta.route.replace(":id", users[1].id),
+ `/api/v1/accounts/${users[1].id}/unmute`,
{
method: "POST",
},
@@ -32,7 +31,7 @@ describe(meta.route, () => {
test("should return 404 if user not found", async () => {
const response = await fakeRequest(
- meta.route.replace(":id", "00000000-0000-0000-0000-000000000000"),
+ "/api/v1/accounts/00000000-0000-0000-0000-000000000000/unmute",
{
method: "POST",
headers: {
@@ -45,7 +44,7 @@ describe(meta.route, () => {
test("should unmute user", async () => {
const response = await fakeRequest(
- meta.route.replace(":id", users[1].id),
+ `/api/v1/accounts/${users[1].id}/unmute`,
{
method: "POST",
headers: {
@@ -61,7 +60,7 @@ describe(meta.route, () => {
test("should return 200 if user already unmuted", async () => {
const response = await fakeRequest(
- meta.route.replace(":id", users[1].id),
+ `/api/v1/accounts/${users[1].id}/unmute`,
{
method: "POST",
headers: {
diff --git a/api/api/v1/accounts/:id/unmute.ts b/api/api/v1/accounts/:id/unmute.ts
index 3053e21d..33e56f8b 100644
--- a/api/api/v1/accounts/:id/unmute.ts
+++ b/api/api/v1/accounts/:id/unmute.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig, auth } from "@/api";
+import { apiRoute, auth } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { Relationship, User } from "@versia/kit/db";
import { RolePermissions } from "@versia/kit/tables";
@@ -6,24 +6,6 @@ import { z } from "zod";
import { ApiError } from "~/classes/errors/api-error";
import { ErrorSchema } from "~/types/api";
-export const meta = applyConfig({
- ratelimits: {
- max: 30,
- duration: 60,
- },
- route: "/api/v1/accounts/:id/unmute",
- auth: {
- required: true,
- oauthPermissions: ["write:mutes"],
- },
- permissions: {
- required: [
- RolePermissions.ManageOwnMutes,
- RolePermissions.ViewAccounts,
- ],
- },
-});
-
export const schemas = {
param: z.object({
id: z.string().uuid(),
diff --git a/api/api/v1/accounts/:id/unpin.ts b/api/api/v1/accounts/:id/unpin.ts
index 2614df15..859fc6e7 100644
--- a/api/api/v1/accounts/:id/unpin.ts
+++ b/api/api/v1/accounts/:id/unpin.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig, auth } from "@/api";
+import { apiRoute, auth } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { Relationship, User } from "@versia/kit/db";
import { RolePermissions } from "@versia/kit/tables";
@@ -6,24 +6,6 @@ import { z } from "zod";
import { ApiError } from "~/classes/errors/api-error";
import { ErrorSchema } from "~/types/api";
-export const meta = applyConfig({
- ratelimits: {
- max: 30,
- duration: 60,
- },
- route: "/api/v1/accounts/:id/unpin",
- auth: {
- required: true,
- oauthPermissions: ["write:accounts"],
- },
- permissions: {
- required: [
- RolePermissions.ManageOwnAccount,
- RolePermissions.ViewAccounts,
- ],
- },
-});
-
export const schemas = {
param: z.object({
id: z.string().uuid(),
diff --git a/api/api/v1/accounts/familiar_followers/index.test.ts b/api/api/v1/accounts/familiar_followers/index.test.ts
index f3450023..db9216da 100644
--- a/api/api/v1/accounts/familiar_followers/index.test.ts
+++ b/api/api/v1/accounts/familiar_followers/index.test.ts
@@ -1,6 +1,5 @@
import { afterAll, beforeAll, describe, expect, test } from "bun:test";
import { fakeRequest, getTestUsers } from "~/tests/utils.ts";
-import { meta } from "./index.ts";
const { users, tokens, deleteUsers } = await getTestUsers(5);
@@ -83,13 +82,16 @@ afterAll(async () => {
await deleteUsers();
});
-describe(meta.route, () => {
+describe("/api/v1/accounts/familiar_followers", () => {
test("should return 0 familiar followers", async () => {
- const response = await fakeRequest(`${meta.route}?id=${users[4].id}`, {
- headers: {
- Authorization: `Bearer ${tokens[0].data.accessToken}`,
+ const response = await fakeRequest(
+ `/api/v1/accounts/familiar_followers?id=${users[4].id}`,
+ {
+ headers: {
+ Authorization: `Bearer ${tokens[0].data.accessToken}`,
+ },
},
- });
+ );
expect(response.status).toBe(200);
@@ -100,11 +102,14 @@ describe(meta.route, () => {
});
test("should return 1 familiar follower", async () => {
- const response = await fakeRequest(`${meta.route}?id=${users[2].id}`, {
- headers: {
- Authorization: `Bearer ${tokens[0].data.accessToken}`,
+ const response = await fakeRequest(
+ `/api/v1/accounts/familiar_followers?id=${users[2].id}`,
+ {
+ headers: {
+ Authorization: `Bearer ${tokens[0].data.accessToken}`,
+ },
},
- });
+ );
expect(response.status).toBe(200);
@@ -115,11 +120,14 @@ describe(meta.route, () => {
});
test("should return 2 familiar followers", async () => {
- const response = await fakeRequest(`${meta.route}?id=${users[3].id}`, {
- headers: {
- Authorization: `Bearer ${tokens[0].data.accessToken}`,
+ const response = await fakeRequest(
+ `/api/v1/accounts/familiar_followers?id=${users[3].id}`,
+ {
+ headers: {
+ Authorization: `Bearer ${tokens[0].data.accessToken}`,
+ },
},
- });
+ );
expect(response.status).toBe(200);
@@ -133,7 +141,7 @@ describe(meta.route, () => {
test("should work with multiple ids", async () => {
const response = await fakeRequest(
- `${meta.route}?id[]=${users[2].id}&id[]=${users[3].id}&id[]=${users[4].id}`,
+ `/api/v1/accounts/familiar_followers?id[]=${users[2].id}&id[]=${users[3].id}&id[]=${users[4].id}`,
{
headers: {
Authorization: `Bearer ${tokens[0].data.accessToken}`,
diff --git a/api/api/v1/accounts/familiar_followers/index.ts b/api/api/v1/accounts/familiar_followers/index.ts
index 2e971baf..1a9dfc7d 100644
--- a/api/api/v1/accounts/familiar_followers/index.ts
+++ b/api/api/v1/accounts/familiar_followers/index.ts
@@ -1,25 +1,10 @@
-import { apiRoute, applyConfig, auth, qsQuery } from "@/api";
+import { apiRoute, auth, qsQuery } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { User, db } from "@versia/kit/db";
import { RolePermissions, type Users } from "@versia/kit/tables";
import { type InferSelectModel, sql } from "drizzle-orm";
import { z } from "zod";
-export const meta = applyConfig({
- route: "/api/v1/accounts/familiar_followers",
- ratelimits: {
- max: 5,
- duration: 60,
- },
- auth: {
- required: true,
- oauthPermissions: ["read:follows"],
- },
- permissions: {
- required: [RolePermissions.ManageOwnFollows],
- },
-});
-
export const schemas = {
query: z.object({
id: z
diff --git a/api/api/v1/accounts/id/index.test.ts b/api/api/v1/accounts/id/index.test.ts
index 65984f8e..30f036ea 100644
--- a/api/api/v1/accounts/id/index.test.ts
+++ b/api/api/v1/accounts/id/index.test.ts
@@ -1,7 +1,6 @@
import { afterAll, describe, expect, test } from "bun:test";
import type { Account as ApiAccount } from "@versia/client/types";
import { fakeRequest, getTestUsers } from "~/tests/utils";
-import { meta } from "./index.ts";
const { users, deleteUsers } = await getTestUsers(5);
@@ -10,10 +9,10 @@ afterAll(async () => {
});
// /api/v1/accounts/id
-describe(meta.route, () => {
+describe("/api/v1/accounts/id", () => {
test("should correctly get user from username", async () => {
const response = await fakeRequest(
- `${meta.route}?username=${users[0].data.username}`,
+ `/api/v1/accounts/id?username=${users[0].data.username}`,
);
expect(response.status).toBe(200);
@@ -25,7 +24,7 @@ describe(meta.route, () => {
test("should return 404 for non-existent user", async () => {
const response = await fakeRequest(
- `${meta.route}?username=${users[0].data.username}-nonexistent`,
+ `/api/v1/accounts/id?username=${users[0].data.username}-nonexistent`,
);
expect(response.status).toBe(404);
diff --git a/api/api/v1/accounts/id/index.ts b/api/api/v1/accounts/id/index.ts
index cb9bedf5..406aae7d 100644
--- a/api/api/v1/accounts/id/index.ts
+++ b/api/api/v1/accounts/id/index.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig, auth } from "@/api";
+import { apiRoute, auth } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { User } from "@versia/kit/db";
import { RolePermissions, Users } from "@versia/kit/tables";
@@ -7,21 +7,6 @@ import { z } from "zod";
import { ApiError } from "~/classes/errors/api-error";
import { ErrorSchema } from "~/types/api";
-export const meta = applyConfig({
- ratelimits: {
- max: 30,
- duration: 60,
- },
- route: "/api/v1/accounts/id",
- auth: {
- required: false,
- oauthPermissions: [],
- },
- permissions: {
- required: [RolePermissions.Search],
- },
-});
-
export const schemas = {
query: z.object({
username: z.string().min(1).max(512).toLowerCase(),
diff --git a/api/api/v1/accounts/index.test.ts b/api/api/v1/accounts/index.test.ts
index e4415654..2b3551a1 100644
--- a/api/api/v1/accounts/index.test.ts
+++ b/api/api/v1/accounts/index.test.ts
@@ -4,7 +4,6 @@ import { db } from "@versia/kit/db";
import { Users } from "@versia/kit/tables";
import { eq } from "drizzle-orm";
import { fakeRequest, getSolvedChallenge } from "~/tests/utils";
-import { meta } from "./index.ts";
const username = randomString(10, "hex");
const username2 = randomString(10, "hex");
@@ -15,9 +14,9 @@ afterEach(async () => {
});
// /api/v1/statuses
-describe(meta.route, () => {
+describe("/api/v1/accounts", () => {
test("should create a new account", async () => {
- const response = await fakeRequest(meta.route, {
+ const response = await fakeRequest("/api/v1/accounts", {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -38,7 +37,7 @@ describe(meta.route, () => {
});
test("should refuse invalid emails", async () => {
- const response = await fakeRequest(meta.route, {
+ const response = await fakeRequest("/api/v1/accounts", {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -58,7 +57,7 @@ describe(meta.route, () => {
});
test("should require a password", async () => {
- const response = await fakeRequest(meta.route, {
+ const response = await fakeRequest("/api/v1/accounts", {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -77,7 +76,7 @@ describe(meta.route, () => {
});
test("should not allow a previously registered email", async () => {
- await fakeRequest(meta.route, {
+ await fakeRequest("/api/v1/accounts", {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -93,7 +92,7 @@ describe(meta.route, () => {
}),
});
- const response = await fakeRequest(meta.route, {
+ const response = await fakeRequest("/api/v1/accounts", {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -113,7 +112,7 @@ describe(meta.route, () => {
});
test("should not allow a previously registered email (case insensitive)", async () => {
- await fakeRequest(meta.route, {
+ await fakeRequest("/api/v1/accounts", {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -129,7 +128,7 @@ describe(meta.route, () => {
}),
});
- const response = await fakeRequest(meta.route, {
+ const response = await fakeRequest("/api/v1/accounts", {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -149,7 +148,7 @@ describe(meta.route, () => {
});
test("should not allow invalid usernames (not a-z_0-9)", async () => {
- const response1 = await fakeRequest(meta.route, {
+ const response1 = await fakeRequest("/api/v1/accounts", {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -167,7 +166,7 @@ describe(meta.route, () => {
expect(response1.status).toBe(422);
- const response2 = await fakeRequest(meta.route, {
+ const response2 = await fakeRequest("/api/v1/accounts", {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -185,7 +184,7 @@ describe(meta.route, () => {
expect(response2.status).toBe(422);
- const response3 = await fakeRequest(meta.route, {
+ const response3 = await fakeRequest("/api/v1/accounts", {
method: "POST",
headers: {
"Content-Type": "application/json",
@@ -203,7 +202,7 @@ describe(meta.route, () => {
expect(response3.status).toBe(422);
- const response4 = await fakeRequest(meta.route, {
+ const response4 = await fakeRequest("/api/v1/accounts", {
method: "POST",
headers: {
"Content-Type": "application/json",
diff --git a/api/api/v1/accounts/index.ts b/api/api/v1/accounts/index.ts
index c8084db9..21bdcdc3 100644
--- a/api/api/v1/accounts/index.ts
+++ b/api/api/v1/accounts/index.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig, auth, jsonOrForm } from "@/api";
+import { apiRoute, auth, jsonOrForm } from "@/api";
import { tempmailDomains } from "@/tempmail";
import { createRoute } from "@hono/zod-openapi";
import { User } from "@versia/kit/db";
@@ -9,21 +9,6 @@ import { z } from "zod";
import { ApiError } from "~/classes/errors/api-error";
import { config } from "~/packages/config-manager";
-export const meta = applyConfig({
- route: "/api/v1/accounts",
- ratelimits: {
- max: 2,
- duration: 60,
- },
- auth: {
- required: false,
- oauthPermissions: ["write:accounts"],
- },
- challenge: {
- required: true,
- },
-});
-
export const schemas = {
json: z.object({
username: z.string(),
diff --git a/api/api/v1/accounts/lookup/index.test.ts b/api/api/v1/accounts/lookup/index.test.ts
index 021c8b50..1660c9a9 100644
--- a/api/api/v1/accounts/lookup/index.test.ts
+++ b/api/api/v1/accounts/lookup/index.test.ts
@@ -1,7 +1,6 @@
import { afterAll, describe, expect, test } from "bun:test";
import type { Account as ApiAccount } from "@versia/client/types";
import { fakeRequest, getTestUsers } from "~/tests/utils";
-import { meta } from "./index.ts";
const { users, tokens, deleteUsers } = await getTestUsers(5);
@@ -10,10 +9,10 @@ afterAll(async () => {
});
// /api/v1/accounts/lookup
-describe(meta.route, () => {
+describe("/api/v1/accounts/lookup", () => {
test("should return 200 with users", async () => {
const response = await fakeRequest(
- `${meta.route}?acct=${users[0].data.username}`,
+ `/api/v1/accounts/lookup?acct=${users[0].data.username}`,
{
headers: {
Authorization: `Bearer ${tokens[0].data.accessToken}`,
@@ -37,7 +36,7 @@ describe(meta.route, () => {
test("should automatically lowercase the acct", async () => {
const response = await fakeRequest(
- `${meta.route}?acct=${users[0].data.username.toUpperCase()}`,
+ `/api/v1/accounts/lookup?acct=${users[0].data.username.toUpperCase()}`,
{
headers: {
Authorization: `Bearer ${tokens[0].data.accessToken}`,
diff --git a/api/api/v1/accounts/lookup/index.ts b/api/api/v1/accounts/lookup/index.ts
index 389e5fac..71f42886 100644
--- a/api/api/v1/accounts/lookup/index.ts
+++ b/api/api/v1/accounts/lookup/index.ts
@@ -1,4 +1,4 @@
-import { apiRoute, applyConfig, auth, parseUserAddress } from "@/api";
+import { apiRoute, auth, parseUserAddress } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { Instance, User } from "@versia/kit/db";
import { RolePermissions, Users } from "@versia/kit/tables";
@@ -8,21 +8,6 @@ import { ApiError } from "~/classes/errors/api-error";
import { config } from "~/packages/config-manager";
import { ErrorSchema } from "~/types/api";
-export const meta = applyConfig({
- ratelimits: {
- max: 30,
- duration: 60,
- },
- route: "/api/v1/accounts/lookup",
- auth: {
- required: false,
- oauthPermissions: [],
- },
- permissions: {
- required: [RolePermissions.Search],
- },
-});
-
export const schemas = {
query: z.object({
acct: z.string().min(1).max(512).toLowerCase(),
diff --git a/api/api/v1/accounts/relationships/index.test.ts b/api/api/v1/accounts/relationships/index.test.ts
index 1071cfde..5068a895 100644
--- a/api/api/v1/accounts/relationships/index.test.ts
+++ b/api/api/v1/accounts/relationships/index.test.ts
@@ -3,7 +3,6 @@ import { db } from "@versia/kit/db";
import { Users } from "@versia/kit/tables";
import { eq } from "drizzle-orm";
import { fakeRequest, getTestUsers } from "~/tests/utils";
-import { meta } from "./index.ts";
const { users, tokens, deleteUsers } = await getTestUsers(5);
@@ -44,16 +43,18 @@ afterAll(async () => {
});
// /api/v1/accounts/relationships
-describe(meta.route, () => {
+describe("/api/v1/accounts/relationships", () => {
test("should return 401 if not authenticated", async () => {
- const response = await fakeRequest(`${meta.route}?id[]=${users[2].id}`);
+ const response = await fakeRequest(
+ `/api/v1/accounts/relationships?id[]=${users[2].id}`,
+ );
expect(response.status).toBe(401);
});
test("should return relationships", async () => {
const response = await fakeRequest(
- `${meta.route}?id[]=${users[2].id}`,
+ `/api/v1/accounts/relationships?id[]=${users[2].id}`,
{
headers: {
Authorization: `Bearer ${tokens[0].data.accessToken}`,
@@ -83,7 +84,7 @@ describe(meta.route, () => {
test("should be requested_by user1", async () => {
const response = await fakeRequest(
- `${meta.route}?id[]=${users[1].id}`,
+ `/api/v1/accounts/relationships?id[]=${users[1].id}`,
{
headers: {
Authorization: `Bearer ${tokens[0].data.accessToken}`,
diff --git a/api/api/v1/accounts/relationships/index.ts b/api/api/v1/accounts/relationships/index.ts
index 422918cf..b018f162 100644
--- a/api/api/v1/accounts/relationships/index.ts
+++ b/api/api/v1/accounts/relationships/index.ts
@@ -1,24 +1,9 @@
-import { apiRoute, applyConfig, auth, qsQuery } from "@/api";
+import { apiRoute, auth, qsQuery } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { Relationship } from "@versia/kit/db";
import { RolePermissions } from "@versia/kit/tables";
import { z } from "zod";
-export const meta = applyConfig({
- route: "/api/v1/accounts/relationships",
- ratelimits: {
- max: 30,
- duration: 60,
- },
- auth: {
- required: true,
- oauthPermissions: ["read:follows"],
- },
- permissions: {
- required: [RolePermissions.ManageOwnFollows],
- },
-});
-
export const schemas = {
query: z.object({
id: z.array(z.string().uuid()).min(1).max(10).or(z.string().uuid()),
diff --git a/api/api/v1/accounts/search/index.test.ts b/api/api/v1/accounts/search/index.test.ts
index 8ab0b144..0751a202 100644
--- a/api/api/v1/accounts/search/index.test.ts
+++ b/api/api/v1/accounts/search/index.test.ts
@@ -1,7 +1,6 @@
import { afterAll, describe, expect, test } from "bun:test";
import type { Account as ApiAccount } from "@versia/client/types";
import { fakeRequest, getTestUsers } from "~/tests/utils";
-import { meta } from "./index.ts";
const { users, tokens, deleteUsers } = await getTestUsers(5);
@@ -10,10 +9,10 @@ afterAll(async () => {
});
// /api/v1/accounts/search
-describe(meta.route, () => {
+describe("/api/v1/accounts/search", () => {
test("should return 200 with users", async () => {
const response = await fakeRequest(
- `${meta.route}?q=${users[0].data.username}`,
+ `/api/v1/accounts/search?q=${users[0].data.username}`,
{
headers: {
Authorization: `Bearer ${tokens[0].data.accessToken}`,
diff --git a/api/api/v1/accounts/search/index.ts b/api/api/v1/accounts/search/index.ts
index f27008ab..9d20faaf 100644
--- a/api/api/v1/accounts/search/index.ts
+++ b/api/api/v1/accounts/search/index.ts
@@ -1,10 +1,4 @@
-import {
- apiRoute,
- applyConfig,
- auth,
- parseUserAddress,
- userAddressValidator,
-} from "@/api";
+import { apiRoute, auth, parseUserAddress, userAddressValidator } from "@/api";
import { createRoute } from "@hono/zod-openapi";
import { User } from "@versia/kit/db";
import { RolePermissions, Users } from "@versia/kit/tables";
@@ -13,21 +7,6 @@ import stringComparison from "string-comparison";
import { z } from "zod";
import { ApiError } from "~/classes/errors/api-error";
-export const meta = applyConfig({
- route: "/api/v1/accounts/search",
- ratelimits: {
- max: 100,
- duration: 60,
- },
- auth: {
- required: false,
- oauthPermissions: ["read:accounts"],
- },
- permissions: {
- required: [RolePermissions.Search, RolePermissions.ViewAccounts],
- },
-});
-
export const schemas = {
query: z.object({
q: z.string().min(1).max(512).regex(userAddressValidator),
diff --git a/api/api/v1/accounts/update_credentials/index.test.ts b/api/api/v1/accounts/update_credentials/index.test.ts
index 9f9545f2..78edd2e9 100644
--- a/api/api/v1/accounts/update_credentials/index.test.ts
+++ b/api/api/v1/accounts/update_credentials/index.test.ts
@@ -2,7 +2,6 @@ import { afterAll, describe, expect, test } from "bun:test";
import type { Account as APIAccount } from "@versia/client/types";
import { config } from "~/packages/config-manager/index.ts";
import { fakeRequest, getTestUsers } from "~/tests/utils";
-import { meta } from "./index.ts";
const { tokens, deleteUsers } = await getTestUsers(1);
@@ -11,18 +10,21 @@ afterAll(async () => {
});
// /api/v1/accounts/update_credentials
-describe(meta.route, () => {
+describe("/api/v1/accounts/update_credentials", () => {
describe("HTML injection testing", () => {
test("should not allow HTML injection", async () => {
- const response = await fakeRequest(meta.route, {
- method: "PATCH",
- headers: {
- Authorization: `Bearer ${tokens[0].data.accessToken}`,
+ const response = await fakeRequest(
+ "/api/v1/accounts/update_credentials",
+ {
+ method: "PATCH",
+ headers: {
+ Authorization: `Bearer ${tokens[0].data.accessToken}`,
+ },
+ body: new URLSearchParams({
+ note: "Hi! ",
+ }),
},
- body: new URLSearchParams({
- note: "Hi! ",
- }),
- });
+ );
expect(response.status).toBe(200);
expect(response.headers.get("content-type")).toContain(
@@ -37,15 +39,18 @@ describe(meta.route, () => {
});
test("should rewrite all image and video src to go through proxy", async () => {
- const response = await fakeRequest(meta.route, {
- method: "PATCH",
- headers: {
- Authorization: `Bearer ${tokens[0].data.accessToken}`,
+ const response = await fakeRequest(
+ "/api/v1/accounts/update_credentials",
+ {
+ method: "PATCH",
+ headers: {
+ Authorization: `Bearer ${tokens[0].data.accessToken}`,
+ },
+ body: new URLSearchParams({
+ note: "