Peter Lee | df26beb | 2016-07-28 23:42:27 -0700 | [diff] [blame] | 1 | # |
| 2 | # Author: Peter K. Lee (peter@corenova.com) |
| 3 | # |
| 4 | # All rights reserved. This program and the accompanying materials |
| 5 | # are made available under the terms of the Apache License, Version 2.0 |
| 6 | # which accompanies this distribution, and is available at |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | |
Peter Lee | df26beb | 2016-07-28 23:42:27 -0700 | [diff] [blame] | 10 | yang = require('yang-js') |
| 11 | |
Peter K. Lee | 29a9514 | 2016-08-13 03:25:18 -0700 | [diff] [blame] | 12 | app = require('yang-express') -> |
| 13 | @set 'pkginfo', require('../../package.json') |
| 14 | @set 'initial state', require('../../sample-data.json') |
| 15 | @enable 'openapi', 'restjson', 'websocket' |
| 16 | |
| 17 | cord = @link yang.require('cord-core') |
| 18 | xos = @link yang.require('xos-core') |
| 19 | |
| 20 | cord.on 'update', (prop) -> |
| 21 | console.log "[#{prop.path}] got updated, should consider persisting the change somewhere" |
| 22 | |
| 23 | module.exports = app |
Peter Lee | df26beb | 2016-07-28 23:42:27 -0700 | [diff] [blame] | 24 | |
Peter K. Lee | 29a9514 | 2016-08-13 03:25:18 -0700 | [diff] [blame] | 25 | # only start if directly invoked |
| 26 | if require.main is module |
| 27 | path = require('path') |
| 28 | argv = require('minimist')(process.argv.slice(2)) |
| 29 | argv.port ?= 5050 |
| 30 | app.listen argv.port |