'use strict'
const Node = require('./node')
const compose = require('./compose')
const methods = require('./methods')
const defaultFilter = require('./middleware/defaultFilter')
const METHOD_NAME_OF_ALL = 'ALL'
const match = url.match(/^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/)
return match[5]
}
const proxyHandler = {
get:
(target, prop) =>
(...args) => {
if (target.constructor.prototype.hasOwnProperty(prop)) {
return target[prop](...args)
} else {
return target.addRoute(prop, ...args)
}
},
}
class Hono {
constructor() {
this.router = new Router()
this.middlewareRouters = []
for (const method of methods) {
this[method] = (...args) => {
return this.addRoute(method, ...args)
}
}
}
all(...args) {
this.addRoute('ALL', ...args)
}
getRouter() {
return this.router
}
this.router.add(method, this.router.tempPath, ...args)
} else {
this.router.add(method, ...args)
}
return WrappedApp(this)
return this
}
route(path) {
this.router.tempPath = path
return WrappedApp(this)
return this
}
use(path, middleware) {
const router = new Router()
return new Response('Not Found', { status: 404 })
}
}
const WrappedApp = (hono = new Hono()) => {
return new Proxy(hono, proxyHandler)
module.exports = () => {
return new Hono()
}
module.exports = WrappedApp