(target: TargetShape, path: string, identity: Identity, body: unknown)
| 68 | const cookieOf = (identity: Identity): string => identity.headers?.["cookie"] ?? ""; |
| 69 | |
| 70 | const postJson = (target: TargetShape, path: string, identity: Identity, body: unknown) => |
| 71 | Effect.promise(async () => { |
| 72 | const response = await fetch(new URL(path, target.baseUrl), { |
| 73 | method: "POST", |
| 74 | headers: { |
| 75 | "content-type": "application/json", |
| 76 | origin: new URL(target.baseUrl).origin, |
| 77 | cookie: cookieOf(identity), |
| 78 | }, |
| 79 | body: JSON.stringify(body), |
| 80 | }); |
| 81 | if (!response.ok) { |
| 82 | throw new Error(`${path} failed (${response.status}): ${await response.text()}`); |
| 83 | } |
| 84 | return response; |
| 85 | }); |
| 86 | |
| 87 | /** The identity re-bound to the refreshed session cookie a response set. */ |
| 88 | const withRefreshedSession = (identity: Identity, response: Response): Identity => { |
no test coverage detected