mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
added aws lambda adapter + improvements to handle concurrency
This commit is contained in:
@@ -164,13 +164,23 @@ export class AdminController extends Controller {
|
||||
};
|
||||
|
||||
if (isProd) {
|
||||
// @ts-ignore
|
||||
const manifest = await import("bknd/dist/manifest.json", {
|
||||
assert: { type: "json" },
|
||||
});
|
||||
let manifest: any;
|
||||
if (this.options.assets_path.startsWith("http")) {
|
||||
manifest = await fetch(this.options.assets_path + "manifest.json", {
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
},
|
||||
}).then((res) => res.json());
|
||||
} else {
|
||||
// @ts-ignore
|
||||
manifest = await import("bknd/dist/manifest.json", {
|
||||
assert: { type: "json" },
|
||||
}).then((res) => res.default);
|
||||
}
|
||||
|
||||
// @todo: load all marked as entry (incl. css)
|
||||
assets.js = manifest.default["src/ui/main.tsx"].file;
|
||||
assets.css = manifest.default["src/ui/main.tsx"].css[0] as any;
|
||||
assets.js = manifest["src/ui/main.tsx"].file;
|
||||
assets.css = manifest["src/ui/main.tsx"].css[0] as any;
|
||||
}
|
||||
|
||||
const theme = configs.server.admin.color_scheme ?? "light";
|
||||
@@ -197,16 +207,8 @@ export class AdminController extends Controller {
|
||||
)}
|
||||
{isProd ? (
|
||||
<Fragment>
|
||||
<script
|
||||
type="module"
|
||||
CrossOrigin
|
||||
src={this.options.assets_path + assets?.js}
|
||||
/>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
crossOrigin
|
||||
href={this.options.assets_path + assets?.css}
|
||||
/>
|
||||
<script type="module" src={this.options.assets_path + assets?.js} />
|
||||
<link rel="stylesheet" href={this.options.assets_path + assets?.css} />
|
||||
</Fragment>
|
||||
) : (
|
||||
<Fragment>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/// <reference types="@cloudflare/workers-types" />
|
||||
|
||||
import type { App } from "App";
|
||||
import { tbValidator as tb } from "core";
|
||||
import { $console, tbValidator as tb } from "core";
|
||||
import {
|
||||
StringEnum,
|
||||
Type,
|
||||
@@ -229,17 +229,23 @@ export class SystemController extends Controller {
|
||||
Type.Object({
|
||||
config: Type.Optional(booleanLike),
|
||||
secrets: Type.Optional(booleanLike),
|
||||
fresh: Type.Optional(booleanLike),
|
||||
}),
|
||||
),
|
||||
async (c) => {
|
||||
const module = c.req.param("module") as ModuleKey | undefined;
|
||||
const { config, secrets } = c.req.valid("query");
|
||||
const { config, secrets, fresh } = c.req.valid("query");
|
||||
|
||||
config && this.ctx.guard.throwUnlessGranted(SystemPermissions.configRead, c);
|
||||
secrets && this.ctx.guard.throwUnlessGranted(SystemPermissions.configReadSecrets, c);
|
||||
|
||||
const { version, ...schema } = this.app.getSchema();
|
||||
|
||||
if (fresh) {
|
||||
// in cases of concurrency, refetching schema/config must be always fresh
|
||||
await this.app.build({ fetch: true });
|
||||
}
|
||||
|
||||
if (module) {
|
||||
return c.json({
|
||||
module,
|
||||
@@ -265,14 +271,18 @@ export class SystemController extends Controller {
|
||||
"query",
|
||||
Type.Object({
|
||||
sync: Type.Optional(booleanLike),
|
||||
fetch: Type.Optional(booleanLike),
|
||||
}),
|
||||
),
|
||||
async (c) => {
|
||||
const { sync } = c.req.valid("query") as Record<string, boolean>;
|
||||
const options = c.req.valid("query") as Record<string, boolean>;
|
||||
this.ctx.guard.throwUnlessGranted(SystemPermissions.build, c);
|
||||
|
||||
await this.app.build({ sync });
|
||||
return c.json({ success: true, options: { sync } });
|
||||
await this.app.build(options);
|
||||
return c.json({
|
||||
success: true,
|
||||
options,
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user