mirror of
https://github.com/directus/directus.git
synced 2026-01-14 22:37:58 -05:00
* Bye-bye, Jest * Clean-up non-null assertions for PORT * Test all vendors * Consistent file names * Try with MSSQL 2022 * Revert "Try with MSSQL 2022" This reverts commitda807c6ec8. * Try to run on Windows for better MSSQL perf * Worth a try (hopefully runs MSSQL faster this way) * Start docker services via bash * Quick attempt with local installation of MSSQL * Test with MSSQL 2019 * Back to ubuntu-latest for other tests * Add typecheck cmd * Revert "Test all vendors" This reverts commitd6fbdd76c9. * Use TS for Vitest config file * Simplify vendors typecasting --------- Co-authored-by: ian <licitdev@gmail.com>
27 lines
677 B
TypeScript
27 lines
677 B
TypeScript
import { getUrl } from '@common/config';
|
|
import type { Vendor } from '@common/get-dbs-to-test';
|
|
import request from 'supertest';
|
|
|
|
export type AllowedRequestMethods = 'get' | 'post' | 'put' | 'patch' | 'delete' | 'search';
|
|
|
|
export type RequestOptions = {
|
|
path: string;
|
|
method: AllowedRequestMethods;
|
|
token: string;
|
|
body?: any;
|
|
};
|
|
|
|
export const PrepareRequest = (vendor: Vendor, requestOptions: RequestOptions) => {
|
|
const req = request(getUrl(vendor))[requestOptions.method](requestOptions.path);
|
|
|
|
if (requestOptions.token) {
|
|
req.set('Authorization', `Bearer ${requestOptions.token}`);
|
|
}
|
|
|
|
if (requestOptions.body) {
|
|
req.send(requestOptions.body);
|
|
}
|
|
|
|
return req;
|
|
};
|