Files
photofetch/backend/src/config.ts
Julien Calixte 9ded10f68e feat(napta): client-credentials auth + real project listing
Napta uses Auth0 M2M, not a static token: exchange client_id/secret for a cached
JWT, then list non-archived projects via JSON:API (include client name). Falls back
to fixtures when NAPTA_CLIENT_ID/SECRET are unset. Member resolution still stubbed.
2026-06-26 16:16:06 +01:00

30 lines
1.2 KiB
TypeScript

export interface Config {
port: number
// Napta uses Auth0 Machine-to-Machine (client-credentials), not a static token:
// client_id + client_secret are exchanged for a short-lived JWT (see napta.ts).
naptaClientId: string | null
naptaClientSecret: string | null
naptaBaseUrl: string
naptaAuthUrl: string
naptaAudience: string
slackBotToken: string | null
}
export const config: Config = {
port: Number(process.env.PORT ?? 8000),
naptaClientId: process.env.NAPTA_CLIENT_ID || null,
naptaClientSecret: process.env.NAPTA_CLIENT_SECRET || null,
naptaBaseUrl: process.env.NAPTA_BASE_URL || "https://app.napta.io/api/v1",
naptaAuthUrl: process.env.NAPTA_AUTH_URL || "https://auth.napta.io/oauth/token",
naptaAudience: process.env.NAPTA_AUDIENCE || "backend",
slackBotToken: process.env.SLACK_BOT_TOKEN || null,
}
// Listing Projects and Members needs Napta. Without it, the API serves fixtures.
export const hasNaptaCredentials: boolean = Boolean(
config.naptaClientId && config.naptaClientSecret,
)
// Slack only resolves Avatars; it's optional and degrades to initials when absent.
export const hasSlackCredentials: boolean = Boolean(config.slackBotToken)