mirror of
https://github.com/versia-pub/server.git
synced 2026-03-13 05:49:16 +01:00
Replace eslint and prettier with Biome
This commit is contained in:
parent
4a5a2ea590
commit
af0d627f19
199 changed files with 16493 additions and 16361 deletions
|
|
@ -2,11 +2,11 @@ import type { Server } from "./types";
|
|||
import { HookTypes } from "./types";
|
||||
|
||||
const registerPlugin = (server: Server) => {
|
||||
server.on(HookTypes.OnPostCreate, (req, newPost, author) => {
|
||||
console.log("New post created!");
|
||||
console.log(`Post details: ${newPost.content} (${newPost.id})`);
|
||||
console.log(`Made by ${author.username} (${author.id})`);
|
||||
});
|
||||
server.on(HookTypes.OnPostCreate, (req, newPost, author) => {
|
||||
console.log("New post created!");
|
||||
console.log(`Post details: ${newPost.content} (${newPost.id})`);
|
||||
console.log(`Made by ${author.username} (${author.id})`);
|
||||
});
|
||||
};
|
||||
|
||||
export default registerPlugin;
|
||||
|
|
|
|||
280
plugins/types.ts
280
plugins/types.ts
|
|
@ -4,152 +4,152 @@ import type { UserWithRelations } from "~database/entities/User";
|
|||
import type { LysandObjectType } from "~types/lysand/Object";
|
||||
|
||||
export enum HookTypes {
|
||||
/**
|
||||
* Called before the server starts listening
|
||||
*/
|
||||
PreServe = "preServe",
|
||||
/**
|
||||
* Called after the server stops listening
|
||||
*/
|
||||
PostServe = "postServe",
|
||||
/**
|
||||
* Called on every HTTP request (before anything else is done)
|
||||
*/
|
||||
OnRequestReceive = "onRequestReceive",
|
||||
/**
|
||||
* Called on every HTTP request (after it is processed)
|
||||
*/
|
||||
OnRequestProcessed = "onRequestProcessed",
|
||||
/**
|
||||
* Called on every object received (before it is parsed and added to the database)
|
||||
*/
|
||||
OnObjectReceive = "onObjectReceive",
|
||||
/**
|
||||
* Called on every object processed (after it is parsed and added to the database)
|
||||
*/
|
||||
OnObjectProcessed = "onObjectProcessed",
|
||||
/**
|
||||
* Called when signature verification fails on an object
|
||||
*/
|
||||
OnCryptoFail = "onCryptoFail",
|
||||
/**
|
||||
* Called when signature verification succeeds on an object
|
||||
*/
|
||||
OnCryptoSuccess = "onCryptoSuccess",
|
||||
/**
|
||||
* Called when a user is banned by another user
|
||||
*/
|
||||
OnBan = "onBan",
|
||||
/**
|
||||
* Called when a user is suspended by another user
|
||||
*/
|
||||
OnSuspend = "onSuspend",
|
||||
/**
|
||||
* Called when a user is blocked by another user
|
||||
*/
|
||||
OnUserBlock = "onUserBlock",
|
||||
/**
|
||||
* Called when a user is muted by another user
|
||||
*/
|
||||
OnUserMute = "onUserMute",
|
||||
/**
|
||||
* Called when a user is followed by another user
|
||||
*/
|
||||
OnUserFollow = "onUserFollow",
|
||||
/**
|
||||
* Called when a user registers (before completing email verification)
|
||||
*/
|
||||
OnRegister = "onRegister",
|
||||
/**
|
||||
* Called when a user finishes registering (after completing email verification)
|
||||
*/
|
||||
OnRegisterFinish = "onRegisterFinish",
|
||||
/**
|
||||
* Called when a user deletes their account
|
||||
*/
|
||||
OnDeleteAccount = "onDeleteAccount",
|
||||
/**
|
||||
* Called when a post is created
|
||||
*/
|
||||
OnPostCreate = "onPostCreate",
|
||||
/**
|
||||
* Called when a post is deleted
|
||||
*/
|
||||
OnPostDelete = "onPostDelete",
|
||||
/**
|
||||
* Called when a post is updated
|
||||
*/
|
||||
OnPostUpdate = "onPostUpdate",
|
||||
/**
|
||||
* Called before the server starts listening
|
||||
*/
|
||||
PreServe = "preServe",
|
||||
/**
|
||||
* Called after the server stops listening
|
||||
*/
|
||||
PostServe = "postServe",
|
||||
/**
|
||||
* Called on every HTTP request (before anything else is done)
|
||||
*/
|
||||
OnRequestReceive = "onRequestReceive",
|
||||
/**
|
||||
* Called on every HTTP request (after it is processed)
|
||||
*/
|
||||
OnRequestProcessed = "onRequestProcessed",
|
||||
/**
|
||||
* Called on every object received (before it is parsed and added to the database)
|
||||
*/
|
||||
OnObjectReceive = "onObjectReceive",
|
||||
/**
|
||||
* Called on every object processed (after it is parsed and added to the database)
|
||||
*/
|
||||
OnObjectProcessed = "onObjectProcessed",
|
||||
/**
|
||||
* Called when signature verification fails on an object
|
||||
*/
|
||||
OnCryptoFail = "onCryptoFail",
|
||||
/**
|
||||
* Called when signature verification succeeds on an object
|
||||
*/
|
||||
OnCryptoSuccess = "onCryptoSuccess",
|
||||
/**
|
||||
* Called when a user is banned by another user
|
||||
*/
|
||||
OnBan = "onBan",
|
||||
/**
|
||||
* Called when a user is suspended by another user
|
||||
*/
|
||||
OnSuspend = "onSuspend",
|
||||
/**
|
||||
* Called when a user is blocked by another user
|
||||
*/
|
||||
OnUserBlock = "onUserBlock",
|
||||
/**
|
||||
* Called when a user is muted by another user
|
||||
*/
|
||||
OnUserMute = "onUserMute",
|
||||
/**
|
||||
* Called when a user is followed by another user
|
||||
*/
|
||||
OnUserFollow = "onUserFollow",
|
||||
/**
|
||||
* Called when a user registers (before completing email verification)
|
||||
*/
|
||||
OnRegister = "onRegister",
|
||||
/**
|
||||
* Called when a user finishes registering (after completing email verification)
|
||||
*/
|
||||
OnRegisterFinish = "onRegisterFinish",
|
||||
/**
|
||||
* Called when a user deletes their account
|
||||
*/
|
||||
OnDeleteAccount = "onDeleteAccount",
|
||||
/**
|
||||
* Called when a post is created
|
||||
*/
|
||||
OnPostCreate = "onPostCreate",
|
||||
/**
|
||||
* Called when a post is deleted
|
||||
*/
|
||||
OnPostDelete = "onPostDelete",
|
||||
/**
|
||||
* Called when a post is updated
|
||||
*/
|
||||
OnPostUpdate = "onPostUpdate",
|
||||
}
|
||||
|
||||
export interface ServerStats {
|
||||
postCount: number;
|
||||
postCount: number;
|
||||
}
|
||||
|
||||
interface ServerEvents {
|
||||
[HookTypes.PreServe]: () => void;
|
||||
[HookTypes.PostServe]: (stats: ServerStats) => void;
|
||||
[HookTypes.OnRequestReceive]: (req: Request) => void;
|
||||
[HookTypes.OnRequestProcessed]: (req: Request) => void;
|
||||
[HookTypes.OnObjectReceive]: (obj: LysandObjectType) => void;
|
||||
[HookTypes.OnObjectProcessed]: (obj: LysandObjectType) => void;
|
||||
[HookTypes.OnCryptoFail]: (
|
||||
req: Request,
|
||||
obj: LysandObjectType,
|
||||
author: UserWithRelations,
|
||||
publicKey: string
|
||||
) => void;
|
||||
[HookTypes.OnCryptoSuccess]: (
|
||||
req: Request,
|
||||
obj: LysandObjectType,
|
||||
author: UserWithRelations,
|
||||
publicKey: string
|
||||
) => void;
|
||||
[HookTypes.OnBan]: (
|
||||
req: Request,
|
||||
bannedUser: UserWithRelations,
|
||||
banner: UserWithRelations
|
||||
) => void;
|
||||
[HookTypes.OnSuspend]: (
|
||||
req: Request,
|
||||
suspendedUser: UserWithRelations,
|
||||
suspender: UserWithRelations
|
||||
) => void;
|
||||
[HookTypes.OnUserBlock]: (
|
||||
req: Request,
|
||||
blockedUser: UserWithRelations,
|
||||
blocker: UserWithRelations
|
||||
) => void;
|
||||
[HookTypes.OnUserMute]: (
|
||||
req: Request,
|
||||
mutedUser: UserWithRelations,
|
||||
muter: UserWithRelations
|
||||
) => void;
|
||||
[HookTypes.OnUserFollow]: (
|
||||
req: Request,
|
||||
followedUser: UserWithRelations,
|
||||
follower: UserWithRelations
|
||||
) => void;
|
||||
[HookTypes.OnRegister]: (req: Request, newUser: UserWithRelations) => void;
|
||||
[HookTypes.OnDeleteAccount]: (
|
||||
req: Request,
|
||||
deletedUser: UserWithRelations
|
||||
) => void;
|
||||
[HookTypes.OnPostCreate]: (
|
||||
req: Request,
|
||||
newPost: StatusWithRelations,
|
||||
author: UserWithRelations
|
||||
) => void;
|
||||
[HookTypes.OnPostDelete]: (
|
||||
req: Request,
|
||||
deletedPost: StatusWithRelations,
|
||||
deleter: UserWithRelations
|
||||
) => void;
|
||||
[HookTypes.OnPostUpdate]: (
|
||||
req: Request,
|
||||
updatedPost: StatusWithRelations,
|
||||
updater: UserWithRelations
|
||||
) => void;
|
||||
[HookTypes.PreServe]: () => void;
|
||||
[HookTypes.PostServe]: (stats: ServerStats) => void;
|
||||
[HookTypes.OnRequestReceive]: (req: Request) => void;
|
||||
[HookTypes.OnRequestProcessed]: (req: Request) => void;
|
||||
[HookTypes.OnObjectReceive]: (obj: LysandObjectType) => void;
|
||||
[HookTypes.OnObjectProcessed]: (obj: LysandObjectType) => void;
|
||||
[HookTypes.OnCryptoFail]: (
|
||||
req: Request,
|
||||
obj: LysandObjectType,
|
||||
author: UserWithRelations,
|
||||
publicKey: string,
|
||||
) => void;
|
||||
[HookTypes.OnCryptoSuccess]: (
|
||||
req: Request,
|
||||
obj: LysandObjectType,
|
||||
author: UserWithRelations,
|
||||
publicKey: string,
|
||||
) => void;
|
||||
[HookTypes.OnBan]: (
|
||||
req: Request,
|
||||
bannedUser: UserWithRelations,
|
||||
banner: UserWithRelations,
|
||||
) => void;
|
||||
[HookTypes.OnSuspend]: (
|
||||
req: Request,
|
||||
suspendedUser: UserWithRelations,
|
||||
suspender: UserWithRelations,
|
||||
) => void;
|
||||
[HookTypes.OnUserBlock]: (
|
||||
req: Request,
|
||||
blockedUser: UserWithRelations,
|
||||
blocker: UserWithRelations,
|
||||
) => void;
|
||||
[HookTypes.OnUserMute]: (
|
||||
req: Request,
|
||||
mutedUser: UserWithRelations,
|
||||
muter: UserWithRelations,
|
||||
) => void;
|
||||
[HookTypes.OnUserFollow]: (
|
||||
req: Request,
|
||||
followedUser: UserWithRelations,
|
||||
follower: UserWithRelations,
|
||||
) => void;
|
||||
[HookTypes.OnRegister]: (req: Request, newUser: UserWithRelations) => void;
|
||||
[HookTypes.OnDeleteAccount]: (
|
||||
req: Request,
|
||||
deletedUser: UserWithRelations,
|
||||
) => void;
|
||||
[HookTypes.OnPostCreate]: (
|
||||
req: Request,
|
||||
newPost: StatusWithRelations,
|
||||
author: UserWithRelations,
|
||||
) => void;
|
||||
[HookTypes.OnPostDelete]: (
|
||||
req: Request,
|
||||
deletedPost: StatusWithRelations,
|
||||
deleter: UserWithRelations,
|
||||
) => void;
|
||||
[HookTypes.OnPostUpdate]: (
|
||||
req: Request,
|
||||
updatedPost: StatusWithRelations,
|
||||
updater: UserWithRelations,
|
||||
) => void;
|
||||
}
|
||||
|
||||
export class Server extends EventEmitter<ServerEvents> {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue