move strategy to index.ts and add adapters

This commit is contained in:
Jacob Nguyen
2023-04-27 13:20:11 -05:00
parent 97ad338830
commit d41cc9ea2d
2 changed files with 38 additions and 23 deletions

View File

@@ -1 +1,38 @@
export * from './strategy';
export const enum DispatchType {
Websocket,
Serverless
}
export type PlatformStrategy =
| WebsocketStrategy
| ServerlessStrategy;
export interface WebsocketStrategy {
type: DispatchType.Websocket;
//icreate, messageCreate, ready
eventNames: [ string, string, string]
defaultPrefix?: string;
}
export interface ServerlessStrategy {
type: DispatchType.Serverless;
endpoint: string;
}
export function makeWebsocketAdapter(
eventNames: [interactionCreate: string, messageCreate: string, ready: string],
defaultPrefix?: string
): WebsocketStrategy {
return {
type: DispatchType.Websocket,
eventNames,
defaultPrefix
};
}
export function makeServerlessAdapter(i : { endpoint: string }): ServerlessStrategy {
return {
type: DispatchType.Serverless ,
...i
};
}

View File

@@ -1,22 +0,0 @@
export const enum DispatchType {
Websocket,
Serverless
}
export type PlatformStrategy =
| WebsocketStrategy
| ServerlessStrategy;
export interface WebsocketStrategy {
type: DispatchType.Websocket;
interactionCreate: string;
messageCreate: string;
ready: string;
defaultPrefix?: string;
}
export interface ServerlessStrategy {
type: DispatchType.Serverless;
endpoint: string;
}