-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhooks.js
More file actions
27 lines (22 loc) · 1.15 KB
/
hooks.js
File metadata and controls
27 lines (22 loc) · 1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var hooks = require('hooks');
var before = hooks.before;
var after = hooks.after;
var responseStash = {};
after("/blueprints > POST > 201 > application/json", function (transaction) {
responseStash[transaction.name] = transaction.real.body;
});
before("/blueprints/{blueprint_id} > GET > 200 > application/json", function (transaction) {
var blueprintId = JSON.parse(responseStash['/blueprints > POST > 201 > application/json'])['blueprint_id'];
var url = transaction.fullPath;
transaction.fullPath = url.replace('5c49caf3763d081d264b2637', blueprintId);
});
before("/blueprints/{blueprint_id} > PATCH > 200", function (transaction) {
var blueprintId = JSON.parse(responseStash['/blueprints > POST > 201 > application/json'])['blueprint_id'];
var url = transaction.fullPath;
transaction.fullPath = url.replace('5c49caf3763d081d264b2637', blueprintId);
});
before("/blueprints/{blueprint_id} > DELETE > 204", function (transaction) {
var blueprintId = JSON.parse(responseStash['/blueprints > POST > 201 > application/json'])['blueprint_id'];
var url = transaction.fullPath;
transaction.fullPath = url.replace('5c49caf3763d081d264b2637', blueprintId);
});