@crowdin/app-project-module 0.17.8 → 0.17.9

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.
package/README.md CHANGED
@@ -74,9 +74,9 @@ const configuration = {
74
74
  dbFolder: __dirname,
75
75
  imagePath: __dirname + '/' + 'logo.png',
76
76
  crowdinUrls: { // custom urls to override
77
- // apiUrl: 'https://local.crowdin.dev/api/v2'
78
- // accountUrl: 'https://local.crowdin.dev/oauth/token' // (default https://accounts.crowdin.com/oauth/token)
79
- // subscriptionUrl: 'https://local.crowdin.dev' // (default https://crowdin.com or https://org.api.crowdin.com)
77
+ // apiUrl: 'https://<copy_name>.crowdin.dev/api/v2', // 'https://<org_name>.<copy_name>.crowdin.dev/api/v2' for enterprise
78
+ // accountUrl: 'https://accounts.<copy_name>.crowdin.dev/oauth/token', // (default https://accounts.crowdin.com/oauth/token)
79
+ // subscriptionUrl: 'https://<copy_name>.crowdin.dev' // (default https://crowdin.com or https://org.api.crowdin.com)
80
80
  },
81
81
  projectIntegration: {
82
82
  withRootFolder: true,
@@ -17,7 +17,7 @@ const fs_1 = __importDefault(require("fs"));
17
17
  const path_1 = __importDefault(require("path"));
18
18
  const models_1 = require("../../models");
19
19
  const util_1 = require("../../util");
20
- const MAX_BODY_SIZE = 5 * 1024 * 1024; //5mb
20
+ const MAX_BODY_SIZE = 4.9 * 1024 * 1024; //4.9mb
21
21
  function storeFile(fileContent, folder) {
22
22
  const fileName = `file${Date.now()}`;
23
23
  return new Promise((res, rej) => fs_1.default.writeFile(path_1.default.join(folder, 'custom-file-format', fileName), fileContent, err => {
@@ -70,9 +70,13 @@ function handleParseFile(baseUrl, dataFolder, config, req, client, context, proj
70
70
  return { response };
71
71
  }
72
72
  const res = yield config.parseFile(file, req, client, context, projectId);
73
+ let maxSize = MAX_BODY_SIZE;
74
+ if (res.strings && res.previewFile) {
75
+ maxSize = maxSize / 2;
76
+ }
73
77
  if (res.previewFile) {
74
78
  const previewFileEncoded = Buffer.from(res.previewFile).toString('base64');
75
- if (Buffer.byteLength(previewFileEncoded, 'utf8') < MAX_BODY_SIZE) {
79
+ if (Buffer.byteLength(previewFileEncoded, 'utf8') < maxSize) {
76
80
  response.preview = previewFileEncoded;
77
81
  }
78
82
  else {
@@ -92,7 +96,7 @@ function handleParseFile(baseUrl, dataFolder, config, req, client, context, proj
92
96
  });
93
97
  }
94
98
  const stringsJson = JSON.stringify(strings);
95
- if (Buffer.byteLength(stringsJson, 'utf8') < MAX_BODY_SIZE) {
99
+ if (Buffer.byteLength(stringsJson, 'utf8') < maxSize) {
96
100
  response.strings = strings;
97
101
  }
98
102
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.17.8",
3
+ "version": "0.17.9",
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",