Skip to content

Commit

Permalink
[WIP] feat(backend): OpenSearchに対応
Browse files Browse the repository at this point in the history
  • Loading branch information
Esurio committed May 7, 2024
1 parent 63981c7 commit b8b8eef
Show file tree
Hide file tree
Showing 7 changed files with 743 additions and 423 deletions.
124 changes: 57 additions & 67 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6962,16 +6962,6 @@ export interface Locale extends ILocale {
*/
"description": string;
};
"_setNameToYojo": {
/**
* ロリータコンプレックス
*/
"title": string;
/**
* これであなたもロリコン
*/
"description": string;
}
"_passedSinceAccountCreated1": {
/**
* 一周年
Expand Down Expand Up @@ -7338,10 +7328,10 @@ export interface Locale extends ILocale {
* ノート検索の利用
*/
"canSearchNotes": string;
/**
* 高度な検索
*/
"canAdvancedSearchNotes": string;
/**
* 高度な検索の利用
*/
"canAdvancedSearchNotes": string;
/**
* 翻訳機能の利用
*/
Expand Down Expand Up @@ -7892,7 +7882,7 @@ export interface Locale extends ILocale {
*/
"blockCode": string;
/**
* 複数行のプログラムなどのコードをブロックでシンタックスハイライトします。
* 複数行のプログラムなどのコードをブロックでシンタックスハイライトします。いくつかの言語を指定するとその言語に合わせたシンタックスハイライトになります。
*/
"blockCodeDescription": string;
/**
Expand Down Expand Up @@ -8119,14 +8109,14 @@ export interface Locale extends ILocale {
* 文字の上にルビを表示します。
*/
"rubyDescription": string;
/**
* ボーダー
*/
"border": string;
/**
* 内容を枠線で囲みます
*/
"borderDescription": string;
/**
* ボーダー
*/
"border": string;
/**
* 内容を枠線で囲むことができます
*/
"borderDescription": string;
};
"_instanceTicker": {
/**
Expand Down Expand Up @@ -11040,50 +11030,50 @@ export interface Locale extends ILocale {
*/
"noResizeCompressLossy": string;
};
"_advancedSearch": {
"_fileOption": {
/**
* ファイル付きのみ
*/
"fileAttachedOnly": string;
/**
* ファイルなし
*/
"noFile": string;
/**
* どっちも
*/
"combined": string;
};
"_searchOption": {
/**
* NSFWを除外する
*/
"toggleNsfw": string;
/**
* 返信を除外する
*/
"toggleReply": string;
/**
* 日時を指定する
*/
"toggleDate": string;
/**
* 高度な検索を有効にする
*/
"toggleAdvancedSearch": string;
};
"_specifyDate": {
/**
* から
*/
"startDate": string;
/**
* まで
*/
"endDate": string;
};
};
"_advancedSearch": {
"_fileOption": {
/**
* ファイル付きのみ
*/
"fileAttachedOnly": string;
/**
* ファイルなし
*/
"noFile": string;
/**
* どっちも
*/
"combined": string;
};
"_searchOption": {
/**
* NSFWを除外する
*/
"toggleNsfw": string;
/**
* リプライを除外する
*/
"toggleReply": string;
/**
* 日時を指定する
*/
"toggleDate": string;
/**
* 高度な検索を有効にする
*/
"toggleAdvancedSearch": string;
};
"_specifyDate": {
/**
* から
*/
"startDate": string;
/**
* まで
*/
"endDate": string;
};
};
}
declare const locales: {
[lang: string]: Locale;
Expand Down
1 change: 1 addition & 0 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"@nestjs/common": "10.2.10",
"@nestjs/core": "10.2.10",
"@nestjs/testing": "10.2.10",
"@opensearch-project/opensearch": "^2.7.0",
"@peertube/http-signature": "1.7.0",
"@simplewebauthn/server": "9.0.2",
"@sinonjs/fake-timers": "11.2.2",
Expand Down
24 changes: 24 additions & 0 deletions packages/backend/src/GlobalModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Global, Inject, Module } from '@nestjs/common';
import * as Redis from 'ioredis';
import { DataSource } from 'typeorm';
import { MeiliSearch } from 'meilisearch';
import { Client as OpenSearch } from '@opensearch-project/opensearch';
import { Logging } from '@google-cloud/logging';
import { DI } from './di-symbols.js';
import { Config, loadConfig } from './config.js';
Expand Down Expand Up @@ -45,6 +46,29 @@ const $meilisearch: Provider = {
inject: [DI.config],
};

const $opensearch: Provider = {
provide: DI.opensearch,
useFactory: (config: Config) => {
if (config.opensearch) {
return new OpenSearch({
nodes: {
url: new URL(`${config.opensearch.ssl ? 'https' : 'http'}://${config.opensearch.host}:${config.opensearch.port}`),
ssl: {
rejectUnauthorized: config.opensearch.rejectUnauthorized,
},
},
auth: {
username: config.opensearch.user,
password: config.opensearch.pass,
},
});
} else {
return null;
}
},
inject: [DI.config],
};

const $cloudLogging: Provider = {
provide: DI.cloudLogging,
useFactory: (config: Config) => {
Expand Down
22 changes: 22 additions & 0 deletions packages/backend/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ type Source = {
user: string;
pass: string;
}[];
pgroonga?: boolean;
redis: RedisOptionsSource;
redisForPubsub?: RedisOptionsSource;
redisForJobQueue?: RedisOptionsSource;
Expand All @@ -56,6 +57,15 @@ type Source = {
index: string;
scope?: 'local' | 'global' | string[];
};
opensearch?: {
host: string;
port: string;
user: string;
pass: string;
ssl?: boolean;
rejectUnauthorized?: boolean;
index: string;
} | undefined;

publishTarballInsteadOfProvideRepositoryUrl?: boolean;

Expand Down Expand Up @@ -126,6 +136,7 @@ export type Config = {
user: string;
pass: string;
}[] | undefined;
pgroonga: boolean | undefined;
meilisearch: {
host: string;
port: string;
Expand All @@ -134,6 +145,15 @@ export type Config = {
index: string;
scope?: 'local' | 'global' | string[];
} | undefined;
opensearch: {
host: string;
port: string;
user: string;
pass: string;
ssl?: boolean;
rejectUnauthorized?: boolean;
index: string;
} | undefined;
proxy: string | undefined;
proxySmtp: string | undefined;
proxyBypassHosts: string[] | undefined;
Expand Down Expand Up @@ -248,7 +268,9 @@ export function loadConfig(): Config {
db: config.db,
dbReplications: config.dbReplications,
dbSlaves: config.dbSlaves,
pgroonga: config.pgroonga,
meilisearch: config.meilisearch,
opensearch: config.opensearch,
redis,
redisForPubsub: config.redisForPubsub ? convertRedisOptions(config.redisForPubsub, host) : redis,
redisForJobQueue: config.redisForJobQueue ? convertRedisOptions(config.redisForJobQueue, host) : redis,
Expand Down
Loading

0 comments on commit b8b8eef

Please sign in to comment.