1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-13 07:00:06 +00:00

feat(session-cleanup): delete a session after it has been used

This commit is contained in:
Krishna Acondy
2020-08-05 21:52:23 +01:00
parent f763f05b5e
commit 14daa55184
5 changed files with 118 additions and 76 deletions

View File

@@ -16,7 +16,21 @@ export class SessionManager {
async getSession(accessToken?: string) {
await this.createSessions(accessToken);
this.createAndWaitForSession(accessToken);
return this.sessions.pop();
const session = this.sessions.pop();
return session;
}
async clearSession(id: string, accessToken?: string) {
const deleteSessionRequest = {
method: "DELETE",
headers: this.getHeaders(accessToken),
};
return await this.request<Session>(
`${this.serverUrl}/compute/sessions/${id}`,
deleteSessionRequest
).then(() => {
this.sessions = this.sessions.filter((s) => s.id !== id);
});
}
private async createSessions(accessToken?: string) {