mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
Fix ESLint
This commit is contained in:
parent
436a79d99f
commit
636f2ffff8
14
.eslintrc.cjs
Normal file
14
.eslintrc.cjs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
module.exports = {
|
||||
extends: [
|
||||
"eslint:recommended",
|
||||
"plugin:@typescript-eslint/strict-type-checked",
|
||||
"plugin:@typescript-eslint/stylistic",
|
||||
],
|
||||
parser: "@typescript-eslint/parser",
|
||||
parserOptions: {
|
||||
project: "./tsconfig.json",
|
||||
},
|
||||
ignorePatterns: ["node_modules/", "dist/", ".eslintrc.cjs"],
|
||||
plugins: ["@typescript-eslint"],
|
||||
root: true,
|
||||
};
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
module.exports = {
|
||||
extends: [
|
||||
"eslint:strict",
|
||||
"plugin:@typescript-eslint/strict-type-checked",
|
||||
"plugin:@typescript-eslint/stylistic",
|
||||
],
|
||||
};
|
||||
13
index.ts
13
index.ts
|
|
@ -3,21 +3,24 @@ const router = new Bun.FileSystemRouter({
|
|||
dir: process.cwd() + "/server/api",
|
||||
})
|
||||
|
||||
console.log("[+] Starting FediProject...");
|
||||
|
||||
Bun.serve({
|
||||
port: 8080,
|
||||
port: 8653,
|
||||
hostname: "0.0.0.0", // defaults to "0.0.0.0"
|
||||
async fetch(req) {
|
||||
const url = new URL(req.url);
|
||||
|
||||
const matchedRoute = router.match(req);
|
||||
|
||||
if (matchedRoute) {
|
||||
return (await import(matchedRoute.filePath)).default(req, matchedRoute);
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
||||
return (await import(matchedRoute.filePath)).default(req, matchedRoute) as Response | Promise<Response>;
|
||||
} else {
|
||||
const response = new Response(undefined, {
|
||||
return new Response(undefined, {
|
||||
status: 404,
|
||||
statusText: "Route not found",
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
console.log("[+] FediProject started!")
|
||||
|
|
|
|||
|
|
@ -4,8 +4,10 @@
|
|||
"type": "module",
|
||||
"devDependencies": {
|
||||
"@typescript-eslint/eslint-plugin": "^6.6.0",
|
||||
"@typescript-eslint/parser": "^6.6.0",
|
||||
"bun-types": "latest",
|
||||
"eslint": "^8.49.0"
|
||||
"eslint": "^8.49.0",
|
||||
"typescript": "^5.2.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": "^5.0.0"
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import { Field } from "./field";
|
|||
import { Role } from "./role";
|
||||
import { Source } from "./source";
|
||||
|
||||
export type Account = {
|
||||
export interface Account {
|
||||
id: string;
|
||||
username: string;
|
||||
acct: string;
|
||||
|
|
@ -24,11 +24,11 @@ export type Account = {
|
|||
avatar_static: string;
|
||||
header: string;
|
||||
header_static: string;
|
||||
emojis: Array<Emoji>;
|
||||
emojis: Emoji[];
|
||||
moved: Account | null;
|
||||
fields: Array<Field>;
|
||||
fields: Field[];
|
||||
bot: boolean;
|
||||
source?: Source;
|
||||
role?: Role;
|
||||
mute_expires_at?: string;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
export type Activity = {
|
||||
export interface Activity {
|
||||
week: string;
|
||||
statuses: string;
|
||||
logins: string;
|
||||
registrations: string;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Emoji } from "./emoji";
|
||||
import { StatusTag } from "./status";
|
||||
|
||||
export type Announcement = {
|
||||
export interface Announcement {
|
||||
id: string;
|
||||
content: string;
|
||||
starts_at: string | null;
|
||||
|
|
@ -11,29 +11,29 @@ export type Announcement = {
|
|||
published_at: string;
|
||||
updated_at: string;
|
||||
read: boolean | null;
|
||||
mentions: Array<AnnouncementAccount>;
|
||||
statuses: Array<AnnouncementStatus>;
|
||||
tags: Array<StatusTag>;
|
||||
emojis: Array<Emoji>;
|
||||
reactions: Array<AnnouncementReaction>;
|
||||
};
|
||||
mentions: AnnouncementAccount[];
|
||||
statuses: AnnouncementStatus[];
|
||||
tags: StatusTag[];
|
||||
emojis: Emoji[];
|
||||
reactions: AnnouncementReaction[];
|
||||
}
|
||||
|
||||
export type AnnouncementAccount = {
|
||||
export interface AnnouncementAccount {
|
||||
id: string;
|
||||
username: string;
|
||||
url: string;
|
||||
acct: string;
|
||||
};
|
||||
}
|
||||
|
||||
export type AnnouncementStatus = {
|
||||
export interface AnnouncementStatus {
|
||||
id: string;
|
||||
url: string;
|
||||
};
|
||||
}
|
||||
|
||||
export type AnnouncementReaction = {
|
||||
export interface AnnouncementReaction {
|
||||
name: string;
|
||||
count: number;
|
||||
me: boolean | null;
|
||||
url: string | null;
|
||||
static_url: string | null;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
export type Application = {
|
||||
export interface Application {
|
||||
name: string;
|
||||
website?: string | null;
|
||||
vapid_key?: string | null;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Meta } from "./attachment";
|
||||
|
||||
export type AsyncAttachment = {
|
||||
export interface AsyncAttachment {
|
||||
id: string;
|
||||
type: "unknown" | "image" | "gifv" | "video" | "audio";
|
||||
url: string | null;
|
||||
|
|
@ -10,4 +10,4 @@ export type AsyncAttachment = {
|
|||
meta: Meta | null;
|
||||
description: string | null;
|
||||
blurhash: string | null;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export type Sub = {
|
||||
export interface Sub {
|
||||
// For Image, Gifv, and Video
|
||||
width?: number;
|
||||
height?: number;
|
||||
|
|
@ -11,14 +11,14 @@ export type Sub = {
|
|||
// For Audio, Gifv, and Video
|
||||
duration?: number;
|
||||
bitrate?: number;
|
||||
};
|
||||
}
|
||||
|
||||
export type Focus = {
|
||||
export interface Focus {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
}
|
||||
|
||||
export type Meta = {
|
||||
export interface Meta {
|
||||
original?: Sub;
|
||||
small?: Sub;
|
||||
focus?: Focus;
|
||||
|
|
@ -32,9 +32,9 @@ export type Meta = {
|
|||
audio_encode?: string;
|
||||
audio_bitrate?: string;
|
||||
audio_channel?: string;
|
||||
};
|
||||
}
|
||||
|
||||
export type Attachment = {
|
||||
export interface Attachment {
|
||||
id: string;
|
||||
type: "unknown" | "image" | "gifv" | "video" | "audio";
|
||||
url: string;
|
||||
|
|
@ -44,4 +44,4 @@ export type Attachment = {
|
|||
meta: Meta | null;
|
||||
description: string | null;
|
||||
blurhash: string | null;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export type Card = {
|
||||
export interface Card {
|
||||
url: string;
|
||||
title: string;
|
||||
description: string;
|
||||
|
|
@ -13,4 +13,4 @@ export type Card = {
|
|||
height: number;
|
||||
embed_url: string;
|
||||
blurhash: string | null;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Status } from "./status";
|
||||
|
||||
export type Context = {
|
||||
ancestors: Array<Status>;
|
||||
descendants: Array<Status>;
|
||||
};
|
||||
export interface Context {
|
||||
ancestors: Status[];
|
||||
descendants: Status[];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { Account } from "./account";
|
||||
import { Status } from "./status";
|
||||
|
||||
export type Conversation = {
|
||||
export interface Conversation {
|
||||
id: string;
|
||||
accounts: Array<Account>;
|
||||
accounts: Account[];
|
||||
last_status: Status | null;
|
||||
unread: boolean;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
export type Emoji = {
|
||||
export interface Emoji {
|
||||
shortcode: string;
|
||||
static_url: string;
|
||||
url: string;
|
||||
visible_in_picker: boolean;
|
||||
category?: string;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
export type FeaturedTag = {
|
||||
export interface FeaturedTag {
|
||||
id: string;
|
||||
name: string;
|
||||
statuses_count: number;
|
||||
last_status_at: string;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
export type Field = {
|
||||
export interface Field {
|
||||
name: string;
|
||||
value: string;
|
||||
verified_at: string | null;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
export type Filter = {
|
||||
export interface Filter {
|
||||
id: string;
|
||||
phrase: string;
|
||||
context: Array<FilterContext>;
|
||||
context: FilterContext[];
|
||||
expires_at: string | null;
|
||||
irreversible: boolean;
|
||||
whole_word: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export type FilterContext = string;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
export type History = {
|
||||
export interface History {
|
||||
day: string;
|
||||
uses: number;
|
||||
accounts: number;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
export type IdentityProof = {
|
||||
export interface IdentityProof {
|
||||
provider: string;
|
||||
provider_username: string;
|
||||
updated_at: string;
|
||||
proof_url: string;
|
||||
profile_url: string;
|
||||
};
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ import { Account } from "./account";
|
|||
import { Stats } from "./stats";
|
||||
import { URLs } from "./urls";
|
||||
|
||||
export type Instance = {
|
||||
export interface Instance {
|
||||
uri: string;
|
||||
title: string;
|
||||
description: string;
|
||||
|
|
@ -11,7 +11,7 @@ export type Instance = {
|
|||
thumbnail: string | null;
|
||||
urls: URLs;
|
||||
stats: Stats;
|
||||
languages: Array<string>;
|
||||
languages: string[];
|
||||
registrations: boolean;
|
||||
approval_required: boolean;
|
||||
invites_enabled: boolean;
|
||||
|
|
@ -23,7 +23,7 @@ export type Instance = {
|
|||
characters_reserved_per_url: number;
|
||||
};
|
||||
media_attachments: {
|
||||
supported_mime_types: Array<string>;
|
||||
supported_mime_types: string[];
|
||||
image_size_limit: number;
|
||||
image_matrix_limit: number;
|
||||
video_size_limit: number;
|
||||
|
|
@ -38,10 +38,10 @@ export type Instance = {
|
|||
};
|
||||
};
|
||||
contact_account: Account;
|
||||
rules: Array<InstanceRule>;
|
||||
};
|
||||
rules: InstanceRule[];
|
||||
}
|
||||
|
||||
export type InstanceRule = {
|
||||
export interface InstanceRule {
|
||||
id: string;
|
||||
text: string;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
export type List = {
|
||||
export interface List {
|
||||
id: string;
|
||||
title: string;
|
||||
replies_policy: RepliesPolicy;
|
||||
};
|
||||
}
|
||||
|
||||
export type RepliesPolicy = "followed" | "list" | "none";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export type Marker = {
|
||||
export interface Marker {
|
||||
home: {
|
||||
last_read_id: string;
|
||||
version: number;
|
||||
|
|
@ -9,4 +9,4 @@ export type Marker = {
|
|||
version: number;
|
||||
updated_at: string;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
export type Mention = {
|
||||
export interface Mention {
|
||||
id: string;
|
||||
username: string;
|
||||
url: string;
|
||||
acct: string;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,12 @@
|
|||
import { Account } from "./account"
|
||||
import { Status } from "./status"
|
||||
import { Account } from "./account";
|
||||
import { Status } from "./status";
|
||||
|
||||
namespace MastodonEntity {
|
||||
export type Notification = {
|
||||
account: Account
|
||||
created_at: string
|
||||
id: string
|
||||
status?: Status
|
||||
type: NotificationType
|
||||
export interface Notification {
|
||||
account: Account;
|
||||
created_at: string;
|
||||
id: string;
|
||||
status?: Status;
|
||||
type: NotificationType;
|
||||
}
|
||||
|
||||
export type NotificationType = string
|
||||
}
|
||||
export type NotificationType = string;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { PollOption } from "./poll_option";
|
||||
|
||||
export type Poll = {
|
||||
export interface Poll {
|
||||
id: string;
|
||||
expires_at: string | null;
|
||||
expired: boolean;
|
||||
multiple: boolean;
|
||||
votes_count: number;
|
||||
options: Array<PollOption>;
|
||||
options: PollOption[];
|
||||
voted: boolean;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export type PollOption = {
|
||||
export interface PollOption {
|
||||
title: string;
|
||||
votes_count: number | null;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
export type Preferences = {
|
||||
export interface Preferences {
|
||||
"posting:default:visibility": "public" | "unlisted" | "private" | "direct";
|
||||
"posting:default:sensitive": boolean;
|
||||
"posting:default:language": string | null;
|
||||
"reading:expand:media": "default" | "show_all" | "hide_all";
|
||||
"reading:expand:spoilers": boolean;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,14 @@
|
|||
export type Alerts = {
|
||||
export interface Alerts {
|
||||
follow: boolean;
|
||||
favourite: boolean;
|
||||
mention: boolean;
|
||||
reblog: boolean;
|
||||
poll: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
export type PushSubscription = {
|
||||
export interface PushSubscription {
|
||||
id: string;
|
||||
endpoint: string;
|
||||
server_key: string;
|
||||
alerts: Alerts;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export type Relationship = {
|
||||
export interface Relationship {
|
||||
id: string;
|
||||
following: boolean;
|
||||
followed_by: boolean;
|
||||
|
|
@ -12,5 +12,5 @@ export type Relationship = {
|
|||
endorsed: boolean;
|
||||
notifying: boolean;
|
||||
note: string;
|
||||
languages: Array<string>;
|
||||
};
|
||||
languages: string[];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,15 @@
|
|||
import { Account } from "./account";
|
||||
|
||||
export type Report = {
|
||||
export interface Report {
|
||||
id: string;
|
||||
action_taken: boolean;
|
||||
action_taken_at: string | null;
|
||||
category: Category;
|
||||
comment: string;
|
||||
forwarded: boolean;
|
||||
status_ids: Array<string> | null;
|
||||
rule_ids: Array<string> | null;
|
||||
status_ids: string[] | null;
|
||||
rule_ids: string[] | null;
|
||||
target_account: Account;
|
||||
};
|
||||
}
|
||||
|
||||
export type Category = "spam" | "violation" | "other";
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ import { Account } from "./account";
|
|||
import { Status } from "./status";
|
||||
import { Tag } from "./tag";
|
||||
|
||||
export type Results = {
|
||||
accounts: Array<Account>;
|
||||
statuses: Array<Status>;
|
||||
hashtags: Array<Tag>;
|
||||
};
|
||||
export interface Results {
|
||||
accounts: Account[];
|
||||
statuses: Status[];
|
||||
hashtags: Tag[];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
export type Role = {
|
||||
export interface Role {
|
||||
name: string;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { Attachment } from "./attachment";
|
||||
import { StatusParams } from "./status_params";
|
||||
|
||||
export type ScheduledStatus = {
|
||||
export interface ScheduledStatus {
|
||||
id: string;
|
||||
scheduled_at: string;
|
||||
params: StatusParams;
|
||||
media_attachments: Array<Attachment>;
|
||||
};
|
||||
media_attachments: Attachment[];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { Field } from "./field";
|
||||
|
||||
export type Source = {
|
||||
export interface Source {
|
||||
privacy: string | null;
|
||||
sensitive: boolean | null;
|
||||
language: string | null;
|
||||
note: string;
|
||||
fields: Array<Field>;
|
||||
};
|
||||
fields: Field[];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
export type Stats = {
|
||||
export interface Stats {
|
||||
user_count: number;
|
||||
status_count: number;
|
||||
domain_count: number;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { Emoji } from "./emoji";
|
|||
import { Mention } from "./mention";
|
||||
import { Poll } from "./poll";
|
||||
|
||||
export type Status = {
|
||||
export interface Status {
|
||||
id: string;
|
||||
uri: string;
|
||||
url: string;
|
||||
|
|
@ -26,9 +26,9 @@ export type Status = {
|
|||
sensitive: boolean;
|
||||
spoiler_text: string;
|
||||
visibility: "public" | "unlisted" | "private" | "direct";
|
||||
media_attachments: Array<Attachment>;
|
||||
mentions: Array<Mention>;
|
||||
tags: Array<StatusTag>;
|
||||
media_attachments: Attachment[];
|
||||
mentions: Mention[];
|
||||
tags: StatusTag[];
|
||||
card: Card | null;
|
||||
poll: Poll | null;
|
||||
application: Application | null;
|
||||
|
|
@ -38,9 +38,9 @@ export type Status = {
|
|||
// These parameters are unique parameters in fedibird.com for quote.
|
||||
quote_id?: string;
|
||||
quote?: Status | null;
|
||||
};
|
||||
}
|
||||
|
||||
export type StatusTag = {
|
||||
export interface StatusTag {
|
||||
name: string;
|
||||
url: string;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
export type StatusParams = {
|
||||
export interface StatusParams {
|
||||
text: string;
|
||||
in_reply_to_id: string | null;
|
||||
media_ids: Array<string> | null;
|
||||
media_ids: string[] | null;
|
||||
sensitive: boolean | null;
|
||||
spoiler_text: string | null;
|
||||
visibility: "public" | "unlisted" | "private" | "direct" | null;
|
||||
scheduled_at: string | null;
|
||||
application_id: number;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
export type StatusSource = {
|
||||
export interface StatusSource {
|
||||
id: string;
|
||||
text: string;
|
||||
spoiler_text: string;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { History } from "./history";
|
||||
|
||||
export type Tag = {
|
||||
export interface Tag {
|
||||
name: string;
|
||||
url: string;
|
||||
history: Array<History>;
|
||||
history: History[];
|
||||
following?: boolean;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
export type Token = {
|
||||
export interface Token {
|
||||
access_token: string;
|
||||
token_type: string;
|
||||
scope: string;
|
||||
created_at: number;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
export type URLs = {
|
||||
export interface URLs {
|
||||
streaming_api: string;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import data from "../config/config.toml";
|
||||
|
||||
export type ConfigType = {
|
||||
export interface ConfigType {
|
||||
database: {
|
||||
host: string;
|
||||
port: number;
|
||||
|
|
@ -8,7 +8,7 @@ export type ConfigType = {
|
|||
password: string;
|
||||
database: string;
|
||||
}
|
||||
[ key: string ]: any;
|
||||
[ key: string ]: unknown;
|
||||
}
|
||||
|
||||
export const getConfig = () => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
export const jsonResponse = (data: object, status: number = 200) => {
|
||||
export const jsonResponse = (data: object, status = 200) => {
|
||||
return new Response(JSON.stringify(data), {
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
|
|
|
|||
Loading…
Reference in a new issue