MCPcopy Create free account
hub / github.com/aetherstate/GODMOD3.AI / tierGate

Function tierGate

api/middleware/tierGate.ts:74–94  ·  view source on GitHub ↗
(gate: GateCheck)

Source from the content-addressed store, hash-verified

72 * Create middleware that enforces a tier gate.
73 */
74export function tierGate(gate: GateCheck) {
75 return (req: Request, res: Response, next: NextFunction): void => {
76 const tier: Tier = req.tier || 'free'
77 const config = getTierConfig(tier)
78
79 if (!passesGate(config, gate)) {
80 const required = minimumTierFor(gate)
81 res.status(403).json({
82 error: 'Upgrade required',
83 message: `This feature requires a ${required} plan or higher.`,
84 current_tier: tier,
85 required_tier: required,
86 feature: gate,
87 upgrade: 'Contact sales or set GODMODE_TIER_KEYS to upgrade your API key tier.',
88 })
89 return
90 }
91
92 next()
93 }
94}

Callers 1

metadata.tsFile · 0.90

Calls 3

getTierConfigFunction · 0.90
passesGateFunction · 0.85
minimumTierForFunction · 0.85

Tested by

no test coverage detected