mirror of
https://github.com/Kong/insomnia
synced 2024-11-08 14:49:53 +00:00
32 lines
690 B
JavaScript
32 lines
690 B
JavaScript
'use strict';
|
|
|
|
const db = require('./');
|
|
|
|
module.exports.type = 'Response';
|
|
module.exports.prefix = 'res';
|
|
module.exports.init = () => ({
|
|
statusCode: 0,
|
|
statusMessage: '',
|
|
contentType: 'text/plain',
|
|
url: '',
|
|
bytesRead: 0,
|
|
elapsedTime: 0,
|
|
headers: [],
|
|
cookies: [],
|
|
body: '',
|
|
error: ''
|
|
});
|
|
|
|
module.exports.create = (patch = {}) => {
|
|
if (!patch.parentId) {
|
|
throw new Error('New Response missing `parentId`');
|
|
}
|
|
|
|
db.removeBulkSilently(module.exports.type, {parentId: patch.parentId});
|
|
return db.docCreate(module.exports.type, patch);
|
|
};
|
|
|
|
module.exports.getLatestByParentId = parentId => {
|
|
return db.getMostRecentlyModified(module.exports.type, {parentId});
|
|
};
|