blob: e9dbd4ee800be8e21fab8d21a6efa19af0b7c91e [file] [log] [blame]
Peter Leedf26beb2016-07-28 23:42:27 -07001#
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 Leedf26beb2016-07-28 23:42:27 -070010yang = require('yang-js')
11
Peter K. Lee29a95142016-08-13 03:25:18 -070012app = 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
23module.exports = app
Peter Leedf26beb2016-07-28 23:42:27 -070024
Peter K. Lee29a95142016-08-13 03:25:18 -070025# only start if directly invoked
26if 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