@dnax/core 0.12.6 → 0.12.8

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/app/hono.ts CHANGED
@@ -4,6 +4,7 @@ import { cleanDoubleSlashes } from "ufo";
4
4
  import sharp from "sharp";
5
5
  import path from "path";
6
6
  import mime from "mime-types";
7
+ import { setApiStudio } from "./studio";
7
8
  import { Hono } from "hono";
8
9
  import { getCookie, setCookie } from "hono/cookie";
9
10
  import colors from "@colors/colors/safe";
@@ -549,30 +550,6 @@ function HonoInstance(): typeof app {
549
550
  }
550
551
  });
551
552
 
552
- app.post("/api/studio", async (c, next) => {
553
- let cookie = getCookie(c);
554
- let body = await c?.req?.json();
555
- let secretKeyStudio = body?.secret || cookie["_STUDIO_SECRET_KEY_"];
556
- let canPerform = isStudio(secretKeyStudio);
557
- let cf = {
558
- collections: Cfg.collections?.map((c) =>
559
- pick(c, ["fields", "slug", "tenant_id", "type"])
560
- ),
561
- tenants: Cfg.tenants.map((t) => t?.id),
562
- };
563
-
564
- if (canPerform) {
565
- return c.json({
566
- auth: true,
567
- data: cf,
568
- token: jwt.sign({ studio: true }),
569
- });
570
- } else {
571
- c.status(403);
572
- return c.json({ message: "Unauthorized" });
573
- }
574
- });
575
-
576
553
  // serve static files
577
554
  app.get("/files/:folder/public/:filename", async (c, next) => {
578
555
  let { folder, filename } = c.req.param();
@@ -650,6 +627,8 @@ function HonoInstance(): typeof app {
650
627
  //}
651
628
  //});
652
629
 
630
+ setApiStudio(app);
631
+
653
632
  // Endpoint
654
633
  Cfg?.endpoints?.map((e) => {
655
634
  if (e?.enabled) {
package/app/studio.ts ADDED
@@ -0,0 +1,24 @@
1
+ import type { Context, Hono } from "hono";
2
+ import { Cfg } from "../config";
3
+ import { omit, pick } from "radash";
4
+ function setApiStudio(app: InstanceType<typeof Hono>) {
5
+ app.post("/api/studio/config", async (c) => {
6
+ let collections = Cfg.collections?.map((col) => {
7
+ return pick(col, [
8
+ "fields",
9
+ "slug",
10
+ "description",
11
+ "type",
12
+ "timestamps",
13
+ "tenant_id",
14
+ ]);
15
+ });
16
+ let config = {
17
+ collections: collections,
18
+ };
19
+
20
+ return c.json(config);
21
+ });
22
+ }
23
+
24
+ export { setApiStudio };
@@ -435,7 +435,7 @@ class useRest {
435
435
  });
436
436
  }
437
437
 
438
- return resolve(data);
438
+ return resolve(toJson(data));
439
439
  } catch (err) {
440
440
  reject(err);
441
441
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.12.6",
3
+ "version": "0.12.8",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "bin": {