mirror of
https://github.com/ragestudio/linebridge.git
synced 2025-06-09 10:34:17 +00:00
23 lines
645 B
JavaScript
Executable File
23 lines
645 B
JavaScript
Executable File
const loadEndpointsFromDir = require("../loadEndpointsFromDir")
|
|
|
|
function generateEndpointsFromDir(dir) {
|
|
const loadedEndpoints = loadEndpointsFromDir(dir)
|
|
|
|
// filter by methods
|
|
const endpointsByMethods = Object()
|
|
|
|
for (const endpointKey in loadedEndpoints) {
|
|
const endpoint = loadedEndpoints[endpointKey]
|
|
const method = endpoint.method.toLowerCase()
|
|
|
|
if (!endpointsByMethods[method]) {
|
|
endpointsByMethods[method] = {}
|
|
}
|
|
|
|
endpointsByMethods[method][endpoint.route] = loadedEndpoints[endpointKey]
|
|
}
|
|
|
|
return endpointsByMethods
|
|
}
|
|
|
|
module.exports = generateEndpointsFromDir |