mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 00:18:19 +01:00
feat(api): ✨ Add rules to /api/v2/instance
This commit is contained in:
parent
9e3e02cabd
commit
71d2c7ae3b
|
|
@ -6,7 +6,8 @@
|
|||
"node_modules/**/*",
|
||||
"dist/**/*",
|
||||
"packages/frontend/.output",
|
||||
"packages/frontend/.nuxt"
|
||||
"packages/frontend/.nuxt",
|
||||
"glitch"
|
||||
]
|
||||
},
|
||||
"linter": {
|
||||
|
|
@ -18,7 +19,8 @@
|
|||
"node_modules/**/*",
|
||||
"dist/**/*",
|
||||
"packages/frontend/.output",
|
||||
"packages/frontend/.nuxt"
|
||||
"packages/frontend/.nuxt",
|
||||
"glitch"
|
||||
]
|
||||
},
|
||||
"formatter": {
|
||||
|
|
@ -29,7 +31,8 @@
|
|||
"node_modules/**/*",
|
||||
"dist/**/*",
|
||||
"packages/frontend/.output",
|
||||
"packages/frontend/.nuxt"
|
||||
"packages/frontend/.nuxt",
|
||||
"glitch"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
2
index.ts
2
index.ts
|
|
@ -1,3 +1,4 @@
|
|||
import { dualLogger } from "@loggers";
|
||||
import { connectMeili } from "@meilisearch";
|
||||
import { config } from "config-manager";
|
||||
import { count } from "drizzle-orm";
|
||||
|
|
@ -5,7 +6,6 @@ import { LogLevel, LogManager, type MultiLogManager } from "log-manager";
|
|||
import { db, setupDatabase } from "~drizzle/db";
|
||||
import { status } from "~drizzle/schema";
|
||||
import { createServer } from "~server";
|
||||
import { dualLogger } from "@loggers";
|
||||
|
||||
const timeAtStart = performance.now();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { join } from "node:path";
|
||||
import { dualLogger } from "@loggers";
|
||||
import { errorResponse } from "@response";
|
||||
import { config } from "config-manager";
|
||||
import { join } from "node:path";
|
||||
import {
|
||||
LogLevel,
|
||||
type LogManager,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { describe, expect, test } from "bun:test";
|
||||
import { meta } from "./extended_description";
|
||||
import { sendTestRequest } from "~tests/utils";
|
||||
import { config } from "config-manager";
|
||||
import { sendTestRequest } from "~tests/utils";
|
||||
import { meta } from "./extended_description";
|
||||
|
||||
// /api/v1/instance/extended_description
|
||||
describe(meta.route, () => {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { describe, expect, test } from "bun:test";
|
||||
import { meta } from "./rules";
|
||||
import { sendTestRequest } from "~tests/utils";
|
||||
import { config } from "config-manager";
|
||||
import { sendTestRequest } from "~tests/utils";
|
||||
import { meta } from "./rules";
|
||||
|
||||
// /api/v1/instance/rules
|
||||
describe(meta.route, () => {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { describe, expect, test } from "bun:test";
|
||||
import { meta } from "./index";
|
||||
import { sendTestRequest } from "~tests/utils";
|
||||
import { config } from "config-manager";
|
||||
import { sendTestRequest } from "~tests/utils";
|
||||
import { meta } from "./index";
|
||||
|
||||
// /api/v2/instance
|
||||
describe(meta.route, () => {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,10 @@
|
|||
import { apiRoute, applyConfig } from "@api";
|
||||
import { jsonResponse } from "@response";
|
||||
import { and, count, countDistinct, eq, gte, isNull } from "drizzle-orm";
|
||||
import { and, countDistinct, eq, gte, isNull } from "drizzle-orm";
|
||||
import { findFirstUser, userToAPI } from "~database/entities/User";
|
||||
import { db } from "~drizzle/db";
|
||||
import { instance, status, user } from "~drizzle/schema";
|
||||
import { status, user } from "~drizzle/schema";
|
||||
import manifest from "~package.json";
|
||||
import type { Instance as APIInstance } from "~types/mastodon/instance";
|
||||
|
||||
export const meta = applyConfig({
|
||||
allowedMethods: ["GET"],
|
||||
|
|
@ -108,6 +107,9 @@ export default apiRoute(async (req, matchedRoute, extraData) => {
|
|||
email: contactAccount?.email || null,
|
||||
account: contactAccount ? userToAPI(contactAccount) : null,
|
||||
},
|
||||
rules: [],
|
||||
rules: config.signups.rules.map((rule, index) => ({
|
||||
id: String(index),
|
||||
text: rule,
|
||||
})),
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue