mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
Enable verbatim module syntax + more API routes
This commit is contained in:
parent
991a2cba84
commit
be9b2e3376
84 changed files with 438 additions and 192 deletions
|
|
@ -1,5 +1,5 @@
|
|||
import { APIApplication } from "~types/entities/application";
|
||||
import { Application } from "@prisma/client";
|
||||
import type { APIApplication } from "~types/entities/application";
|
||||
import type { Application } from "@prisma/client";
|
||||
import { client } from "~database/datasource";
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { ConfigType } from "@config";
|
||||
import { Attachment } from "@prisma/client";
|
||||
import { APIAsyncAttachment } from "~types/entities/async_attachment";
|
||||
import { APIAttachment } from "~types/entities/attachment";
|
||||
import type { ConfigType } from "@config";
|
||||
import type { Attachment } from "@prisma/client";
|
||||
import type { APIAsyncAttachment } from "~types/entities/async_attachment";
|
||||
import type { APIAttachment } from "~types/entities/attachment";
|
||||
|
||||
export const attachmentToAPI = (
|
||||
attachment: Attachment
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { APIEmoji } from "~types/entities/emoji";
|
||||
import { Emoji as LysandEmoji } from "~types/lysand/extensions/org.lysand/custom_emojis";
|
||||
import type { APIEmoji } from "~types/entities/emoji";
|
||||
import type { Emoji as LysandEmoji } from "~types/lysand/extensions/org.lysand/custom_emojis";
|
||||
import { client } from "~database/datasource";
|
||||
import { Emoji } from "@prisma/client";
|
||||
import type { Emoji } from "@prisma/client";
|
||||
|
||||
/**
|
||||
* Represents an emoji entity in the database.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Instance } from "@prisma/client";
|
||||
import type { Instance } from "@prisma/client";
|
||||
import { client } from "~database/datasource";
|
||||
import { ServerMetadata } from "~types/lysand/Object";
|
||||
import type { ServerMetadata } from "~types/lysand/Object";
|
||||
|
||||
/**
|
||||
* Represents an instance in the database.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
import { Like as LysandLike } from "~types/lysand/Object";
|
||||
import type { Like as LysandLike } from "~types/lysand/Object";
|
||||
import { getConfig } from "@config";
|
||||
import { Like } from "@prisma/client";
|
||||
import type { Like } from "@prisma/client";
|
||||
|
||||
/**
|
||||
* Represents a Like entity in the database.
|
||||
|
|
|
|||
23
database/entities/Notification.ts
Normal file
23
database/entities/Notification.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
import type { Notification } from "@prisma/client";
|
||||
import type { APINotification } from "~types/entities/notification";
|
||||
import { type StatusWithRelations, statusToAPI } from "./Status";
|
||||
import { type UserWithRelations, userToAPI } from "./User";
|
||||
|
||||
export type NotificationWithRelations = Notification & {
|
||||
status: StatusWithRelations | null;
|
||||
account: UserWithRelations;
|
||||
};
|
||||
|
||||
export const notificationToAPI = async (
|
||||
notification: NotificationWithRelations
|
||||
): Promise<APINotification> => {
|
||||
return {
|
||||
account: userToAPI(notification.account),
|
||||
created_at: notification.createdAt.toISOString(),
|
||||
id: notification.id,
|
||||
type: notification.type,
|
||||
status: notification.status
|
||||
? await statusToAPI(notification.status)
|
||||
: undefined,
|
||||
};
|
||||
};
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
import { LysandObject } from "@prisma/client";
|
||||
import type { LysandObject } from "@prisma/client";
|
||||
import { client } from "~database/datasource";
|
||||
import { LysandObjectType } from "~types/lysand/Object";
|
||||
import type { LysandObjectType } from "~types/lysand/Object";
|
||||
|
||||
/**
|
||||
* Represents a Lysand object in the database.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { Relationship, User } from "@prisma/client";
|
||||
import { APIRelationship } from "~types/entities/relationship";
|
||||
import type { Relationship, User } from "@prisma/client";
|
||||
import type { APIRelationship } from "~types/entities/relationship";
|
||||
import { client } from "~database/datasource";
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
import { getConfig } from "@config";
|
||||
import type { UserWithRelations } from "./User";
|
||||
import {
|
||||
UserWithRelations,
|
||||
fetchRemoteUser,
|
||||
parseMentionsUris,
|
||||
userRelations,
|
||||
userToAPI,
|
||||
} from "./User";
|
||||
import { client } from "~database/datasource";
|
||||
import { LysandPublication, Note } from "~types/lysand/Object";
|
||||
import type { LysandPublication, Note } from "~types/lysand/Object";
|
||||
import { htmlToText } from "html-to-text";
|
||||
import { getBestContentType } from "@content_types";
|
||||
import {
|
||||
import type {
|
||||
Application,
|
||||
Emoji,
|
||||
Instance,
|
||||
|
|
@ -21,7 +21,7 @@ import {
|
|||
User,
|
||||
} from "@prisma/client";
|
||||
import { emojiToAPI, emojiToLysand, parseEmojis } from "./Emoji";
|
||||
import { APIStatus } from "~types/entities/status";
|
||||
import type { APIStatus } from "~types/entities/status";
|
||||
import { applicationToAPI } from "./Application";
|
||||
|
||||
const config = getConfig();
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import { ConfigType, getConfig } from "@config";
|
||||
import { APIAccount } from "~types/entities/account";
|
||||
import { User as LysandUser } from "~types/lysand/Object";
|
||||
import type { ConfigType } from "@config";
|
||||
import { getConfig } from "@config";
|
||||
import type { APIAccount } from "~types/entities/account";
|
||||
import type { User as LysandUser } from "~types/lysand/Object";
|
||||
import { htmlToText } from "html-to-text";
|
||||
import {
|
||||
import type {
|
||||
Emoji,
|
||||
Instance,
|
||||
Like,
|
||||
|
|
@ -13,7 +14,7 @@ import {
|
|||
import { client } from "~database/datasource";
|
||||
import { addEmojiIfNotExists, emojiToAPI, emojiToLysand } from "./Emoji";
|
||||
import { addInstanceIfNotExists } from "./Instance";
|
||||
import { APISource } from "~types/entities/source";
|
||||
import type { APISource } from "~types/entities/source";
|
||||
|
||||
export interface AuthData {
|
||||
user: UserWithRelations | null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue