mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 12:37:20 +00:00
added bulk updates to data controller
This commit is contained in:
@@ -1,7 +1,21 @@
|
||||
import { Hono } from "hono";
|
||||
import type { ServerEnv } from "modules/Module";
|
||||
import type { App } from "App";
|
||||
import { type Context, Hono } from "hono";
|
||||
import * as middlewares from "modules/middlewares";
|
||||
|
||||
export type ServerEnv = {
|
||||
Variables: {
|
||||
app: App;
|
||||
// to prevent resolving auth multiple times
|
||||
auth?: {
|
||||
resolved: boolean;
|
||||
registered: boolean;
|
||||
skip: boolean;
|
||||
user?: { id: any; role?: string; [key: string]: any };
|
||||
};
|
||||
html?: string;
|
||||
};
|
||||
};
|
||||
|
||||
export class Controller {
|
||||
protected middlewares = middlewares;
|
||||
|
||||
@@ -16,4 +30,19 @@ export class Controller {
|
||||
getController(): Hono<ServerEnv> {
|
||||
return this.create();
|
||||
}
|
||||
|
||||
protected isJsonRequest(c: Context<ServerEnv>) {
|
||||
return (
|
||||
c.req.header("Content-Type") === "application/json" ||
|
||||
c.req.header("Accept") === "application/json"
|
||||
);
|
||||
}
|
||||
|
||||
protected notFound(c: Context<ServerEnv>) {
|
||||
if (this.isJsonRequest(c)) {
|
||||
return c.json({ error: "Not found" }, 404);
|
||||
}
|
||||
|
||||
return c.notFound();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import type { App } from "App";
|
||||
import type { Guard } from "auth";
|
||||
import { type DebugLogger, SchemaObject } from "core";
|
||||
import type { EventManager } from "core/events";
|
||||
@@ -15,20 +14,7 @@ import {
|
||||
import { Entity } from "data";
|
||||
import type { Hono } from "hono";
|
||||
import { isEqual } from "lodash-es";
|
||||
|
||||
export type ServerEnv = {
|
||||
Variables: {
|
||||
app: App;
|
||||
// to prevent resolving auth multiple times
|
||||
auth?: {
|
||||
resolved: boolean;
|
||||
registered: boolean;
|
||||
skip: boolean;
|
||||
user?: { id: any; role?: string; [key: string]: any };
|
||||
};
|
||||
html?: string;
|
||||
};
|
||||
};
|
||||
import type { ServerEnv } from "modules/Controller";
|
||||
|
||||
export type ModuleBuildContext = {
|
||||
connection: Connection;
|
||||
|
||||
@@ -32,7 +32,8 @@ import { AppAuth } from "../auth/AppAuth";
|
||||
import { AppData } from "../data/AppData";
|
||||
import { AppFlows } from "../flows/AppFlows";
|
||||
import { AppMedia } from "../media/AppMedia";
|
||||
import { Module, type ModuleBuildContext, type ServerEnv } from "./Module";
|
||||
import type { ServerEnv } from "./Controller";
|
||||
import { Module, type ModuleBuildContext } from "./Module";
|
||||
|
||||
export type { ModuleBuildContext };
|
||||
|
||||
|
||||
1
app/src/modules/middlewares/index.ts
Normal file
1
app/src/modules/middlewares/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { auth, permission } from "auth/middlewares";
|
||||
Reference in New Issue
Block a user