mirror of
https://github.com/versia-pub/server.git
synced 2025-12-06 08:28:19 +01:00
Initial commit
This commit is contained in:
commit
436a79d99f
7
.eslintrc.js
Normal file
7
.eslintrc.js
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
module.exports = {
|
||||||
|
extends: [
|
||||||
|
"eslint:strict",
|
||||||
|
"plugin:@typescript-eslint/strict-type-checked",
|
||||||
|
"plugin:@typescript-eslint/stylistic",
|
||||||
|
],
|
||||||
|
};
|
||||||
170
.gitignore
vendored
Normal file
170
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,170 @@
|
||||||
|
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
|
||||||
|
|
||||||
|
# Logs
|
||||||
|
|
||||||
|
logs
|
||||||
|
_.log
|
||||||
|
npm-debug.log_
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
.pnpm-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
|
||||||
|
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
|
||||||
|
pids
|
||||||
|
_.pid
|
||||||
|
_.seed
|
||||||
|
\*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
|
||||||
|
coverage
|
||||||
|
\*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# Snowpack dependency directory (https://snowpack.dev/)
|
||||||
|
|
||||||
|
web_modules/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
|
||||||
|
\*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional stylelint cache
|
||||||
|
|
||||||
|
.stylelintcache
|
||||||
|
|
||||||
|
# Microbundle cache
|
||||||
|
|
||||||
|
.rpt2_cache/
|
||||||
|
.rts2_cache_cjs/
|
||||||
|
.rts2_cache_es/
|
||||||
|
.rts2_cache_umd/
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
|
||||||
|
\*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variable files
|
||||||
|
|
||||||
|
.env
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
.env.local
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
|
||||||
|
.cache
|
||||||
|
.parcel-cache
|
||||||
|
|
||||||
|
# Next.js build output
|
||||||
|
|
||||||
|
.next
|
||||||
|
out
|
||||||
|
|
||||||
|
# Nuxt.js build / generate output
|
||||||
|
|
||||||
|
.nuxt
|
||||||
|
dist
|
||||||
|
|
||||||
|
# Gatsby files
|
||||||
|
|
||||||
|
.cache/
|
||||||
|
|
||||||
|
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||||
|
|
||||||
|
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||||
|
|
||||||
|
# public
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# vuepress v2.x temp and cache directory
|
||||||
|
|
||||||
|
.temp
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# Docusaurus cache and generated files
|
||||||
|
|
||||||
|
.docusaurus
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# TernJS port file
|
||||||
|
|
||||||
|
.tern-port
|
||||||
|
|
||||||
|
# Stores VSCode versions used for testing VSCode extensions
|
||||||
|
|
||||||
|
.vscode-test
|
||||||
|
|
||||||
|
# yarn v2
|
||||||
|
|
||||||
|
.yarn/cache
|
||||||
|
.yarn/unplugged
|
||||||
|
.yarn/build-state.yml
|
||||||
|
.yarn/install-state.gz
|
||||||
|
.pnp.\*
|
||||||
|
config/config.toml
|
||||||
15
README.md
Normal file
15
README.md
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
# fedi-project
|
||||||
|
|
||||||
|
To install dependencies:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bun install
|
||||||
|
```
|
||||||
|
|
||||||
|
To run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bun run index.ts
|
||||||
|
```
|
||||||
|
|
||||||
|
This project was created using `bun init` in bun v0.8.1. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
|
||||||
17
database/datasource.ts
Normal file
17
database/datasource.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { DataSource } from "typeorm";
|
||||||
|
import { getConfig } from "../utils/config";
|
||||||
|
|
||||||
|
const config = getConfig();
|
||||||
|
|
||||||
|
const AppDataSource = new DataSource({
|
||||||
|
type: "postgres",
|
||||||
|
host: config.database.host,
|
||||||
|
port: config.database.port,
|
||||||
|
username: config.database.username,
|
||||||
|
password: config.database.password,
|
||||||
|
database: config.database.database,
|
||||||
|
synchronize: true,
|
||||||
|
entities: ["./entities/*.ts"],
|
||||||
|
});
|
||||||
|
|
||||||
|
export { AppDataSource };
|
||||||
21
database/entities/User.ts
Normal file
21
database/entities/User.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
import { BaseEntity, Column, CreateDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
|
||||||
|
|
||||||
|
@Entity({
|
||||||
|
name: "users",
|
||||||
|
})
|
||||||
|
export class User extends BaseEntity {
|
||||||
|
@PrimaryGeneratedColumn("uuid")
|
||||||
|
id!: string;
|
||||||
|
|
||||||
|
@Column("varchar")
|
||||||
|
username!: string;
|
||||||
|
|
||||||
|
@Column("varchar")
|
||||||
|
password!: string;
|
||||||
|
|
||||||
|
@CreateDateColumn()
|
||||||
|
created_at!: Date;
|
||||||
|
|
||||||
|
@UpdateDateColumn()
|
||||||
|
updated_at!: Date;
|
||||||
|
}
|
||||||
23
index.ts
Normal file
23
index.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
const router = new Bun.FileSystemRouter({
|
||||||
|
style: "nextjs",
|
||||||
|
dir: process.cwd() + "/server/api",
|
||||||
|
})
|
||||||
|
|
||||||
|
Bun.serve({
|
||||||
|
port: 8080,
|
||||||
|
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);
|
||||||
|
} else {
|
||||||
|
const response = new Response(undefined, {
|
||||||
|
status: 404,
|
||||||
|
statusText: "Route not found",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
17
package.json
Normal file
17
package.json
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"name": "fedi-project",
|
||||||
|
"module": "index.ts",
|
||||||
|
"type": "module",
|
||||||
|
"devDependencies": {
|
||||||
|
"@typescript-eslint/eslint-plugin": "^6.6.0",
|
||||||
|
"bun-types": "latest",
|
||||||
|
"eslint": "^8.49.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"typescript": "^5.0.0"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"pg": "^8.11.3",
|
||||||
|
"typeorm": "^0.3.17"
|
||||||
|
}
|
||||||
|
}
|
||||||
26
server/api/v1/accounts/[id]/index.ts
Normal file
26
server/api/v1/accounts/[id]/index.ts
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
import { jsonResponse } from "@response";
|
||||||
|
import { MatchedRoute } from "bun";
|
||||||
|
import { User } from "~database/entities/User";
|
||||||
|
|
||||||
|
export default async (
|
||||||
|
req: Request,
|
||||||
|
matchedRoute: MatchedRoute
|
||||||
|
): Promise<Response> => {
|
||||||
|
const id = matchedRoute.params.id;
|
||||||
|
|
||||||
|
const user = await User.findOneBy({
|
||||||
|
id,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!user)
|
||||||
|
return jsonResponse(
|
||||||
|
{
|
||||||
|
statusText: "User not found",
|
||||||
|
},
|
||||||
|
404
|
||||||
|
);
|
||||||
|
|
||||||
|
return jsonResponse({
|
||||||
|
id,
|
||||||
|
});
|
||||||
|
};
|
||||||
30
tsconfig.json
Normal file
30
tsconfig.json
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"lib": ["ESNext"],
|
||||||
|
"module": "esnext",
|
||||||
|
"target": "esnext",
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
"moduleDetection": "force",
|
||||||
|
"allowImportingTsExtensions": true,
|
||||||
|
"noEmit": true,
|
||||||
|
"composite": true,
|
||||||
|
"strict": true,
|
||||||
|
"downlevelIteration": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"jsx": "preserve",
|
||||||
|
"allowSyntheticDefaultImports": true,
|
||||||
|
"strictNullChecks": true,
|
||||||
|
"strictFunctionTypes": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"allowJs": true,
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"types": [
|
||||||
|
"bun-types" // add Bun global
|
||||||
|
],
|
||||||
|
"paths": {
|
||||||
|
"@*": ["./utils/*"],
|
||||||
|
"~*": ["./*"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
34
types/entities/account.ts
Normal file
34
types/entities/account.ts
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
import { Emoji } from "./emoji";
|
||||||
|
import { Field } from "./field";
|
||||||
|
import { Role } from "./role";
|
||||||
|
import { Source } from "./source";
|
||||||
|
|
||||||
|
export type Account = {
|
||||||
|
id: string;
|
||||||
|
username: string;
|
||||||
|
acct: string;
|
||||||
|
display_name: string;
|
||||||
|
locked: boolean;
|
||||||
|
discoverable?: boolean;
|
||||||
|
group: boolean | null;
|
||||||
|
noindex: boolean | null;
|
||||||
|
suspended: boolean | null;
|
||||||
|
limited: boolean | null;
|
||||||
|
created_at: string;
|
||||||
|
followers_count: number;
|
||||||
|
following_count: number;
|
||||||
|
statuses_count: number;
|
||||||
|
note: string;
|
||||||
|
url: string;
|
||||||
|
avatar: string;
|
||||||
|
avatar_static: string;
|
||||||
|
header: string;
|
||||||
|
header_static: string;
|
||||||
|
emojis: Array<Emoji>;
|
||||||
|
moved: Account | null;
|
||||||
|
fields: Array<Field>;
|
||||||
|
bot: boolean;
|
||||||
|
source?: Source;
|
||||||
|
role?: Role;
|
||||||
|
mute_expires_at?: string;
|
||||||
|
};
|
||||||
6
types/entities/activity.ts
Normal file
6
types/entities/activity.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
export type Activity = {
|
||||||
|
week: string;
|
||||||
|
statuses: string;
|
||||||
|
logins: string;
|
||||||
|
registrations: string;
|
||||||
|
};
|
||||||
39
types/entities/announcement.ts
Normal file
39
types/entities/announcement.ts
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
import { Emoji } from "./emoji";
|
||||||
|
import { StatusTag } from "./status";
|
||||||
|
|
||||||
|
export type Announcement = {
|
||||||
|
id: string;
|
||||||
|
content: string;
|
||||||
|
starts_at: string | null;
|
||||||
|
ends_at: string | null;
|
||||||
|
published: boolean;
|
||||||
|
all_day: boolean;
|
||||||
|
published_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
read: boolean | null;
|
||||||
|
mentions: Array<AnnouncementAccount>;
|
||||||
|
statuses: Array<AnnouncementStatus>;
|
||||||
|
tags: Array<StatusTag>;
|
||||||
|
emojis: Array<Emoji>;
|
||||||
|
reactions: Array<AnnouncementReaction>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type AnnouncementAccount = {
|
||||||
|
id: string;
|
||||||
|
username: string;
|
||||||
|
url: string;
|
||||||
|
acct: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type AnnouncementStatus = {
|
||||||
|
id: string;
|
||||||
|
url: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type AnnouncementReaction = {
|
||||||
|
name: string;
|
||||||
|
count: number;
|
||||||
|
me: boolean | null;
|
||||||
|
url: string | null;
|
||||||
|
static_url: string | null;
|
||||||
|
};
|
||||||
5
types/entities/application.ts
Normal file
5
types/entities/application.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
export type Application = {
|
||||||
|
name: string;
|
||||||
|
website?: string | null;
|
||||||
|
vapid_key?: string | null;
|
||||||
|
};
|
||||||
13
types/entities/async_attachment.ts
Normal file
13
types/entities/async_attachment.ts
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
import { Meta } from "./attachment";
|
||||||
|
|
||||||
|
export type AsyncAttachment = {
|
||||||
|
id: string;
|
||||||
|
type: "unknown" | "image" | "gifv" | "video" | "audio";
|
||||||
|
url: string | null;
|
||||||
|
remote_url: string | null;
|
||||||
|
preview_url: string;
|
||||||
|
text_url: string | null;
|
||||||
|
meta: Meta | null;
|
||||||
|
description: string | null;
|
||||||
|
blurhash: string | null;
|
||||||
|
};
|
||||||
47
types/entities/attachment.ts
Normal file
47
types/entities/attachment.ts
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
export type Sub = {
|
||||||
|
// For Image, Gifv, and Video
|
||||||
|
width?: number;
|
||||||
|
height?: number;
|
||||||
|
size?: string;
|
||||||
|
aspect?: number;
|
||||||
|
|
||||||
|
// For Gifv and Video
|
||||||
|
frame_rate?: string;
|
||||||
|
|
||||||
|
// For Audio, Gifv, and Video
|
||||||
|
duration?: number;
|
||||||
|
bitrate?: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Focus = {
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Meta = {
|
||||||
|
original?: Sub;
|
||||||
|
small?: Sub;
|
||||||
|
focus?: Focus;
|
||||||
|
length?: string;
|
||||||
|
duration?: number;
|
||||||
|
fps?: number;
|
||||||
|
size?: string;
|
||||||
|
width?: number;
|
||||||
|
height?: number;
|
||||||
|
aspect?: number;
|
||||||
|
audio_encode?: string;
|
||||||
|
audio_bitrate?: string;
|
||||||
|
audio_channel?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Attachment = {
|
||||||
|
id: string;
|
||||||
|
type: "unknown" | "image" | "gifv" | "video" | "audio";
|
||||||
|
url: string;
|
||||||
|
remote_url: string | null;
|
||||||
|
preview_url: string | null;
|
||||||
|
text_url: string | null;
|
||||||
|
meta: Meta | null;
|
||||||
|
description: string | null;
|
||||||
|
blurhash: string | null;
|
||||||
|
};
|
||||||
16
types/entities/card.ts
Normal file
16
types/entities/card.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
export type Card = {
|
||||||
|
url: string;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
type: "link" | "photo" | "video" | "rich";
|
||||||
|
image: string | null;
|
||||||
|
author_name: string;
|
||||||
|
author_url: string;
|
||||||
|
provider_name: string;
|
||||||
|
provider_url: string;
|
||||||
|
html: string;
|
||||||
|
width: number;
|
||||||
|
height: number;
|
||||||
|
embed_url: string;
|
||||||
|
blurhash: string | null;
|
||||||
|
};
|
||||||
6
types/entities/context.ts
Normal file
6
types/entities/context.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
import { Status } from "./status";
|
||||||
|
|
||||||
|
export type Context = {
|
||||||
|
ancestors: Array<Status>;
|
||||||
|
descendants: Array<Status>;
|
||||||
|
};
|
||||||
9
types/entities/conversation.ts
Normal file
9
types/entities/conversation.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { Account } from "./account";
|
||||||
|
import { Status } from "./status";
|
||||||
|
|
||||||
|
export type Conversation = {
|
||||||
|
id: string;
|
||||||
|
accounts: Array<Account>;
|
||||||
|
last_status: Status | null;
|
||||||
|
unread: boolean;
|
||||||
|
};
|
||||||
7
types/entities/emoji.ts
Normal file
7
types/entities/emoji.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
export type Emoji = {
|
||||||
|
shortcode: string;
|
||||||
|
static_url: string;
|
||||||
|
url: string;
|
||||||
|
visible_in_picker: boolean;
|
||||||
|
category?: string;
|
||||||
|
};
|
||||||
6
types/entities/featured_tag.ts
Normal file
6
types/entities/featured_tag.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
export type FeaturedTag = {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
statuses_count: number;
|
||||||
|
last_status_at: string;
|
||||||
|
};
|
||||||
5
types/entities/field.ts
Normal file
5
types/entities/field.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
export type Field = {
|
||||||
|
name: string;
|
||||||
|
value: string;
|
||||||
|
verified_at: string | null;
|
||||||
|
};
|
||||||
10
types/entities/filter.ts
Normal file
10
types/entities/filter.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
export type Filter = {
|
||||||
|
id: string;
|
||||||
|
phrase: string;
|
||||||
|
context: Array<FilterContext>;
|
||||||
|
expires_at: string | null;
|
||||||
|
irreversible: boolean;
|
||||||
|
whole_word: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type FilterContext = string;
|
||||||
5
types/entities/history.ts
Normal file
5
types/entities/history.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
export type History = {
|
||||||
|
day: string;
|
||||||
|
uses: number;
|
||||||
|
accounts: number;
|
||||||
|
};
|
||||||
7
types/entities/identity_proof.ts
Normal file
7
types/entities/identity_proof.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
export type IdentityProof = {
|
||||||
|
provider: string;
|
||||||
|
provider_username: string;
|
||||||
|
updated_at: string;
|
||||||
|
proof_url: string;
|
||||||
|
profile_url: string;
|
||||||
|
};
|
||||||
47
types/entities/instance.ts
Normal file
47
types/entities/instance.ts
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
import { Account } from "./account";
|
||||||
|
import { Stats } from "./stats";
|
||||||
|
import { URLs } from "./urls";
|
||||||
|
|
||||||
|
export type Instance = {
|
||||||
|
uri: string;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
email: string;
|
||||||
|
version: string;
|
||||||
|
thumbnail: string | null;
|
||||||
|
urls: URLs;
|
||||||
|
stats: Stats;
|
||||||
|
languages: Array<string>;
|
||||||
|
registrations: boolean;
|
||||||
|
approval_required: boolean;
|
||||||
|
invites_enabled: boolean;
|
||||||
|
max_toot_chars?: number;
|
||||||
|
configuration: {
|
||||||
|
statuses: {
|
||||||
|
max_characters: number;
|
||||||
|
max_media_attachments: number;
|
||||||
|
characters_reserved_per_url: number;
|
||||||
|
};
|
||||||
|
media_attachments: {
|
||||||
|
supported_mime_types: Array<string>;
|
||||||
|
image_size_limit: number;
|
||||||
|
image_matrix_limit: number;
|
||||||
|
video_size_limit: number;
|
||||||
|
video_frame_limit: number;
|
||||||
|
video_matrix_limit: number;
|
||||||
|
};
|
||||||
|
polls: {
|
||||||
|
max_options: number;
|
||||||
|
max_characters_per_option: number;
|
||||||
|
min_expiration: number;
|
||||||
|
max_expiration: number;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
contact_account: Account;
|
||||||
|
rules: Array<InstanceRule>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type InstanceRule = {
|
||||||
|
id: string;
|
||||||
|
text: string;
|
||||||
|
};
|
||||||
7
types/entities/list.ts
Normal file
7
types/entities/list.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
export type List = {
|
||||||
|
id: string;
|
||||||
|
title: string;
|
||||||
|
replies_policy: RepliesPolicy;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type RepliesPolicy = "followed" | "list" | "none";
|
||||||
12
types/entities/marker.ts
Normal file
12
types/entities/marker.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
export type Marker = {
|
||||||
|
home: {
|
||||||
|
last_read_id: string;
|
||||||
|
version: number;
|
||||||
|
updated_at: string;
|
||||||
|
};
|
||||||
|
notifications: {
|
||||||
|
last_read_id: string;
|
||||||
|
version: number;
|
||||||
|
updated_at: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
6
types/entities/mention.ts
Normal file
6
types/entities/mention.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
export type Mention = {
|
||||||
|
id: string;
|
||||||
|
username: string;
|
||||||
|
url: string;
|
||||||
|
acct: string;
|
||||||
|
};
|
||||||
14
types/entities/notification.ts
Normal file
14
types/entities/notification.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
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 type NotificationType = string
|
||||||
|
}
|
||||||
11
types/entities/poll.ts
Normal file
11
types/entities/poll.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { PollOption } from "./poll_option";
|
||||||
|
|
||||||
|
export type Poll = {
|
||||||
|
id: string;
|
||||||
|
expires_at: string | null;
|
||||||
|
expired: boolean;
|
||||||
|
multiple: boolean;
|
||||||
|
votes_count: number;
|
||||||
|
options: Array<PollOption>;
|
||||||
|
voted: boolean;
|
||||||
|
};
|
||||||
4
types/entities/poll_option.ts
Normal file
4
types/entities/poll_option.ts
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
export type PollOption = {
|
||||||
|
title: string;
|
||||||
|
votes_count: number | null;
|
||||||
|
};
|
||||||
7
types/entities/preferences.ts
Normal file
7
types/entities/preferences.ts
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
export type 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;
|
||||||
|
};
|
||||||
14
types/entities/push_subscription.ts
Normal file
14
types/entities/push_subscription.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
export type Alerts = {
|
||||||
|
follow: boolean;
|
||||||
|
favourite: boolean;
|
||||||
|
mention: boolean;
|
||||||
|
reblog: boolean;
|
||||||
|
poll: boolean;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type PushSubscription = {
|
||||||
|
id: string;
|
||||||
|
endpoint: string;
|
||||||
|
server_key: string;
|
||||||
|
alerts: Alerts;
|
||||||
|
};
|
||||||
16
types/entities/relationship.ts
Normal file
16
types/entities/relationship.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
export type Relationship = {
|
||||||
|
id: string;
|
||||||
|
following: boolean;
|
||||||
|
followed_by: boolean;
|
||||||
|
blocking: boolean;
|
||||||
|
blocked_by: boolean;
|
||||||
|
muting: boolean;
|
||||||
|
muting_notifications: boolean;
|
||||||
|
requested: boolean;
|
||||||
|
domain_blocking: boolean;
|
||||||
|
showing_reblogs: boolean;
|
||||||
|
endorsed: boolean;
|
||||||
|
notifying: boolean;
|
||||||
|
note: string;
|
||||||
|
languages: Array<string>;
|
||||||
|
};
|
||||||
15
types/entities/report.ts
Normal file
15
types/entities/report.ts
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
import { Account } from "./account";
|
||||||
|
|
||||||
|
export type 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;
|
||||||
|
target_account: Account;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type Category = "spam" | "violation" | "other";
|
||||||
9
types/entities/results.ts
Normal file
9
types/entities/results.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { Account } from "./account";
|
||||||
|
import { Status } from "./status";
|
||||||
|
import { Tag } from "./tag";
|
||||||
|
|
||||||
|
export type Results = {
|
||||||
|
accounts: Array<Account>;
|
||||||
|
statuses: Array<Status>;
|
||||||
|
hashtags: Array<Tag>;
|
||||||
|
};
|
||||||
3
types/entities/role.ts
Normal file
3
types/entities/role.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
export type Role = {
|
||||||
|
name: string;
|
||||||
|
};
|
||||||
9
types/entities/scheduled_status.ts
Normal file
9
types/entities/scheduled_status.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { Attachment } from "./attachment";
|
||||||
|
import { StatusParams } from "./status_params";
|
||||||
|
|
||||||
|
export type ScheduledStatus = {
|
||||||
|
id: string;
|
||||||
|
scheduled_at: string;
|
||||||
|
params: StatusParams;
|
||||||
|
media_attachments: Array<Attachment>;
|
||||||
|
};
|
||||||
9
types/entities/source.ts
Normal file
9
types/entities/source.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { Field } from "./field";
|
||||||
|
|
||||||
|
export type Source = {
|
||||||
|
privacy: string | null;
|
||||||
|
sensitive: boolean | null;
|
||||||
|
language: string | null;
|
||||||
|
note: string;
|
||||||
|
fields: Array<Field>;
|
||||||
|
};
|
||||||
5
types/entities/stats.ts
Normal file
5
types/entities/stats.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
export type Stats = {
|
||||||
|
user_count: number;
|
||||||
|
status_count: number;
|
||||||
|
domain_count: number;
|
||||||
|
};
|
||||||
46
types/entities/status.ts
Normal file
46
types/entities/status.ts
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
import { Account } from "./account";
|
||||||
|
import { Application } from "./application";
|
||||||
|
import { Attachment } from "./attachment";
|
||||||
|
import { Card } from "./card";
|
||||||
|
import { Emoji } from "./emoji";
|
||||||
|
import { Mention } from "./mention";
|
||||||
|
import { Poll } from "./poll";
|
||||||
|
|
||||||
|
export type Status = {
|
||||||
|
id: string;
|
||||||
|
uri: string;
|
||||||
|
url: string;
|
||||||
|
account: Account;
|
||||||
|
in_reply_to_id: string | null;
|
||||||
|
in_reply_to_account_id: string | null;
|
||||||
|
reblog: Status | null;
|
||||||
|
content: string;
|
||||||
|
created_at: string;
|
||||||
|
emojis: Emoji[];
|
||||||
|
replies_count: number;
|
||||||
|
reblogs_count: number;
|
||||||
|
favourites_count: number;
|
||||||
|
reblogged: boolean | null;
|
||||||
|
favourited: boolean | null;
|
||||||
|
muted: boolean | null;
|
||||||
|
sensitive: boolean;
|
||||||
|
spoiler_text: string;
|
||||||
|
visibility: "public" | "unlisted" | "private" | "direct";
|
||||||
|
media_attachments: Array<Attachment>;
|
||||||
|
mentions: Array<Mention>;
|
||||||
|
tags: Array<StatusTag>;
|
||||||
|
card: Card | null;
|
||||||
|
poll: Poll | null;
|
||||||
|
application: Application | null;
|
||||||
|
language: string | null;
|
||||||
|
pinned: boolean | null;
|
||||||
|
bookmarked?: boolean;
|
||||||
|
// These parameters are unique parameters in fedibird.com for quote.
|
||||||
|
quote_id?: string;
|
||||||
|
quote?: Status | null;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type StatusTag = {
|
||||||
|
name: string;
|
||||||
|
url: string;
|
||||||
|
};
|
||||||
10
types/entities/status_params.ts
Normal file
10
types/entities/status_params.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
export type StatusParams = {
|
||||||
|
text: string;
|
||||||
|
in_reply_to_id: string | null;
|
||||||
|
media_ids: Array<string> | null;
|
||||||
|
sensitive: boolean | null;
|
||||||
|
spoiler_text: string | null;
|
||||||
|
visibility: "public" | "unlisted" | "private" | "direct" | null;
|
||||||
|
scheduled_at: string | null;
|
||||||
|
application_id: number;
|
||||||
|
};
|
||||||
5
types/entities/status_source.ts
Normal file
5
types/entities/status_source.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
export type StatusSource = {
|
||||||
|
id: string;
|
||||||
|
text: string;
|
||||||
|
spoiler_text: string;
|
||||||
|
};
|
||||||
8
types/entities/tag.ts
Normal file
8
types/entities/tag.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
import { History } from "./history";
|
||||||
|
|
||||||
|
export type Tag = {
|
||||||
|
name: string;
|
||||||
|
url: string;
|
||||||
|
history: Array<History>;
|
||||||
|
following?: boolean;
|
||||||
|
};
|
||||||
6
types/entities/token.ts
Normal file
6
types/entities/token.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
export type Token = {
|
||||||
|
access_token: string;
|
||||||
|
token_type: string;
|
||||||
|
scope: string;
|
||||||
|
created_at: number;
|
||||||
|
};
|
||||||
3
types/entities/urls.ts
Normal file
3
types/entities/urls.ts
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
export type URLs = {
|
||||||
|
streaming_api: string;
|
||||||
|
};
|
||||||
39
types/entity.ts
Normal file
39
types/entity.ts
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
/// <reference path="./entities/account.ts" />
|
||||||
|
/// <reference path="./entities/activity.ts" />
|
||||||
|
/// <reference path="./entities/announcement.ts" />
|
||||||
|
/// <reference path="./entities/application.ts" />
|
||||||
|
/// <reference path="./entities/async_attachment.ts" />
|
||||||
|
/// <reference path="./entities/attachment.ts" />
|
||||||
|
/// <reference path="./entities/card.ts" />
|
||||||
|
/// <reference path="./entities/context.ts" />
|
||||||
|
/// <reference path="./entities/conversation.ts" />
|
||||||
|
/// <reference path="./entities/emoji.ts" />
|
||||||
|
/// <reference path="./entities/featured_tag.ts" />
|
||||||
|
/// <reference path="./entities/field.ts" />
|
||||||
|
/// <reference path="./entities/filter.ts" />
|
||||||
|
/// <reference path="./entities/history.ts" />
|
||||||
|
/// <reference path="./entities/identity_proof.ts" />
|
||||||
|
/// <reference path="./entities/instance.ts" />
|
||||||
|
/// <reference path="./entities/list.ts" />
|
||||||
|
/// <reference path="./entities/marker.ts" />
|
||||||
|
/// <reference path="./entities/mention.ts" />
|
||||||
|
/// <reference path="./entities/notification.ts" />
|
||||||
|
/// <reference path="./entities/poll.ts" />
|
||||||
|
/// <reference path="./entities/poll_option.ts" />
|
||||||
|
/// <reference path="./entities/preferences.ts" />
|
||||||
|
/// <reference path="./entities/push_subscription.ts" />
|
||||||
|
/// <reference path="./entities/relationship.ts" />
|
||||||
|
/// <reference path="./entities/report.ts" />
|
||||||
|
/// <reference path="./entities/results.ts" />
|
||||||
|
/// <reference path="./entities/role.ts" />
|
||||||
|
/// <reference path="./entities/scheduled_status.ts" />
|
||||||
|
/// <reference path="./entities/source.ts" />
|
||||||
|
/// <reference path="./entities/stats.ts" />
|
||||||
|
/// <reference path="./entities/status.ts" />
|
||||||
|
/// <reference path="./entities/status_params.ts" />
|
||||||
|
/// <reference path="./entities/status_source.ts" />
|
||||||
|
/// <reference path="./entities/tag.ts" />
|
||||||
|
/// <reference path="./entities/token.ts" />
|
||||||
|
/// <reference path="./entities/urls.ts" />
|
||||||
|
|
||||||
|
export default MastodonEntity
|
||||||
16
utils/config.ts
Normal file
16
utils/config.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
import data from "../config/config.toml";
|
||||||
|
|
||||||
|
export type ConfigType = {
|
||||||
|
database: {
|
||||||
|
host: string;
|
||||||
|
port: number;
|
||||||
|
username: string;
|
||||||
|
password: string;
|
||||||
|
database: string;
|
||||||
|
}
|
||||||
|
[ key: string ]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getConfig = () => {
|
||||||
|
return data as ConfigType;
|
||||||
|
}
|
||||||
8
utils/response.ts
Normal file
8
utils/response.ts
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
export const jsonResponse = (data: object, status: number = 200) => {
|
||||||
|
return new Response(JSON.stringify(data), {
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
status,
|
||||||
|
});
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue