mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 06:39:48 +00:00
33 lines
691 B
JavaScript
33 lines
691 B
JavaScript
import * as db from '../common/database';
|
|
|
|
export const type = 'Response';
|
|
export const prefix = 'res';
|
|
export function init () {
|
|
return {
|
|
statusCode: 0,
|
|
statusMessage: '',
|
|
contentType: '',
|
|
url: '',
|
|
bytesRead: 0,
|
|
elapsedTime: 0,
|
|
headers: [],
|
|
cookies: [],
|
|
body: '',
|
|
encoding: 'utf8', // Legacy format
|
|
error: ''
|
|
}
|
|
}
|
|
|
|
export function create (patch = {}) {
|
|
if (!patch.parentId) {
|
|
throw new Error('New Response missing `parentId`');
|
|
}
|
|
|
|
db.removeBulkSilently(type, {parentId: patch.parentId});
|
|
return db.docCreate(type, patch);
|
|
}
|
|
|
|
export function getLatestByParentId (parentId) {
|
|
return db.getMostRecentlyModified(type, {parentId});
|
|
}
|