sh -c "./wwwapp deploy --herokuapp=myapp"
(host) $ ./wwwapp dev
(container) #
(container) # make && node --inspect=0.0.0.0:9229 server
chrome://inspect and click on Open dedicated DevTools for Node

(container) # ./node_modules/.bin/tap --node-arg=--inspect=0.0.0.0:9229 --no-timeout --bail test/unit/users-sessions.js
To enabled Saucelabs on Travis (https://travis-ci.org/goodenough/wwwapp/settings) :
wwwapp_saucelabs_username: abernier_
wwwapp_saucelabs_accesskey: ************
wwwapp_selenium_hub__hostname: sc
wwwapp_selenium_hub__port: 4445
wwwapp_selenium_capabilities__0__browserName: chrome
wwwapp_selenium_capabilities__0__platform: "Windows 10"
wwwapp_selenium_capabilities__1__browserName: firefox
wwwapp_selenium_capabilities__1__platform: "Windows 10"
req.session.messages.flash.push({
type: 'info',
message: "Cette reconnaissance est maintenant acceptée."
});
res.locals._settings.body.email = -- to current the viewreq.session.body.email = -- to the next viewres.locals._settings.messages.flash.push( -- push a flash message to the current viewreq.session.messages.flash.push( -- push a flash message to the next viewRequirements:
./wwwapp start
Then go to http://localhost:3000
wwwapp has a decent default configuration (see env-dist.sh).
However, you may want to override any of its values, in sereval ways:
node server --selenium_capabilities__2__platform=Windows\ 10wwwapp_* variables:
wwwapp_selenium_capabilities__2__platform="Windows 10" node serverexport wwwapp_selenium_capabilities__2__platform="Windows 10" && node servernode server --config /path/to/config.ini.wwwapprc file found somewhere at (in order):
. but also ../, ../../, ../../../, ...$HOME/.wwwapprc or $HOME/.wwwapp/config or $HOME/.config/wwwapp or $HOME/.config/wwwapp/config/etc/wwwapprc or /etc/wwwapp/configNB: In case of 3., just have a copy of the defaults.json file.
CORS is enabled
API supports content-negociation.
Default Accept and Content-Type headers are application/json by default if ommited.
HTTP/1.1 422 Unprocessable Entity
{
"error": [
{
"field": "firstname",
"code": "missing",
"message": "Please enter a firstname"
},
{
"field": "price",
"code": "invalid"
}
],
"message": "Validation failed",
"stack": "..."
}
HEAD /users/1 or HEAD /[email protected] -- publiccurl -i -XHEAD http://localhost:3000/[email protected]
HTTP/1.1 204 No Content
or HTTP/1.1 404 Not Found
PUT /users/valid or PUT /users/1/valid -- publiccurl -i -XPUT http://localhost:3000/users/valid -d @-
{
"email": "[email protected]",
"quickregister": true,
"g-recaptcha-response": ""
}
HTTP/1.1 204 No Content
or HTTP/1.1 422 Unprocessable Entity if not valid.
quickregister mode, only g-recaptcha-response and one of email|facebookid|googleid and are mandatory.quickregister, additionnal fields are required, ie: tos, firstname, lastname, birthday.An example for an already registered user:
curl -i -XPUT http://localhost:3000/users/1/valid -d @-
{
"email": "[email protected]",
"tos": true,
"firstname": "Antoine"
"lastname": "BERNIER",
"birthday": "05/16/1982"
}
HTTP/1.1 204 No Content
GET /users/new -- publicHTML form to create a user.
curl -i -XGET http://localhost:3000/users/new -H"Accept: text/html"
HTTP/1.1 200 ok
POST /users -- publiccurl -i -XPOST http://localhost:3000/users -d @-
{
"email": "[email protected]",
"quickregister": 1,
"g-recaptcha-response": ""
}
HTTP/1.1 201 Created
Set-Cookie: WwwappAuthSession=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6OSwicGFzc3dvcmQiOiI2ODg5ZWMwNzE1NTNhNzU3MTk4M2UyNjIwYTIxYmJjZWRlNmM5MmU0IiwiaWF0IjoxNDYyMjgyNTIwfQ.AOBXwusUyue-hlgzDUMO3CjpO1h17Xy_zBWytNnnQcM; Version=1; Path=/; HttpOnly
{
...
}
GET /users/1 -- privatecurl -i -XGET http://localhost:3000/users/1 -H"Cookie:WwwappAuthSession=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwicGFzc3dvcmQiOiI3ODQ2NjVmMzViYzQxMzIyNzRiMjZlNTg3ZGVjY2IzYjU4OWJmZWUyIiwiaWF0IjoxNDYzNTc1MDcxfQ.C7b0apEn5uBC8kOpQ62M9dgIW2ZxE3megCibbUxWuYw"
HTTP/1.1 200 ok
{
...
}
or HTTP/1.1 403 Forbidden if not owner
or HTTP/1.1 401 Unauthorized
PUT /users/1 -- privatecurl -i -XPUT http://localhost:3000/users/1 -H"Cookie:WwwappAuthSession=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwicGFzc3dvcmQiOiI3ODQ2NjVmMzViYzQxMzIyNzRiMjZlNTg3ZGVjY2IzYjU4OWJmZWUyIiwiaWF0IjoxNDYzNTc1MDcxfQ.C7b0apEn5uBC8kOpQ62M9dgIW2ZxE3megCibbUxWuYw" \
-d @-
{
"email": "[email protected]"
}
HTTP/1.1 200 Ok
{
...
}
DELETE /users/1 -- privatecurl -i -XDELETE http://localhost:3000/users/1 -H"Cookie:WwwappAuthSession=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6MSwicGFzc3dvcmQiOiI3ODQ2NjVmMzViYzQxMzIyNzRiMjZlNTg3ZGVjY2IzYjU4OWJmZWUyIiwiaWF0IjoxNDYzNTc1MDcxfQ.C7b0apEn5uBC8kOpQ62M9dgIW2ZxE3megCibbUxWuYw"
HTTP/1.1 204 No Content
PUT /sessions/valid -- publiccurl -i -XPUT http://localhost:3000/sessions/valid -d @-
{
"email": "[email protected]",
"password": "toto123+"
}
HTTP/1.1 204 No Content
or HTTP/1.1 422 Unprocessable Entity if not valid.
POST /sessionscurl -i -XPOST http://localhost:3000/sessions -d @-
{
"email": "[email protected]",
"password": "toto123+"
}
HTTP/1.1 201 Created
Set-Cookie: WwwappAuthSession=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6OSwicGFzc3dvcmQiOiI2ODg5ZWMwNzE1NTNhNzU3MTk4M2UyNjIwYTIxYmJjZWRlNmM5MmU0IiwiaWF0IjoxNDYyMjgyNTIwfQ.AOBXwusUyue-hlgzDUMO3CjpO1h17Xy_zBWytNnnQcM; Version=1; Path=/; HttpOnly
{
user: {id: 1, ...}
}
or HTTP/1.1 401 Unauthorized
You can also create a session using the user's id:
curl -i -XPOST http://localhost:3000/sessions -d @-
{
"id": 1,
"password": "toto123+"
}
HTTP/1.1 201 Created
Set-Cookie: WwwappAuthSession=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6OSwicGFzc3dvcmQiOiI2ODg5ZWMwNzE1NTNhNzU3MTk4M2UyNjIwYTIxYmJjZWRlNmM5MmU0IiwiaWF0IjoxNDYyMjgyNTIwfQ.AOBXwusUyue-hlgzDUMO3CjpO1h17Xy_zBWytNnnQcM; Version=1; Path=/; HttpOnly
{
user: {id: 1, ...}
}
GET /sessioncurl -i -XGET http://localhost:3000/session -H"Cookie:WwwappAuthSession=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6OSwicGFzc3dvcmQiOiI2ODg5ZWMwNzE1NTNhNzU3MTk4M2UyNjIwYTIxYmJjZWRlNmM5MmU0IiwiaWF0IjoxNDYyMjgyNTIwfQ.AOBXwusUyue-hlgzDUMO3CjpO1h17Xy_zBWytNnnQcM"
HTTP/1.1 200 Ok
{
user: {id: 1, ...}
}
DELETE /sessioncurl -i -XDELETE http://localhost:3000/session -H"Cookie:WwwappAuthSession=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6OSwicGFzc3dvcmQiOiI2ODg5ZWMwNzE1NTNhNzU3MTk4M2UyNjIwYTIxYmJjZWRlNmM5MmU0IiwiaWF0IjoxNDYyMjgyNTIwfQ.AOBXwusUyue-hlgzDUMO3CjpO1h17Xy_zBWytNnnQcM"
HTTP/1.1 204 No Content
or
HTTP/1.1 401 Unauthorized
GET /sessions/facebookHTTP/1.1 302
GET /sessions/googleHTTP/1.1 302
GET /tokens/newHTML form a user can use to send him a magiclink
POST /tokensRoute that handles token generation.
curl -XPOST http://localhost:3000/tokens -d @-
{
"email": "[email protected]"
}
HTTP/1.1 204 No Content
GET /tokens/{token}Route that log-in a user with a previously generated token.
curl -XGET http://localhost:3006/tokens/{token}
HTTP/1.1 204 No Content
Set-Cookie: WwwappAuthSession=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6OSwicGFzc3dvcmQiOiI2ODg5ZWMwNzE1NTNhNzU3MTk4M2UyNjIwYTIxYmJjZWRlNmM5MmU0IiwiaWF0IjoxNDYyMjgyNTIwfQ.AOBXwusUyue-hlgzDUMO3CjpO1h17Xy_zBWytNnnQcM; Version=1; Path=/; HttpOnly
NB: token is 40 characters long and composed only of [a-zA-Z0-9_-]
or HTTP/1.1 404 Not Found if not found token or expired
./bin/env env*.sh >/tmp/.wwwappenv && docker-compose config
$ docker-compose build test-unit
$ docker-compose run test-unit /bin/sh
/home/node/app # make test-unit
req.session.user
req.session.body
req.session.message
Content type
Image
Digest
Size
43.1 MB
Last updated
almost 8 years ago
docker pull abernier/wwwapp