Skip to content

Commit 2e71143

Browse files
committed
refactor: replace postNoBody with a more explicit postReturn<null, R>
1 parent 84aac0d commit 2e71143

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/connection/http.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,10 +120,6 @@ export default class ConnectionREST {
120120
return this.http.post<B, T>(path, payload, true, '') as Promise<T>;
121121
};
122122

123-
postNoBody = <T>(path: string): Promise<T> => {
124-
return this.postReturn<null, T>(path, null);
125-
};
126-
127123
postEmpty = <B>(path: string, payload: B): Promise<void> => {
128124
if (this.authEnabled) {
129125
return this.login().then((token) => this.http.post<B, void>(path, payload, false, token));

src/users/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,16 @@ const db = (connection: ConnectionREST): DBUsers => {
119119
ns.revokeRoles(roleNames, userId, { userType: 'db' }),
120120

121121
create: (userId: string) =>
122-
connection.postNoBody<APIKeyResponse>(`/users/db/${userId}`).then((resp) => resp.apikey),
122+
connection.postReturn<null, APIKeyResponse>(`/users/db/${userId}`, null).then((resp) => resp.apikey),
123123
delete: (userId: string) =>
124124
connection
125125
.delete(`/users/db/${userId}`, null)
126126
.then(() => true)
127127
.catch(() => false),
128128
rotateKey: (userId: string) =>
129-
connection.postNoBody<APIKeyResponse>(`/users/db/${userId}/rotate-key`).then((resp) => resp.apikey),
129+
connection
130+
.postReturn<null, APIKeyResponse>(`/users/db/${userId}/rotate-key`, null)
131+
.then((resp) => resp.apikey),
130132
activate: (userId: string) =>
131133
connection
132134
.postEmpty<null>(`/users/db/${userId}/activate`, null)

0 commit comments

Comments
 (0)