Skip to content

Commit be9b2e3

Browse files
committed
Enable verbatim module syntax + more API routes
1 parent 991a2cb commit be9b2e3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+438
-192
lines changed

.eslintrc.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@ module.exports = {
1616
"@typescript-eslint/no-unsafe-assignment": "off",
1717
"@typescript-eslint/no-unsafe-argument": "off",
1818
"@typescript-eslint/no-explicit-any": "off",
19+
"@typescript-eslint/consistent-type-exports": "error",
20+
"@typescript-eslint/consistent-type-imports": "error"
1921
},
2022
};

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,16 +154,20 @@ Working endpoints are:
154154
- `/oauth/authorize`
155155
- `/oauth/token`
156156

157-
Endpoints left:
157+
Tests needed but completed:
158158

159159
- `/api/v2/media`
160160
- `/api/v1/media/:id`
161+
- `/api/v1/blocks`
162+
- `/api/v1/mutes`
163+
164+
165+
Endpoints left:
166+
161167
- `/api/v1/reports`
162168
- `/api/v1/accounts/:id/lists`
163169
- `/api/v1/favourites`
164170
- `/api/v1/accounts/:id/following`
165-
- `/api/v1/mutes`
166-
- `/api/v1/blocks`
167171
- `/api/v1/follow_requests`
168172
- `/api/v1/follow_requests/:account_id/authorize`
169173
- `/api/v1/follow_requests/:account_id/reject`

classes/activitypub.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { APActivity, APActor } from "activitypub-types";
1+
import type { APActivity, APActor } from "activitypub-types";
22

33
export class RemoteActor {
44
private actorData: APActor | null;

classes/media.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
import type { GetObjectCommandOutput } from "@aws-sdk/client-s3";
12
import {
23
GetObjectCommand,
3-
GetObjectCommandOutput,
44
PutObjectCommand,
55
S3Client,
66
} from "@aws-sdk/client-s3";
7-
import { ConfigType } from "@config";
7+
import type { ConfigType } from "@config";
88
import sharp from "sharp";
99
import { exists, mkdir } from "fs/promises";
1010
class MediaBackend {

database/entities/Application.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { APIApplication } from "~types/entities/application";
2-
import { Application } from "@prisma/client";
1+
import type { APIApplication } from "~types/entities/application";
2+
import type { Application } from "@prisma/client";
33
import { client } from "~database/datasource";
44

55
/**

database/entities/Attachment.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { ConfigType } from "@config";
2-
import { Attachment } from "@prisma/client";
3-
import { APIAsyncAttachment } from "~types/entities/async_attachment";
4-
import { APIAttachment } from "~types/entities/attachment";
1+
import type { ConfigType } from "@config";
2+
import type { Attachment } from "@prisma/client";
3+
import type { APIAsyncAttachment } from "~types/entities/async_attachment";
4+
import type { APIAttachment } from "~types/entities/attachment";
55

66
export const attachmentToAPI = (
77
attachment: Attachment

database/entities/Emoji.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { APIEmoji } from "~types/entities/emoji";
2-
import { Emoji as LysandEmoji } from "~types/lysand/extensions/org.lysand/custom_emojis";
1+
import type { APIEmoji } from "~types/entities/emoji";
2+
import type { Emoji as LysandEmoji } from "~types/lysand/extensions/org.lysand/custom_emojis";
33
import { client } from "~database/datasource";
4-
import { Emoji } from "@prisma/client";
4+
import type { Emoji } from "@prisma/client";
55

66
/**
77
* Represents an emoji entity in the database.

database/entities/Instance.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { Instance } from "@prisma/client";
1+
import type { Instance } from "@prisma/client";
22
import { client } from "~database/datasource";
3-
import { ServerMetadata } from "~types/lysand/Object";
3+
import type { ServerMetadata } from "~types/lysand/Object";
44

55
/**
66
* Represents an instance in the database.

database/entities/Like.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
2-
import { Like as LysandLike } from "~types/lysand/Object";
2+
import type { Like as LysandLike } from "~types/lysand/Object";
33
import { getConfig } from "@config";
4-
import { Like } from "@prisma/client";
4+
import type { Like } from "@prisma/client";
55

66
/**
77
* Represents a Like entity in the database.

database/entities/Notification.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import type { Notification } from "@prisma/client";
2+
import type { APINotification } from "~types/entities/notification";
3+
import { type StatusWithRelations, statusToAPI } from "./Status";
4+
import { type UserWithRelations, userToAPI } from "./User";
5+
6+
export type NotificationWithRelations = Notification & {
7+
status: StatusWithRelations | null;
8+
account: UserWithRelations;
9+
};
10+
11+
export const notificationToAPI = async (
12+
notification: NotificationWithRelations
13+
): Promise<APINotification> => {
14+
return {
15+
account: userToAPI(notification.account),
16+
created_at: notification.createdAt.toISOString(),
17+
id: notification.id,
18+
type: notification.type,
19+
status: notification.status
20+
? await statusToAPI(notification.status)
21+
: undefined,
22+
};
23+
};

0 commit comments

Comments
 (0)