mirror of
https://github.com/sern-handler/handler
synced 2026-06-17 05:12:16 +00:00
work on strategy and lifted Context
This commit is contained in:
22
src/core/platform/strategy.ts
Normal file
22
src/core/platform/strategy.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
enum DispatchType {
|
||||
Websocket,
|
||||
Serverless
|
||||
}
|
||||
|
||||
|
||||
type PlatformStrategy =
|
||||
| WebsocketStrategy
|
||||
| ServerlessStrategy;
|
||||
|
||||
interface WebsocketStrategy {
|
||||
type: DispatchType.Websocket;
|
||||
interactionCreate: string;
|
||||
messageCreate: string;
|
||||
ready: string;
|
||||
|
||||
}
|
||||
|
||||
interface ServerlessStrategy {
|
||||
type: DispatchType.Serverless;
|
||||
|
||||
}
|
||||
18
src/core/structures/context.ts
Normal file
18
src/core/structures/context.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Result as Either } from 'ts-results-es';
|
||||
|
||||
|
||||
export abstract class Context<Left, Right> {
|
||||
private constructor(private _: Either<Left, Right>){}
|
||||
|
||||
abstract get message(): Left;
|
||||
abstract get interaction(): Right;
|
||||
abstract get id(): string;
|
||||
|
||||
}
|
||||
|
||||
export function wrap<Left, Right>(
|
||||
val: Left|Right,
|
||||
fa: (val: Left|Right
|
||||
) => Either<Left, Right>) {
|
||||
return fa(val);
|
||||
}
|
||||
Reference in New Issue
Block a user