@meridianjs/meridian 0.1.6 → 0.1.7
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.
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import type { Response } from "express";
|
|
2
2
|
/**
|
|
3
|
-
* GET /admin/events?token=<jwt>
|
|
3
|
+
* GET /admin/events?token=<jwt>&workspaceId=<id>
|
|
4
4
|
*
|
|
5
|
-
* SSE stream scoped to the
|
|
6
|
-
* Uses
|
|
7
|
-
*
|
|
5
|
+
* SSE stream scoped to the given workspace.
|
|
6
|
+
* Uses query params because EventSource cannot set custom headers.
|
|
7
|
+
* - token: validated by authenticateJWT middleware (sets req.user)
|
|
8
|
+
* - workspaceId: passed explicitly because the JWT always has workspaceId=null
|
|
9
|
+
* (tokens are issued at auth time, not workspace-selection time)
|
|
10
|
+
*
|
|
11
|
+
* Validates that req.user is a member of the requested workspace before subscribing.
|
|
8
12
|
*/
|
|
9
|
-
export declare const GET: (req: any, res: Response) => void
|
|
13
|
+
export declare const GET: (req: any, res: Response) => Promise<void>;
|
|
10
14
|
//# sourceMappingURL=route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/api/admin/events/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAGvC
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/api/admin/events/route.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAGvC;;;;;;;;;;GAUG;AACH,eAAO,MAAM,GAAG,GAAU,KAAK,GAAG,EAAE,KAAK,QAAQ,kBAsChD,CAAA"}
|
|
@@ -1,15 +1,26 @@
|
|
|
1
1
|
import { sseManager } from "@meridianjs/framework";
|
|
2
2
|
/**
|
|
3
|
-
* GET /admin/events?token=<jwt>
|
|
3
|
+
* GET /admin/events?token=<jwt>&workspaceId=<id>
|
|
4
4
|
*
|
|
5
|
-
* SSE stream scoped to the
|
|
6
|
-
* Uses
|
|
7
|
-
*
|
|
5
|
+
* SSE stream scoped to the given workspace.
|
|
6
|
+
* Uses query params because EventSource cannot set custom headers.
|
|
7
|
+
* - token: validated by authenticateJWT middleware (sets req.user)
|
|
8
|
+
* - workspaceId: passed explicitly because the JWT always has workspaceId=null
|
|
9
|
+
* (tokens are issued at auth time, not workspace-selection time)
|
|
10
|
+
*
|
|
11
|
+
* Validates that req.user is a member of the requested workspace before subscribing.
|
|
8
12
|
*/
|
|
9
|
-
export const GET = (req, res) => {
|
|
10
|
-
const workspaceId = req.
|
|
13
|
+
export const GET = async (req, res) => {
|
|
14
|
+
const workspaceId = req.query.workspaceId;
|
|
11
15
|
if (!workspaceId) {
|
|
12
|
-
res.status(400).json({ error: { message: "
|
|
16
|
+
res.status(400).json({ error: { message: "workspaceId query param required" } });
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
// Validate the user actually belongs to this workspace
|
|
20
|
+
const workspaceMemberService = req.scope.resolve("workspaceMemberModuleService");
|
|
21
|
+
const [members] = await workspaceMemberService.listAndCountWorkspaceMembers({ workspace_id: workspaceId, user_id: req.user.id }, { limit: 1 });
|
|
22
|
+
if (members.length === 0) {
|
|
23
|
+
res.status(403).json({ error: { message: "You are not a member of this workspace" } });
|
|
13
24
|
return;
|
|
14
25
|
}
|
|
15
26
|
res.setHeader("Content-Type", "text/event-stream");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../src/api/admin/events/route.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAElD
|
|
1
|
+
{"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../src/api/admin/events/route.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CA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