blob: 46a1e1bac93a96608cdff48a6b8705d14086ec49 [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 K. Leeaf777da2016-08-17 04:33:00 -070010Yang = require('yang-js')
Peter Leedf26beb2016-07-28 23:42:27 -070011
Peter K. Lee29a95142016-08-13 03:25:18 -070012app = require('yang-express') ->
Peter K. Leeaf777da2016-08-17 04:33:00 -070013 @enable 'yangapi'
14 @enable 'openapi', require('../package.json')
15 @enable 'restjson'
16 @enable 'websocket'
Peter K. Lee29a95142016-08-13 03:25:18 -070017
Peter K. Leeaf777da2016-08-17 04:33:00 -070018 data = require('../sample-data.json')
19 cord = @link Yang.require('cord-core'), data
20 xos = @link Yang.require('xos-core'), data
Peter K. Lee29a95142016-08-13 03:25:18 -070021
22 cord.on 'update', (prop) ->
23 console.log "[#{prop.path}] got updated, should consider persisting the change somewhere"
Peter K. Leeaf777da2016-08-17 04:33:00 -070024
Peter K. Lee29a95142016-08-13 03:25:18 -070025module.exports = app
Peter Leedf26beb2016-07-28 23:42:27 -070026
Peter K. Lee29a95142016-08-13 03:25:18 -070027# only start if directly invoked
28if require.main is module
Peter K. Lee29a95142016-08-13 03:25:18 -070029 argv = require('minimist')(process.argv.slice(2))
30 argv.port ?= 5050
31 app.listen argv.port