ACCESS=accounts (config/access.ts; open stays the default and behaves as before): Newznab and the catalog's releases routes name a user (apikey or the web interface's token), whose tier sets searches and NZBs per UTC day (Newznab 500/501, the catalog 429) and how far back they see (102/403). Counted in one upsert per use, so the last one can't be taken twice; caps, stats and refused requests aren't counted. Signup takes an invite (SIGNUP), which may give a tier; ace access:invite, access:tier (extends a running tier), access:suspend. The web interface signs in and shows the day's usage and the Newznab key. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
1.3 KiB
TypeScript
32 lines
1.3 KiB
TypeScript
import env from '#start/env'
|
|
|
|
/**
|
|
* Who may use the catalog and the Newznab API.
|
|
*
|
|
* `open` (the default): as before, one key for Newznab (NEWZNAB_API_KEY, or
|
|
* none) and an open web catalog, no limits. `accounts`: every request names a
|
|
* user (a Newznab `apikey`, or the web interface's token), whose tier sets what
|
|
* they may do per UTC day and how far back they see.
|
|
*/
|
|
export const ACCESS = env.get('ACCESS', 'open')
|
|
|
|
/** Who may sign up: anyone, with an unused invite code, or no one. With accounts, invites unless set. */
|
|
export const SIGNUP = env.get('SIGNUP', ACCESS === 'accounts' ? 'invite' : 'open')
|
|
|
|
export interface TierLimits {
|
|
/** Searches and release details per day (Newznab t=search & co., the catalog); null: no limit. */
|
|
apiHits: number | null
|
|
/** NZBs per day; null: no limit. */
|
|
grabs: number | null
|
|
/** How many days back releases are found and fetched; null: everything. */
|
|
retentionDays: number | null
|
|
}
|
|
|
|
/** A tier that runs out (users.tier_until) falls back to `free`. */
|
|
export const TIERS: Record<string, TierLimits> = {
|
|
free: { apiHits: 100, grabs: 10, retentionDays: 365 },
|
|
vip: { apiHits: 10_000, grabs: 1_000, retentionDays: null },
|
|
// Staff and friends.
|
|
unlimited: { apiHits: null, grabs: null, retentionDays: null },
|
|
}
|