Implement API key authentication by introducing a new auth module. Update configuration and .env.example to support API key setup, and add authorization checks in the server endpoints.
32 lines
847 B
TypeScript
32 lines
847 B
TypeScript
/**
|
|
* @fileoverview This file manages the application's configuration,
|
|
* loading environment variables and providing them in a structured object.
|
|
*/
|
|
/* eslint-disable n/no-process-env */
|
|
import dotenv from 'dotenv';
|
|
|
|
dotenv.config();
|
|
|
|
/**
|
|
* Application configuration object.
|
|
*/
|
|
export const config = {
|
|
/**
|
|
* The port number for the server to listen on.
|
|
* Defaults to 11434 if not specified in the environment.
|
|
* @type {number}
|
|
*/
|
|
PORT: Number(process.env.PORT ?? 11434),
|
|
/**
|
|
* A flag to enable or disable verbose logging.
|
|
* Defaults to true if not specified in the environment.
|
|
* @type {boolean}
|
|
*/
|
|
VERBOSE: Boolean(process.env.VERBOSE ?? true),
|
|
/**
|
|
* The API key for securing the server.
|
|
* If not set, the server will be public.
|
|
* @type {string | undefined}
|
|
*/
|
|
API_KEY: process.env.API_KEY,
|
|
}; |