blob: 37f7345493500fa15931251388ee68698c6f5643 [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. Leecb2eb922016-09-01 18:02:31 -070017
18 @open 'cord', ->
19 @import Yang.require('cord-core')
20 @import Yang.require('xos-core')
21
22 @connect require('../sample-data.json')
23 @on 'update', (prop) ->
24 console.log "[#{prop.path}] got updated, should consider persisting the change somewhere"
Peter K. Leeaf777da2016-08-17 04:33:00 -070025
Peter K. Lee29a95142016-08-13 03:25:18 -070026module.exports = app
Peter Leedf26beb2016-07-28 23:42:27 -070027
Peter K. Lee29a95142016-08-13 03:25:18 -070028# only start if directly invoked
29if require.main is module
Peter K. Lee29a95142016-08-13 03:25:18 -070030 argv = require('minimist')(process.argv.slice(2))
31 argv.port ?= 5050
32 app.listen argv.port