-
Notifications
You must be signed in to change notification settings - Fork 310
Expand file tree
/
Copy pathtypes.ts
More file actions
47 lines (36 loc) · 1.61 KB
/
Copy pathtypes.ts
File metadata and controls
47 lines (36 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import type { Request } from "express";
// ─── Role ─────────────────────────────────────────────────────────────────────
export type Role = "admin" | "auditor" | "client" | "freelancer";
// ─── Resource & Action ───────────────────────────────────────────────────────
export type Resource =
| "users"
| "jobs"
| "proposals"
| "contracts"
| "payments"
| "reviews"
| "reports"
| "settings"
| "disputes"
| "health"
| "reputation"
| "override-requests";
export type Action = "create" | "read" | "update" | "delete" | "list" | "correct";
// ─── Permission (one row of the PERMISSION_MATRIX) ───────────────────────────
export interface Permission {
role: Role;
resource: Resource;
action: Action;
/** When true, the action is only allowed if the caller owns the record. */
ownOnly?: boolean;
}
// ─── User (attached to req.user by requireAuth) ──────────────────────────────
export interface User {
id: string;
email: string;
role: Role;
}
// ─── AuthenticatedRequest ────────────────────────────────────────────────────
export interface AuthenticatedRequest extends Request {
user?: User;
}