2019-04-27 04:34:15 +00:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import { send } from '../../network/network';
|
|
|
|
import type { Request } from '../../models/request';
|
|
|
|
import * as models from '../../models';
|
2019-05-15 20:01:36 +00:00
|
|
|
import type { ExtraRenderInfo } from '../../common/render';
|
2019-04-27 04:34:15 +00:00
|
|
|
|
2019-05-04 20:34:52 +00:00
|
|
|
export function init(activeEnvironmentId: string | null): { network: Object } {
|
2019-04-27 04:34:15 +00:00
|
|
|
const network = {
|
2019-05-15 20:01:36 +00:00
|
|
|
async sendRequest(request: Request, extraInfo?: ExtraRenderInfo): Promise<Response> {
|
|
|
|
const responsePatch = await send(request._id, activeEnvironmentId, extraInfo);
|
2019-04-27 04:34:15 +00:00
|
|
|
const settings = await models.settings.getOrCreate();
|
|
|
|
return models.response.create(responsePatch, settings.maxHistoryResponses);
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
return { network };
|
|
|
|
}
|