mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
feat(api): 🏷️ Only allow JSON values in JSON HTTP responses
This commit is contained in:
parent
d4894c362e
commit
8a6d71d958
|
|
@ -344,7 +344,7 @@ export const Instances = pgTable("Instances", {
|
|||
baseUrl: text("base_url").notNull(),
|
||||
name: text("name").notNull(),
|
||||
version: text("version").notNull(),
|
||||
logo: jsonb("logo"),
|
||||
logo: jsonb("logo").$type<ContentFormat>(),
|
||||
disableAutomoderation: boolean("disable_automoderation")
|
||||
.default(false)
|
||||
.notNull(),
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ export default (app: Hono) =>
|
|||
and(isNull(Users.instanceId), eq(Users.isAdmin, true)),
|
||||
);
|
||||
|
||||
const knownDomainsCount = Instance.getCount();
|
||||
const knownDomainsCount = await Instance.getCount();
|
||||
|
||||
// TODO: fill in more values
|
||||
return jsonResponse({
|
||||
|
|
|
|||
|
|
@ -27,8 +27,17 @@ export const response = (
|
|||
});
|
||||
};
|
||||
|
||||
export type Json =
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| null
|
||||
| undefined
|
||||
| Json[]
|
||||
| { [key: string]: Json };
|
||||
|
||||
export const jsonResponse = (
|
||||
data: object,
|
||||
data: Json,
|
||||
status = 200,
|
||||
headers: Record<string, string> = {},
|
||||
) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue