blob: 2ded0ff03fa210501b4b560a4be4e0d815191d4d [file] [log] [blame]
Matteo Scandolocf060772016-05-13 15:54:44 -07001'use strict';
2
Matteo Scandolocf060772016-05-13 15:54:44 -07003var path = require('path');
Matteo Scandoloc9306e42016-08-04 16:24:30 -07004var express = require('express');
5var app = express();
Matteo Scandolocf060772016-05-13 15:54:44 -07006
7var conf = {
8 paths: {
9 root: '../../../../../'
10 },
11 port: '8182'
12}
13
Matteo Scandoloc9306e42016-08-04 16:24:30 -070014if (process.env.ONOS_EXTERNAL_APP_DIRS) {
15 var external_apps = process.env.ONOS_EXTERNAL_APP_DIRS.replace(/\s/,'').split(',');
16 external_apps.forEach(function(a, i){
17 let [appName, appPath] = a.split(':');
18 conf.paths[appName] = appPath;
19 });
20}
Matteo Scandolocf060772016-05-13 15:54:44 -070021
Matteo Scandoloc9306e42016-08-04 16:24:30 -070022var httpProxyInit = function (baseDirs) {
Matteo Scandolocf060772016-05-13 15:54:44 -070023
Matteo Scandoloc9306e42016-08-04 16:24:30 -070024 Object.keys(baseDirs).forEach(dir => {
25 var d = path.isAbsolute(baseDirs[dir]) ? baseDirs[dir] : path.join(__dirname, baseDirs[dir]);
26 app.use(express.static(d));
27 });
Matteo Scandolocf060772016-05-13 15:54:44 -070028
Matteo Scandoloc9306e42016-08-04 16:24:30 -070029 app.get('/', function (req, res) {
30 res.send('Hello World!');
31 });
Matteo Scandolocf060772016-05-13 15:54:44 -070032
Matteo Scandoloc9306e42016-08-04 16:24:30 -070033 app.listen(conf.port, function () {
34 console.log(`Dev server is up and listening on http://localhost:${conf.port}!`);
Matteo Scandolocf060772016-05-13 15:54:44 -070035 });
36};
37
Matteo Scandoloc9306e42016-08-04 16:24:30 -070038httpProxyInit(conf.paths);
39
40
41