handle fixedMethod

This commit is contained in:
srgooglo 2022-02-21 11:14:27 +01:00
parent b3ad2efc8f
commit e7c0693100
2 changed files with 6 additions and 2 deletions

View File

@ -29,13 +29,14 @@ export default class ComplexController {
global.VALID_HTTP_METHODS.forEach((httpMethod) => {
if (typeof this[httpMethod] === "object") {
const fixedMethod = global.FIXED_HTTP_METHODS[httpMethod]
const controllerMethods = Object.keys(this[httpMethod])
controllerMethods.forEach((methodKey) => {
const fn = this[httpMethod][methodKey]
let endpoint = {
method: httpMethod,
method: fixedMethod,
route: methodKey,
middlewares: [],
fn: fn,

View File

@ -14,7 +14,10 @@ const { randomWord } = require("@corenode/utils")
const { serverManifest } = require("../lib")
global.LOCALHOST_ADDRESS = net.ip.getHostAddress() ?? "localhost"
global.VALID_HTTP_METHODS = ["get", "post", "put", "patch", "del", "trace", "head", "any", "options", "ws"]
global.FIXED_HTTP_METHODS = {
"delete": "del",
}
global.VALID_HTTP_METHODS = ["get", "post", "put", "patch", "del", "delete", "trace", "head", "any", "options", "ws"]
global.DEFAULT_HEADERS = {
"Access-Control-Allow-Headers": "Origin, X-Requested-With, Content-Type, Accept, Authorization",
"Access-Control-Allow-Origin": "*",