Enable verbatim module syntax + more API routes

This commit is contained in:
Jesse Wierzbinski 2023-11-22 18:10:37 -10:00
parent 991a2cba84
commit be9b2e3376
No known key found for this signature in database
84 changed files with 438 additions and 192 deletions

View file

@ -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";
/**

View file

@ -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

View file

@ -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.

View file

@ -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.

View file

@ -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.

View 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,
};
};

View file

@ -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.

View file

@ -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";
/**

View file

@ -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();

View file

@ -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;