|
1 | 1 | 'use strict' |
2 | 2 |
|
3 | | -// your github token can be stored in an env variable named token, |
4 | | -// and will be picked up here |
| 3 | +var Seneca = require('seneca') |
| 4 | +var Entities = require('seneca-entity') |
| 5 | +var Mesh = require('seneca-mesh') |
| 6 | +var Github = require('../lib/github') |
5 | 7 |
|
6 | | -var GITHUB_TOKEN = process.env.GITHUB_TOKEN || '' |
| 8 | +var envs = process.env |
| 9 | +var opts = { |
| 10 | + seneca: { |
| 11 | + tag: envs.GITHUB_TAG || 'nodezoo-github' |
| 12 | + }, |
| 13 | + github: { |
| 14 | + token: envs.GITHUB_TOKEN || '' |
| 15 | + }, |
| 16 | + mesh: { |
| 17 | + auto: true, |
| 18 | + listen: [ |
| 19 | + {pin: 'role:github,cmd:get', model: 'consume'}, |
| 20 | + {pin: 'role:info,req:part', model: 'observe'} |
| 21 | + ] |
| 22 | + } |
| 23 | +} |
7 | 24 |
|
8 | | -require('seneca')() |
9 | | -.use('entity') |
10 | | -.use('../github.js', {token: GITHUB_TOKEN}) |
11 | | -.add('role:info,req:part', function (args, done) { |
12 | | - done() |
13 | | - |
14 | | - this.act('role:github,cmd:get', {name: args.name}, function (err, mod) { |
15 | | - if (err) { |
16 | | - return done(err) |
17 | | - } |
18 | | - this.act('role:info,res:part,part:github', {name: args.name, data: mod.data$()}) |
19 | | - }) |
20 | | -}) |
21 | | - |
22 | | -.add('role:github,info:change', function (args, done) { |
23 | | - done() |
24 | | - this.act('role:info,cmd:get', {name: args.name, update: true}) |
25 | | -}) |
26 | | -.use('mesh', { |
27 | | - auto: true, |
28 | | - pin: ['role:github', 'role:info,req:part'], |
29 | | - model: 'publish' |
30 | | -}) |
| 25 | +Seneca(opts.seneca) |
| 26 | + .use(Entities) |
| 27 | + .use(Github, opts.github) |
| 28 | + .use(Mesh, opts.mesh) |
0 commit comments