Browse Source

Restore dev version #20 begin

pull/1/head
Alexey Velikiy 7 years ago
parent
commit
74a5ca8c1c
  1. 13
      server/build/dev-server.js
  2. 3
      server/build/webpack.dev.conf.js
  3. 42279
      server/dist/server.js
  4. 13
      server/package.json
  5. 4
      server/src/index.ts
  6. 1
      server/src/services/alerts.ts

13
server/build/dev-server.js

@ -2,9 +2,18 @@ const { spawn } = require('child_process');
const webpack = spawn('webpack', ['--config', 'build/webpack.dev.conf.js'], { const webpack = spawn('webpack', ['--config', 'build/webpack.dev.conf.js'], {
stdio: 'inherit', stdio: 'inherit',
shell: true shell: false
}); });
const nodemon = spawn('nodemon', ['../dist/server', '--watch', 'server.js']); var env = Object.create(process.env);
env.LOG_LEVEL = 'debug';
const nodemon = spawn(
'nodemon',
['--exec', '"node --inspect dist/server.js"'],
{ env: env, shell: true }
);
nodemon.stdout.pipe(process.stdout); nodemon.stdout.pipe(process.stdout);
nodemon.stderr.pipe(process.stderr); nodemon.stderr.pipe(process.stderr);

3
server/build/webpack.dev.conf.js

@ -5,12 +5,13 @@ const webpack = require('webpack');
base.mode = 'development'; base.mode = 'development';
base.watch = true; base.watch = true;
// https://webpack.js.org/configuration/devtool/
base.devtool = 'inline-source-map'; base.devtool = 'inline-source-map';
base.externals = base.externals ? base.externals : []; base.externals = base.externals ? base.externals : [];
base.externals.push( base.externals.push(
function(context, request, callback) { function(context, request, callback) {
if(request[0] == '.' || request.indexOf('koa') == 0) { if(request[0] == '.') {
callback(); callback();
} else { } else {
callback(null, "require('" + request + "')"); callback(null, "require('" + request + "')");

42279
server/dist/server.js vendored

File diff suppressed because one or more lines are too long

13
server/package.json

@ -19,23 +19,22 @@
"url": "https://github.com/hastic/hastic-server/issues" "url": "https://github.com/hastic/hastic-server/issues"
}, },
"homepage": "https://github.com/hastic/hastic-server#readme", "homepage": "https://github.com/hastic/hastic-server#readme",
"dependencies": { "dependencies": {},
},
"devDependencies": { "devDependencies": {
"@types/koa": "^2.0.45", "@types/koa": "^2.0.45",
"@types/koa-bodyparser": "^4.2.0", "@types/koa-bodyparser": "^4.2.0",
"@types/koa-router": "^7.0.28", "@types/koa-router": "^7.0.28",
"axios": "^0.18.0", "axios": "^0.18.0",
"es6-promise": "^4.2.4",
"event-stream": "^3.3.4",
"koa": "^2.5.1",
"koa-bodyparser": "^4.2.1",
"koa-router": "^7.4.0",
"babel-core": "^6.26.3", "babel-core": "^6.26.3",
"babel-loader": "^7.1.4", "babel-loader": "^7.1.4",
"babel-polyfill": "^6.26.0", "babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0", "babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1", "babel-preset-es2015": "^6.24.1",
"es6-promise": "^4.2.4",
"event-stream": "^3.3.4",
"koa": "^2.5.1",
"koa-bodyparser": "^4.2.1",
"koa-router": "^7.4.0",
"nodemon": "^1.17.5", "nodemon": "^1.17.5",
"ts-loader": "^4.4.1", "ts-loader": "^4.4.1",
"typescript": "^2.8.3", "typescript": "^2.8.3",

4
server/src/index.ts

@ -23,12 +23,13 @@ app.use(async function(ctx, next) {
next(); next();
}); });
var rootRouter = new Router(); var rootRouter = new Router();
rootRouter.use('/anomalies', anomaliesRouter.routes(), anomaliesRouter.allowedMethods()); rootRouter.use('/anomalies', anomaliesRouter.routes(), anomaliesRouter.allowedMethods());
rootRouter.use('/segments', segmentsRouter.routes(), segmentsRouter.allowedMethods()); rootRouter.use('/segments', segmentsRouter.routes(), segmentsRouter.allowedMethods());
rootRouter.use('/alerts', alertsRouter.routes(), alertsRouter.allowedMethods()); rootRouter.use('/alerts', alertsRouter.routes(), alertsRouter.allowedMethods());
rootRouter.get('/', async (ctx) => { rootRouter.get('/', async (ctx) => {
ctx.response.body = { status: 'OK' }; ctx.response.body = { status: 'Ok' };
}); });
app app
@ -38,3 +39,4 @@ app
app.listen(PORT, () => { app.listen(PORT, () => {
console.log(`Server is running on :${PORT}`) console.log(`Server is running on :${PORT}`)
}); });

1
server/src/services/alerts.ts

@ -10,6 +10,7 @@ import * as path from 'path';
import * as fs from 'fs'; import * as fs from 'fs';
const ALERTS_DB_PATH = path.join(ANOMALIES_PATH, `alerts_anomalies.json`); const ALERTS_DB_PATH = path.join(ANOMALIES_PATH, `alerts_anomalies.json`);
function getAlertsAnomalies(): AnomalyId[] { function getAlertsAnomalies(): AnomalyId[] {

Loading…
Cancel
Save