chore: apply rename: types -> typedef
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
import HttpServerLike from '../types/HttpServerLike.ts'
|
import HttpServerLike from '../typedef/HttpServerLike.ts'
|
||||||
import UserApi from "./UserApi.ts"
|
import UserApi from "./UserApi.ts"
|
||||||
import * as SocketIo from "socket.io"
|
import * as SocketIo from "socket.io"
|
||||||
import ApiCallbackMessage from "./ApiCallbackMessage.ts"
|
import ApiCallbackMessage from "./ApiCallbackMessage.ts"
|
||||||
import EventCallbackFunction from "../types/EventCallbackFunction.ts"
|
import EventCallbackFunction from "../typedef/EventCallbackFunction.ts"
|
||||||
import BaseApi from "./BaseApi.ts"
|
import BaseApi from "./BaseApi.ts"
|
||||||
|
|
||||||
export default class ApiManager {
|
export default class ApiManager {
|
||||||
@@ -41,6 +41,12 @@ export default class ApiManager {
|
|||||||
return callback(this.event_listeners[name]?.(args))
|
return callback(this.event_listeners[name]?.(args))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
|
try {
|
||||||
|
callback({
|
||||||
|
code: 500,
|
||||||
|
msg: "錯誤: " + e
|
||||||
|
})
|
||||||
|
} catch(_e) {}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import EventCallbackFunction from "../types/EventCallbackFunction.ts"
|
import EventCallbackFunction from "../typedef/EventCallbackFunction.ts"
|
||||||
import ApiManager from "./ApiManager.ts"
|
import ApiManager from "./ApiManager.ts"
|
||||||
import { CallMethod } from './ApiDeclare.ts'
|
import { CallMethod } from './ApiDeclare.ts'
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ export default abstract class BaseApi {
|
|||||||
this.onInit()
|
this.onInit()
|
||||||
}
|
}
|
||||||
abstract onInit(): void
|
abstract onInit(): void
|
||||||
checkArgsMissing(args: {}, names: []) {
|
checkArgsMissing(args: { [key: string]: unknown }, names: []) {
|
||||||
for (const k of names)
|
for (const k of names)
|
||||||
if (!(k in args))
|
if (!(k in args))
|
||||||
return true
|
return true
|
||||||
|
|||||||
@@ -8,10 +8,7 @@ export default class UserApi extends BaseApi {
|
|||||||
this.registerEvent("User.auth", (args) => {
|
this.registerEvent("User.auth", (args) => {
|
||||||
return {
|
return {
|
||||||
msg: "",
|
msg: "",
|
||||||
code: 200,
|
code: 401,
|
||||||
data: {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import ApiManager from "./api/ApiManager.ts"
|
|||||||
// @ts-types="npm:@types/express"
|
// @ts-types="npm:@types/express"
|
||||||
import express from 'express'
|
import express from 'express'
|
||||||
import * as SocketIo from 'socket.io'
|
import * as SocketIo from 'socket.io'
|
||||||
import HttpServerLike from "./types/HttpServerLike.ts"
|
import HttpServerLike from "./typedef/HttpServerLike.ts"
|
||||||
import config from './config.ts'
|
import config from './config.ts'
|
||||||
import http from 'node:http'
|
import http from 'node:http'
|
||||||
import https from 'node:https'
|
import https from 'node:https'
|
||||||
|
|||||||
Reference in New Issue
Block a user