@isardsat/editorial-server 6.6.3 → 6.7.0

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.
@@ -17,7 +17,9 @@ function createCache() {
17
17
  return schema;
18
18
  },
19
19
  async getContent(storage, options = {}) {
20
- const cacheKey = options.production ? "production" : "preview";
20
+ const mode = options.production ? "production" : "preview";
21
+ const langSuffix = options.lang ? `-${options.lang}` : "";
22
+ const cacheKey = `${mode}${langSuffix}`;
21
23
  const cachedEntry = contentCache.get(cacheKey);
22
24
  if (cachedEntry && !isExpired(cachedEntry)) {
23
25
  return cachedEntry.data;
@@ -123,9 +125,15 @@ export function createDataRoutes(config, storage) {
123
125
  const { itemType } = c.req.valid("param");
124
126
  const { lang, preview } = c.req.valid("query");
125
127
  const origin = preview ? new URL(c.req.url).origin : publicFilesUrl;
126
- const content = await cache.getContent(storage, { production: !preview });
128
+ const content = await cache.getContent(storage, {
129
+ production: !preview,
130
+ lang,
131
+ });
127
132
  const schema = await cache.getSchema(storage);
128
133
  const collection = content[itemType];
134
+ if (!collection && schema[itemType]) {
135
+ return c.json({});
136
+ }
129
137
  if (!collection) {
130
138
  return c.notFound();
131
139
  }
@@ -173,11 +181,17 @@ export function createDataRoutes(config, storage) {
173
181
  },
174
182
  description: "Get object ids by type",
175
183
  },
184
+ 404: {
185
+ description: "Item not found",
186
+ },
176
187
  },
177
188
  }), async (c) => {
178
189
  const { itemType } = c.req.valid("param");
179
190
  const { preview } = c.req.valid("query");
180
191
  const content = await cache.getContent(storage, { production: !preview });
192
+ if (!content[itemType]) {
193
+ return c.notFound();
194
+ }
181
195
  return c.json(Object.keys(content[itemType]));
182
196
  });
183
197
  app.openapi(createRoute({
@@ -222,7 +236,10 @@ export function createDataRoutes(config, storage) {
222
236
  const { itemType, id } = c.req.valid("param");
223
237
  const { lang, preview } = c.req.valid("query");
224
238
  const origin = preview ? new URL(c.req.url).origin : publicFilesUrl;
225
- const content = await cache.getContent(storage, { production: !preview });
239
+ const content = await cache.getContent(storage, {
240
+ production: !preview,
241
+ lang,
242
+ });
226
243
  const schema = await cache.getSchema(storage);
227
244
  const collection = content[itemType];
228
245
  if (!collection) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isardsat/editorial-server",
3
- "version": "6.6.3",
3
+ "version": "6.7.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -14,8 +14,8 @@
14
14
  "hono": "^4.6.20",
15
15
  "yaml": "^2.7.0",
16
16
  "zod": "^3.24.1",
17
- "@isardsat/editorial-common": "^6.6.3",
18
- "@isardsat/editorial-admin": "^6.6.3"
17
+ "@isardsat/editorial-admin": "^6.7.0",
18
+ "@isardsat/editorial-common": "^6.7.0"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@tsconfig/node22": "^22.0.0",