Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(config): define returned config obj types #1885

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/config/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,26 @@ function parseCorsParameter(param) {
return param;
}

/**
* @typedef {object} Config
* @property {string} tempDir - Directory for temporarily storing files during conversion.
* @property {import("fastify").FastifyListenOptions} fastify - Fastify server listen options.
* @property {import("fastify").FastifyServerOptions} fastifyInit - Fastify server initialisation options.
* @property {import("@fastify/cors").FastifyCorsOptions} cors - CORS configuration.
* @property {import("@fastify/under-pressure").UnderPressureOptions} processLoad - Process load handling configuration.
* @property {import("@fastify/rate-limit").FastifyRateLimitOptions} rateLimit - Rate limiting configuration.
* @property {import("@fastify/helmet").FastifyHelmetOptions} helmet - Helmet configuration.
* @property {import("@fastify/swagger").FastifyDynamicSwaggerOptions} swagger - Swagger configuration.
* @property {{ tempDir: string }} poppler - Poppler configuration.
* @property {{ enabled: boolean; languages: string; workers: number }} tesseract - Tesseract OCR configuration.
* @property {{ tempDir: string }} unrtf - UnRTF configuration.
* @property {Set<string>} [bearerTokenAuthKeys] - Bearer token auth keys.
*/

/**
* @author Frazer Smith
* @description Validates environment variables and builds server config.
* @returns {Promise<object>} A promise that resolves with a server config object, or rejects with an `Error` object
* @returns {Promise<Config>} A promise that resolves with a server config object, or rejects with an `Error` object
* if HTTPS is enabled and the required files are not found.
*/
async function getConfig() {
Expand Down
2 changes: 1 addition & 1 deletion src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const tidyHtml = require("./plugins/tidy-html");
* @author Frazer Smith
* @description Builds Fastify instance.
* @param {import("fastify").FastifyInstance} server - Fastify instance.
* @param {object} config - Fastify configuration values.
* @param {import("./config").Config} config - Server configuration.
*/
async function plugin(server, config) {
/**
Expand Down