diff --git a/src/api/ApiManager.ts b/src/api/ApiManager.ts index d1d9c0a..7c753d7 100644 --- a/src/api/ApiManager.ts +++ b/src/api/ApiManager.ts @@ -2,6 +2,7 @@ import BaseApi from './BaseApi.ts' import HttpServerLike from '../types/HttpServerLike.ts' import UserApi from "./UserApi.ts" import SocketIo from "socket.io" +import UnknownFunction from "../types/UnknownFunction.ts"; export default class ApiManager { static httpServer: HttpServerLike @@ -14,9 +15,22 @@ export default class ApiManager { static getHttpServer() { return this.httpServer } + static getSocketIoServer() { + return this.socketIoServer + } static initAllApis() { this.apis_instance = { user: new UserApi() } } + static initEvents() { + const io = this.socketIoServer + io.on('connection', (socket) => { + socket.on("The_White_Silk", (name: string, args: {}, callback: UnknownFunction) => { + if (name == null || args == null) return callback({ + + }) + }) + }) + } } diff --git a/src/api/BaseApi.ts b/src/api/BaseApi.ts index 6a36ab0..2d83ca8 100644 --- a/src/api/BaseApi.ts +++ b/src/api/BaseApi.ts @@ -1,4 +1,5 @@ import UnknownFunction from '../types/UnknownFunction.ts' +import ApiManager from "./ApiManager.ts"; export default abstract class BaseApi { abstract getName(): string @@ -7,6 +8,7 @@ export default abstract class BaseApi { } abstract onInit(): void registerEvent(name: string, func: UnknownFunction) { + const io = ApiManager.getSocketIoServer() } } diff --git a/src/types/ApiCallbackMessage.ts b/src/types/ApiCallbackMessage.ts new file mode 100644 index 0000000..565c431 --- /dev/null +++ b/src/types/ApiCallbackMessage.ts @@ -0,0 +1,4 @@ +type ApiCallbackMessage = { + msg: string, + code: 200 | 400 | 401 | 403 | 404 | 500 | 501 +} \ No newline at end of file