document-extraction-service
Version:
A service for handling document extraction and processing
72 lines (59 loc) • 1.62 kB
JavaScript
class ExtractionConfig {
constructor(config) {
if (!config || typeof config !== 'object') {
throw new Error('Invalid configuration');
}
this.
this.
this.
this.
this.
}
const parsed = parseInt(days);
if (isNaN(parsed) || parsed < 1) {
return 2; // default value
}
return parsed;
}
const parsed = parseInt(retries);
if (isNaN(parsed) || parsed < 0) {
return 3; // default value
}
return parsed;
}
get endpoint() {
return this.
}
get headers() {
return { ...this.
}
get callback_url_pattern() {
return this.
}
get timeout_days() {
return this.
}
get max_retries() {
return this.
}
if (!config.endpoint) {
throw new Error('Endpoint is required');
}
if (!config.headers?.callback_url_pattern) {
throw new Error('Callback URL pattern is required');
}
if (!config.headers.callback_url_pattern.includes('{{docId}}') ||
!config.headers.callback_url_pattern.includes('{{streamId}}')) {
throw new Error('Invalid callback URL pattern format');
}
}
}
module.exports = ExtractionConfig;