mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
framework: fix sse args parse
This commit is contained in:
2 files changed
+10
-5
No files matched your search
@@ -274,7 +274,7 @@ export class ConnectionHandler<C> extends HandlerCommon<C> {
|
||||
}
|
||||
|
||||
send(data: any) {
|
||||
let payload = JSON.stringify(data, serializer(false, this));
|
||||
let payload = typeof data === 'string' ? data : JSON.stringify(data, serializer(false, this));
|
||||
if (this.compression) {
|
||||
if (this.counter > 1000) this.resetCompression();
|
||||
payload = this.compression.deflate(payload);
|
||||
@@ -739,14 +739,19 @@ ${c.response.status} ${endTime - startTime}ms ${c.response.length}`);
|
||||
const savedContext = Object.hasOwn(this.ctx, Symbol.for('cordis.shadow'))
|
||||
? Object.getPrototypeOf(this.ctx)
|
||||
: this.ctx;
|
||||
const checker = Checker(permPrivChecker);
|
||||
if (type === 'route') {
|
||||
router.all(routeName, path, (ctx) => this.handleHttp(ctx as any, HandlerClass, Checker(permPrivChecker), savedContext));
|
||||
router.all(routeName, path, (ctx) => this.handleHttp(ctx as any, HandlerClass, checker, savedContext));
|
||||
} else {
|
||||
const checker = Checker(permPrivChecker);
|
||||
const layer = router.ws(path, async (conn, _req, ctx) => {
|
||||
await this.handleWS(ctx as any, HandlerClass, checker, conn, layer, savedContext);
|
||||
});
|
||||
if (this.config.enableSSE) router.get(path, (ctx) => this.handleWS(ctx as any, HandlerClass, checker, null, null, savedContext));
|
||||
if (this.config.enableSSE) {
|
||||
router.get(routeName, path, async (ctx) => {
|
||||
Object.assign(ctx.HydroContext.args, ctx.params);
|
||||
await this.handleWS(ctx as any, HandlerClass, checker, null, null, savedContext);
|
||||
});
|
||||
}
|
||||
}
|
||||
const dispose = router.disposeLastOp;
|
||||
// @ts-ignore
|
||||
|
||||
@@ -10,7 +10,7 @@ export const apply = (ctx: Context) => {
|
||||
const roots = [root];
|
||||
if (process.env.WATCH_ROOT) roots.push(process.env.WATCH_ROOT);
|
||||
const watcher = watch(roots, {
|
||||
ignored: (file) => [
|
||||
ignored: (file) => file.endsWith('.log') || [
|
||||
'node_modules', '.git', 'logs', '.cache', '.yarn', 'tsconfig.tsbuildinfo',
|
||||
].some((rule) => file.startsWith(`${rule}/`) || file.endsWith(`/${rule}`) || file.includes(`/${rule}/`)),
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user