mirror of
https://github.com/docmost/docmost.git
synced 2026-06-11 02:36:56 +08:00
feat: Typesense search driver (EE) (#1664)
* feat: typesense driver (EE) - WIP * feat: typesense driver (EE) - WIP * feat: typesense * sync * fix
This commit is contained in:
@@ -213,4 +213,24 @@ export class EnvironmentService {
|
||||
getPostHogKey(): string {
|
||||
return this.configService.get<string>('POSTHOG_KEY');
|
||||
}
|
||||
|
||||
getSearchDriver(): string {
|
||||
return this.configService
|
||||
.get<string>('SEARCH_DRIVER', 'database')
|
||||
.toLowerCase();
|
||||
}
|
||||
|
||||
getTypesenseUrl(): string {
|
||||
return this.configService
|
||||
.get<string>('TYPESENSE_URL', 'http://localhost:8108')
|
||||
.toLowerCase();
|
||||
}
|
||||
|
||||
getTypesenseApiKey(): string {
|
||||
return this.configService.get<string>('TYPESENSE_API_KEY');
|
||||
}
|
||||
|
||||
getTypesenseLocale(): string {
|
||||
return this.configService.get<string>('TYPESENSE_LOCALE', 'en').toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,14 @@ import {
|
||||
IsNotEmpty,
|
||||
IsNotIn,
|
||||
IsOptional,
|
||||
IsString,
|
||||
IsUrl,
|
||||
MinLength,
|
||||
ValidateIf,
|
||||
validateSync,
|
||||
} from 'class-validator';
|
||||
import { plainToInstance } from 'class-transformer';
|
||||
import { IsISO6391 } from '../../common/validator/is-iso6391';
|
||||
|
||||
export class EnvironmentVariables {
|
||||
@IsNotEmpty()
|
||||
@@ -68,6 +70,37 @@ export class EnvironmentVariables {
|
||||
)
|
||||
@ValidateIf((obj) => obj.CLOUD === 'true'.toLowerCase())
|
||||
SUBDOMAIN_HOST: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsIn(['database', 'typesense'])
|
||||
@IsString()
|
||||
SEARCH_DRIVER: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsUrl(
|
||||
{
|
||||
protocols: ['http', 'https'],
|
||||
require_tld: false,
|
||||
allow_underscores: true,
|
||||
},
|
||||
{
|
||||
message:
|
||||
'TYPESENSE_URL must be a valid typesense url e.g http://localhost:8108',
|
||||
},
|
||||
)
|
||||
@ValidateIf((obj) => obj.SEARCH_DRIVER === 'typesense')
|
||||
TYPESENSE_URL: string;
|
||||
|
||||
@IsOptional()
|
||||
@ValidateIf((obj) => obj.SEARCH_DRIVER === 'typesense')
|
||||
@IsString()
|
||||
TYPESENSE_API_KEY: string;
|
||||
|
||||
@IsOptional()
|
||||
@ValidateIf((obj) => obj.SEARCH_DRIVER === 'typesense')
|
||||
@IsISO6391()
|
||||
@IsString()
|
||||
TYPESENSE_LOCALE: string;
|
||||
}
|
||||
|
||||
export function validate(config: Record<string, any>) {
|
||||
|
||||
Reference in New Issue
Block a user