Skip to content
This repository was archived by the owner on Mar 28, 2022. It is now read-only.

Commit f7ff191

Browse files
committed
Add behavior id
1 parent ebabfc6 commit f7ff191

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,21 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
## [To be deprecated]
88
- Remove deprecated "/mocks" api path.
9+
- Remove property "name" from behavior model.
910

1011
## [unreleased]
1112
### Added
1213
### Changed
1314
### Fixed
1415
### Removed
1516

17+
## [1.3.0] - 2019-01-03
18+
### Added
19+
- Add property id to behaviors model.
20+
21+
### Changed
22+
- Upgrade dependencies.
23+
1624
## [1.2.1] - 2019-12-25
1725
### Changed
1826
- Upgrade admin-api-paths dependency.

src/Behaviors.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,13 @@ class BehaviorsApi {
2323
this._behaviors = this._core.behaviors;
2424
this._router = express.Router();
2525
this._router.get("/", this.getCollection.bind(this));
26-
this._router.get("/:name", this.getModel.bind(this));
26+
this._router.get("/:id", this.getModel.bind(this));
2727
}
2828

2929
_parseModel(behavior) {
3030
return {
31-
name: behavior.name,
31+
id: behavior.id,
32+
name: behavior.name, // TODO, deprecate name property
3233
fixtures: behavior.fixtures.map(fixture => fixture.id),
3334
extendedFrom: behavior.extendedFrom
3435
};
@@ -45,14 +46,14 @@ class BehaviorsApi {
4546
}
4647

4748
getModel(req, res, next) {
48-
const name = req.params.name;
49-
this._tracer.verbose(`${PLUGIN_NAME}: Sending behavior ${name} | ${req.id}`);
50-
const foundBehavior = this._behaviors.collection.find(behavior => behavior.name === name);
49+
const id = req.params.id;
50+
this._tracer.verbose(`${PLUGIN_NAME}: Sending behavior ${id} | ${req.id}`);
51+
const foundBehavior = this._behaviors.collection.find(behavior => behavior.id === id);
5152
if (foundBehavior) {
5253
res.status(200);
5354
res.send(this._parseModel(foundBehavior));
5455
} else {
55-
next(Boom.notFound(`Behavior with name "${name}" was not found`));
56+
next(Boom.notFound(`Behavior with id "${id}" was not found`));
5657
}
5758
}
5859

0 commit comments

Comments
 (0)