decentralised message store
1import type {
2 FastifyReply,
3 FastifyRequest,
4 HookHandlerDoneFunction,
5} from "fastify";
6import type { WebSocket } from "ws";
7
8export type RouteHandler = (
9 req: FastifyRequest,
10 reply: FastifyReply,
11) => Response | Promise<Response>;
12
13export type PreHandler = (
14 req: FastifyRequest,
15 reply: FastifyReply,
16 done: HookHandlerDoneFunction,
17) => void;
18
19export type Method = "GET" | "POST" | "PUT" | "DELETE" | "PATCH";
20
21export interface Route {
22 method: Method;
23 handler: RouteHandler;
24 wsHandler?: undefined;
25 skipRegistrationCheck?: true;
26}
27
28export type WsRouteHandler = (socket: WebSocket, req: FastifyRequest) => void;
29
30export interface WsRoute {
31 method?: Method;
32 handler?: RouteHandler;
33 wsHandler: WsRouteHandler;
34 preHandler?: PreHandler;
35 skipRegistrationCheckHttp?: true;
36 skipRegistrationCheckWs?: true;
37}