UNPKG

1.06 kBJavaScriptView Raw
1/**
2* Example service entry point.
3*
4* The purpose of these entry points is to map
5* and configure all the services that the service
6* will need to connect to.
7*
8* You give the services names, and waif keeps track
9* of what the connection details you give it.
10*
11* Each service may have zero or more of these
12* configuration files, and may point to remote
13* services or load up it's own copies.
14*
15*/
16
17var waif = require('../waif')();
18var service = require('./src/github');
19
20var PORT = process.env.PORT || 3000;
21
22var ghOpts = {
23 headers: {
24 'Accept': 'application/vnd.github.v3+json',
25 'User-Agent': 'Waif-Example-App'
26 }
27};
28
29var ghDomain = 'https://api.github.com';
30
31waif('github/repo')
32 .pipe('/:owner/:repo', ghDomain+'/repos/:owner/:repo', ghOpts)
33 .listen(0);
34
35waif('github/users')
36 .pipe('/:user', ghDomain+'/users/:user', ghOpts)
37 .listen(0);
38
39waif('app')
40 .send('/favicon.ico', null)
41 .pipe('/:user/link', 'https://github.com/:user', { redirect: true })
42 .use(service, { owner: 'wayfin' })
43 .listen(process.env.PORT || 3000);
44
45waif.start();