From d41cc9ea2d6f6d51cf3c60fea5cc37e3d14b66c5 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Thu, 27 Apr 2023 13:20:11 -0500 Subject: [PATCH] move strategy to index.ts and add adapters --- src/core/platform/index.ts | 39 ++++++++++++++++++++++++++++++++++- src/core/platform/strategy.ts | 22 -------------------- 2 files changed, 38 insertions(+), 23 deletions(-) delete mode 100644 src/core/platform/strategy.ts diff --git a/src/core/platform/index.ts b/src/core/platform/index.ts index b7b40ac..7c7b707 100644 --- a/src/core/platform/index.ts +++ b/src/core/platform/index.ts @@ -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 + }; +} diff --git a/src/core/platform/strategy.ts b/src/core/platform/strategy.ts deleted file mode 100644 index 9b58c77..0000000 --- a/src/core/platform/strategy.ts +++ /dev/null @@ -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; -}