Projektstart

This commit is contained in:
2026-01-22 15:49:12 +01:00
parent 7212eb6f7a
commit 57e5f652f8
10637 changed files with 2598792 additions and 64 deletions

View File

@@ -0,0 +1,36 @@
'use strict'
const assert = require('node:assert')
function HostStorage () {
const hosts = {}
const regexHosts = []
return {
get: (host) => {
const exact = hosts[host]
if (exact) {
return exact
}
for (const regex of regexHosts) {
if (regex.host.test(host)) {
return regex.value
}
}
},
set: (host, value) => {
if (host instanceof RegExp) {
regexHosts.push({ host, value })
} else {
hosts[host] = value
}
}
}
}
module.exports = {
name: 'host',
mustMatchWhenDerived: false,
storage: HostStorage,
validate (value) {
assert(typeof value === 'string' || Object.prototype.toString.call(value) === '[object RegExp]', 'Host should be a string or a RegExp')
}
}

View File

@@ -0,0 +1,65 @@
'use strict'
const assert = require('node:assert')
function SemVerStore () {
if (!(this instanceof SemVerStore)) {
return new SemVerStore()
}
this.store = {}
this.maxMajor = 0
this.maxMinors = {}
this.maxPatches = {}
}
SemVerStore.prototype.set = function (version, store) {
if (typeof version !== 'string') {
throw new TypeError('Version should be a string')
}
let [major, minor, patch] = version.split('.')
if (isNaN(major)) {
throw new TypeError('Major version must be a numeric value')
}
major = Number(major)
minor = Number(minor) || 0
patch = Number(patch) || 0
if (major >= this.maxMajor) {
this.maxMajor = major
this.store.x = store
this.store['*'] = store
this.store['x.x'] = store
this.store['x.x.x'] = store
}
if (minor >= (this.maxMinors[major] || 0)) {
this.maxMinors[major] = minor
this.store[`${major}.x`] = store
this.store[`${major}.x.x`] = store
}
if (patch >= (this.maxPatches[`${major}.${minor}`] || 0)) {
this.maxPatches[`${major}.${minor}`] = patch
this.store[`${major}.${minor}.x`] = store
}
this.store[`${major}.${minor}.${patch}`] = store
return this
}
SemVerStore.prototype.get = function (version) {
return this.store[version]
}
module.exports = {
name: 'version',
mustMatchWhenDerived: true,
storage: SemVerStore,
validate (value) {
assert(typeof value === 'string', 'Version should be a string')
}
}

View File

@@ -0,0 +1,14 @@
'use strict'
module.exports = {
name: '__fmw_internal_strategy_merged_tree_http_method__',
storage: function () {
const handlers = {}
return {
get: (type) => { return handlers[type] || null },
set: (type, store) => { handlers[type] = store }
}
},
deriveConstraint: /* istanbul ignore next */ (req) => req.method,
mustMatchWhenDerived: true
}