On Github adriensamson / talk-lft-babitch
Une API REST pour enregistrer et restituer les données
Une application web responsive pour saisir les données et afficher les stats
{
"name": "Adrien",
"email": "adrien@example.com",
"_links": {
"self": {
"href": "http://api.babitch.example.com/v1/players/1"
}
}
}
{
"blue_score": 10,
"red_score": 9,
"composition": [
{ "...": "..." }
],
"goals": [
{ "...": "..." }
],
"_links": {
"self": {
"href": "http://api.babitch.example.com/v1/games/1"
}
}
}
{
"player_id": 1,
"team": "blue",
"position": "defense",
"_links": {
"player": {
"href": "http://api.babitch.example.com/v1/players/1"
}
}
}
{
"player_id": 1,
"conceder_id": 1,
"position": "defense",
"autogoal": true
}
Feature: Players Ressource
Scenario: POST a player, GET it, then GET player listing, finnaly DELETE it
Given I add "CONTENT_TYPE" header equal to "application/json"
When I send a POST request on "/v1/players" with body:
"""
{"name" : "raoul", "email" : "raoul@test.com"}
"""
Then the response status code should be 201
And the header "location" should be equal to "http://localhost/v1/players/1"
When I send a GET request on "/v1/players/1"
Then the response status code should be 200
And the response should be in JSON
And the JSON node "name" should be equal to "raoul"
And the JSON node "email" should be equal to "raoul@test.com"
<div ng-app="demo">
<h3>Hello {{ name }}</h3>
<input type="text" ng-model="name" />
</div>
<div ng-controller='CounterCtrl'>
<h3>Click : {{ count }}</h3>
<button ng-click="increment()">click !</button>
</div>
angular.module('demo', [])
.controller('CounterCtrl', ['$scope', function($scope) {
$scope.count = 0;
$scope.increment = function() {
$scope.count++;
};
}]);
Status : {{ repository.last_build_result }}
Search<div ng-controller='RestCtrl'>
<h3>{{ repository.slug }}</h3>
<p>Status : {{ repository.last_build_result }}</p>
<input type="text" ng-model="repoId" />
<button ng-click="search(repoId)">Search</button>
</div>
angular.module('demo', ['restangular'])
.controller('RestCtrl', ['$scope', 'Restangular', function($scope, Restangular) {
Restangular.setBaseUrl('https://api.travis-ci.org/');
Restangular.setRequestSuffix('.json');
$scope.search = function(repoId) {
$scope.repository = Restangular.one('repos', repoId).get().$object;
};
}]);
var http = require('http'),
faye = require('faye');
var httpServer = http.createServer(),
fayeServer = new faye.NodeAdapter({mount: '/faye', timeout: 45});
fayeServer.attach(httpServer);
server.listen(8000);
var client = new Faye.Client('http://localhost:8000/faye');
// Envoi d'un message
client.publish('/home-channel', {text: 'Hi there'});
// Réception d'un message
client.subscribe('/home-channel', function(message) {
console.log(message);
});