@crowdin/app-project-module 0.98.0-cf-14 → 0.98.0-cf-16

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/out/index.js CHANGED
@@ -174,7 +174,7 @@ function addCrowdinEndpoints(app, clientConfig) {
174
174
  app.use(logsFormatter.contextResolverMiddleware());
175
175
  app.use(logsFormatter.expressMiddleware());
176
176
  }
177
- app.use('/assets', (0, static_files_1.serveStatic)(config, 'static'));
177
+ app.use('/assets', (0, static_files_1.serveStatic)(config, config.assetsPath || 'static'));
178
178
  app.get((0, util_1.getLogoUrl)(), (0, static_files_1.serveFile)(config, config.imagePath));
179
179
  app.get('/manifest.json', json_response_1.default, (0, manifest_1.default)(config));
180
180
  app.get('/', (0, about_1.default)(config));
package/out/types.d.ts CHANGED
@@ -286,6 +286,10 @@ export interface ClientConfig extends ImagePath {
286
286
  * custom file storage
287
287
  */
288
288
  fileStore?: FileStore;
289
+ /**
290
+ * path to assets files directory (default: 'static')
291
+ */
292
+ assetsPath?: string;
289
293
  }
290
294
  export interface AssetsConfig {
291
295
  /**
@@ -25,6 +25,9 @@ const path_1 = __importDefault(require("path"));
25
25
  function proxyAssetsResponse(fetcher, assetPath, baseUrl, req, res, next) {
26
26
  return __awaiter(this, void 0, void 0, function* () {
27
27
  try {
28
+ if (assetPath === '/') {
29
+ return next();
30
+ }
28
31
  const assetUrl = new URL(assetPath, baseUrl);
29
32
  const response = yield fetcher.fetch(assetUrl.toString());
30
33
  if (!response.ok) {
@@ -52,7 +55,7 @@ function serveStatic(config, staticPath) {
52
55
  if ((_a = config.assetsConfig) === null || _a === void 0 ? void 0 : _a.fetcher) {
53
56
  const assetsFetcher = config.assetsConfig.fetcher;
54
57
  return (req, res, next) => __awaiter(this, void 0, void 0, function* () {
55
- const assetPath = staticPath.startsWith('/') ? `${staticPath}${req.path}` : `/${staticPath}${req.path}`;
58
+ const assetPath = `/${staticPath}/${req.path}`.replace(/\/+/g, '/');
56
59
  yield proxyAssetsResponse(assetsFetcher, assetPath, config.baseUrl, req, res, next);
57
60
  });
58
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crowdin/app-project-module",
3
- "version": "0.98.0-cf-14",
3
+ "version": "0.98.0-cf-16",
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",