export enum HttpMethod {
    GET = 'GET',
    POST = 'POST'
}
export enum HttpRoute {
    insertionPath = '/assembly/preview/insertion_sequence/',
    assemblyPreviewPath = '/assembly/preview/subsequence/',
    projects = '/assembly/preview',
    createProject = '/assembly/create',
    ajaxMatrix = 'matrix.json'
}
export class HttpRepository {
    static server = 'http://localhost:3002'
    static async jsonRequest<T>(method: HttpMethod, url: string, data?: any): Promise<T> {
        const reqInit = {
            'body': data,
            'method': method,
            'headers': { 'Content-Type': 'application/json' },
        }
        if (data !== undefined) {
            reqInit['body'] = JSON.stringify(data)
        }
        return (await fetch(this.server + url, reqInit)).json()
    }
    static async request<T>(method: HttpMethod, url: string, data?: any): Promise<T> {
        const reqInit = {
            'body': data,
            'method': method,
        }
        if (data !== undefined) {
            reqInit['body'] = data
        }
        return (await fetch(this.server + url, reqInit)).json()
    }
}