(r: RunningServer)
| 116 | } |
| 117 | |
| 118 | async function createSession(r: RunningServer): Promise<string> { |
| 119 | const res = await appOf(r).inject({ |
| 120 | method: 'POST', |
| 121 | url: '/api/v1/sessions', |
| 122 | payload: { metadata: { cwd: workspace } }, |
| 123 | }); |
| 124 | const env = res.json() as { code: number; data: { id: string } | null }; |
| 125 | if (env.code !== 0 || env.data === null) { |
| 126 | throw new Error(`create session failed: ${JSON.stringify(env)}`); |
| 127 | } |
| 128 | return env.data.id; |
| 129 | } |
| 130 | |
| 131 | function wsUrl(http: string): string { |
| 132 | return http.replace(/^http:\/\//, 'ws://') + '/api/v1/ws'; |
no test coverage detected