@candlerip/shared3 0.0.152 → 0.0.153
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +1 -1
- package/src/backend/database/connect-database/util.js +10 -7
- package/src/backend/database/mutation/candle/get-candles/type.d.ts +2 -2
- package/src/backend/dictionary/compose-dictionary/index.d.ts +2 -1
- package/src/backend/dictionary/compose-dictionary/index.js +3 -1
- package/src/backend/dictionary/compose-dictionary/type.d.ts +1 -3
- package/src/dictionary/index.d.ts +0 -1
- package/src/dictionary/index.js +0 -1
- package/src/backend/dictionary/compose-dictionary/util.d.ts +0 -2
- package/src/backend/dictionary/compose-dictionary/util.js +0 -10
- package/src/dictionary/get-excluded-translation-ids/index.d.ts +0 -2
- package/src/dictionary/get-excluded-translation-ids/index.js +0 -10
- package/src/dictionary/get-excluded-translation-ids/type.d.ts +0 -5
- package/src/dictionary/get-excluded-translation-ids/type.js +0 -1
package/package.json
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
import * as mongoose from 'mongoose';
|
2
2
|
export const connectDatabase = async (url) => {
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
const { readyState } = mongoose.connections[0];
|
4
|
+
if (readyState === 0 || readyState === 3) {
|
5
|
+
try {
|
6
|
+
await mongoose.connect(url);
|
7
|
+
mongoose.connection.on('error', () => {
|
8
|
+
setTimeout(connectDatabase, 5000);
|
9
|
+
});
|
10
|
+
}
|
11
|
+
catch {
|
6
12
|
setTimeout(connectDatabase, 5000);
|
7
|
-
}
|
8
|
-
}
|
9
|
-
catch {
|
10
|
-
setTimeout(connectDatabase, 5000);
|
13
|
+
}
|
11
14
|
}
|
12
15
|
};
|
@@ -14,8 +14,8 @@ export type GetCandles = <T extends keyof TypeMap = never>(props: {
|
|
14
14
|
customError: CustomError;
|
15
15
|
}>;
|
16
16
|
type TypeMap = {
|
17
|
-
|
18
|
-
|
17
|
+
candles: Candle[];
|
18
|
+
candlesWithPerson: Array<Candle & {
|
19
19
|
person?: Person;
|
20
20
|
}>;
|
21
21
|
};
|
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
import { ComposeDictionary } from './type.js';
|
2
|
+
export declare const composeDictionary: ComposeDictionary;
|
@@ -1 +1,3 @@
|
|
1
|
-
|
1
|
+
import { DICTIONARY_CONFIG } from '../../../dictionary/index.js';
|
2
|
+
import { getTranslationsAsDictionary } from '../../database/mutation/translation/index.js';
|
3
|
+
export const composeDictionary = async (page, language) => getTranslationsAsDictionary(language, [...DICTIONARY_CONFIG[page].translationIds]);
|
@@ -1,9 +1,7 @@
|
|
1
1
|
import { Dictionary, Language } from '../../../dictionary/index.js';
|
2
2
|
import { CustomError } from '../../../error/index.js';
|
3
3
|
import { Page } from '../../../page/index.js';
|
4
|
-
export type ComposeDictionary = (page: Page, language: Language
|
5
|
-
isAuthenticated: boolean;
|
6
|
-
}) => Promise<{
|
4
|
+
export type ComposeDictionary = (page: Page, language: Language) => Promise<{
|
7
5
|
data: Dictionary;
|
8
6
|
} | {
|
9
7
|
customError: CustomError;
|
package/src/dictionary/index.js
CHANGED
@@ -1,10 +0,0 @@
|
|
1
|
-
import { DICTIONARY_CONFIG } from '../../../dictionary/index.js';
|
2
|
-
import { getTranslationsAsDictionary } from '../../database/mutation/translation/index.js';
|
3
|
-
import { getExcludedTranslationIds } from '../../../dictionary/get-excluded-translation-ids/index.js';
|
4
|
-
export const composeDictionary = async (page, language, options) => {
|
5
|
-
let translationIds = [...DICTIONARY_CONFIG[page].translationIds];
|
6
|
-
const excludedIds = getExcludedTranslationIds(page, options);
|
7
|
-
translationIds = translationIds.filter((it) => !excludedIds.includes(it));
|
8
|
-
const resp = await getTranslationsAsDictionary(language, translationIds);
|
9
|
-
return resp;
|
10
|
-
};
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import { isUndefined } from '../../type/index.js';
|
2
|
-
export const getExcludedTranslationIds = (page, options) => {
|
3
|
-
const excludedIds = [`pageMenu.${page}`];
|
4
|
-
if (options) {
|
5
|
-
const { isAuthenticated } = options;
|
6
|
-
if (!isUndefined(isAuthenticated))
|
7
|
-
excludedIds.push(isAuthenticated ? 'login' : 'logout');
|
8
|
-
}
|
9
|
-
return excludedIds;
|
10
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|