mirror of
https://github.com/ragestudio/linebridge.git
synced 2025-06-09 10:34:17 +00:00
move to lib
This commit is contained in:
parent
4f3a57e9fa
commit
c639a51f8e
@ -1,9 +1,8 @@
|
||||
const axios = require("axios")
|
||||
const WSInterface = require("../classes/ClientWSInterface")
|
||||
const camalize = require("@corenode/utils/dist/camalize").default
|
||||
|
||||
const generateRequestDispatcher = require("./generateRequestDispatcher")
|
||||
const generateWSRequestDispatcher = require("./generateWSRequestDispatcher")
|
||||
const { WSInterface } = require("./classes")
|
||||
const { generateHTTPRequestDispatcher, generateWSRequestDispatcher } = require("./lib")
|
||||
|
||||
const FixedMethods = {
|
||||
"del": "delete"
|
||||
@ -127,7 +126,7 @@ module.exports = class Bridge {
|
||||
nameKey = "index"
|
||||
}
|
||||
|
||||
this.endpoints[fixedMethod][nameKey] = generateRequestDispatcher(
|
||||
this.endpoints[fixedMethod][nameKey] = generateHTTPRequestDispatcher(
|
||||
this.httpInterface,
|
||||
fixedMethod,
|
||||
route,
|
||||
|
@ -1,9 +1,7 @@
|
||||
const Controller = require("./controller")
|
||||
const Bridge = require("./bridge")
|
||||
const generateRequestDispatcher = require("./generateRequestDispatcher")
|
||||
|
||||
module.exports = {
|
||||
Bridge,
|
||||
Controller,
|
||||
generateRequestDispatcher,
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
module.exports = function generateRequestDispatcher(instance, method, route, handleRequestContext, handleResponse) {
|
||||
function generateHTTPRequestDispatcher(instance, method, route, handleRequestContext, handleResponse) {
|
||||
return function (body, query, options) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
let requestParams = {
|
||||
@ -48,3 +48,5 @@ module.exports = function generateRequestDispatcher(instance, method, route, han
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = generateHTTPRequestDispatcher
|
@ -1,4 +1,4 @@
|
||||
module.exports = function generateWSRequestDispatcher(instance, channel) {
|
||||
function generateWSRequestDispatcher(instance, channel) {
|
||||
return function (...payload) {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const req = instance.emit(channel, ...payload)
|
||||
@ -13,3 +13,5 @@ module.exports = function generateWSRequestDispatcher(instance, channel) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = generateWSRequestDispatcher
|
4
src/client/lib/index.js
Normal file
4
src/client/lib/index.js
Normal file
@ -0,0 +1,4 @@
|
||||
module.exports = {
|
||||
generateHTTPRequestDispatcher: require("./generateHTTPRequestDispatcher"),
|
||||
generateWSRequestDispatcher: require("./generateWSRequestDispatcher"),
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user