@crowdin/app-project-module 0.102.1 → 0.102.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -19,18 +19,18 @@ function handle(config) {
19
19
  (0, logger_1.log)('Received request for custom mt');
20
20
  (0, logger_1.log)(`Source language ${source}, target language ${target}`);
21
21
  (0, logger_1.log)(`Payload ${JSON.stringify(body, null, 2)}`);
22
- const projectId = Number(req.query.project_id);
22
+ const projectId = req.query.project_id ? Number(req.query.project_id) : null;
23
23
  try {
24
- if (source === 'en' && target === 'de' && body.strings && body.strings[0] === 'validation') {
24
+ const isValidationRequest = source === 'en' && target === 'de' && body.strings && body.strings[0] === 'validation';
25
+ if (isValidationRequest) {
25
26
  if (config.validate) {
26
27
  yield config.validate(req.crowdinApiClient);
27
28
  }
28
29
  res.send({ data: { translations: [] } });
30
+ return;
29
31
  }
30
- else {
31
- const translations = yield config.translate(req.crowdinApiClient, req.crowdinContext, projectId, source, target, body.strings);
32
- res.send({ data: { translations } });
33
- }
32
+ const translations = yield config.translate(req.crowdinApiClient, req.crowdinContext, projectId, source, target, body.strings);
33
+ res.send({ data: { translations } });
34
34
  }
35
35
  catch (e) {
36
36
  req.logError(e);
@@ -4,7 +4,7 @@ export interface CustomMTLogic extends ModuleKey {
4
4
  withContext?: boolean;
5
5
  batchSize?: number;
6
6
  maskEntities?: boolean;
7
- translate: (client: Crowdin, context: CrowdinContextInfo, projectId: number, source: string, target: string, strings: CustomMtString[]) => Promise<string[]>;
7
+ translate: (client: Crowdin, context: CrowdinContextInfo, projectId: number | null, source: string, target: string, strings: CustomMtString[]) => Promise<string[]>;
8
8
  validate?: (client: Crowdin) => Promise<void>;
9
9
  }
10
10
  export interface CustomMTRequest {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.102.1",
3
+ "version": "0.102.2",
4
4
  "description": "Module that generates for you all common endpoints for serving standalone Crowdin App",
5
5
  "main": "out/index.js",
6
6
  "types": "out/index.d.ts",