[1/n]: Migrate deleteOne Rest API to use TwentyORM directly (#9784)
# This PR - Addressing #3644 - Migrates the `DELETE /rest/*` endpoint to use TwentyORM - Factorizes common middleware logic into a common module --------- Co-authored-by: martmull <martmull@hotmail.fr>
This commit is contained in:
@ -0,0 +1,18 @@
|
||||
import { IncomingHttpHeaders } from 'http';
|
||||
|
||||
import request from 'supertest';
|
||||
|
||||
export type RestAPIRequestMethod = 'get' | 'post' | 'put' | 'patch' | 'delete';
|
||||
|
||||
export const makeRestAPIRequest = (
|
||||
method: RestAPIRequestMethod,
|
||||
path: string,
|
||||
headers: IncomingHttpHeaders = {},
|
||||
) => {
|
||||
const client = request(`http://localhost:${APP_PORT}`);
|
||||
|
||||
return client[method]('/rest' + path)
|
||||
.set('Authorization', `Bearer ${ACCESS_TOKEN}`)
|
||||
.set({ ...headers })
|
||||
.send();
|
||||
};
|
||||
Reference in New Issue
Block a user