2016-01-24 18:03:01 -06:00
|
|
|
import express from 'express'
|
2016-04-09 05:09:53 -05:00
|
|
|
import * as Scribe from '../index.js';
|
2016-01-24 18:03:01 -06:00
|
|
|
import * as JSON2 from '../src/libs/JSON2'
|
|
|
|
|
|
|
|
const port = 4005;
|
|
|
|
const socketPort = 3000;
|
|
|
|
|
2016-04-09 05:09:53 -05:00
|
|
|
const options = {
|
|
|
|
"app": 'simple-server-stream-only',
|
|
|
|
"id": process.pid,
|
|
|
|
"expose": {
|
|
|
|
"default": [
|
|
|
|
"socket",
|
|
|
|
"bash"
|
|
|
|
],
|
|
|
|
"express": [
|
|
|
|
"express-socket",
|
|
|
|
"express-bash"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"expose/pipeline": {
|
|
|
|
"socket": [
|
|
|
|
"transform/ErrorExtractor",
|
|
|
|
"transform/ToJSON2",
|
|
|
|
"transform/FullTextSerialize",
|
|
|
|
"writer/SocketIO"
|
|
|
|
],
|
|
|
|
"express-socket": [
|
|
|
|
"transform/ExpressExtractor",
|
|
|
|
"transform/ErrorExtractor",
|
|
|
|
"transform/ToJSON2",
|
|
|
|
"transform/FullTextSerialize",
|
|
|
|
"writer/SocketIO"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
"module": {
|
|
|
|
"writer/SocketIO": {
|
|
|
|
"port": socketPort,
|
|
|
|
"options": {}
|
2016-01-24 18:03:01 -06:00
|
|
|
},
|
2016-04-09 05:09:53 -05:00
|
|
|
"router/Viewer/client": {
|
|
|
|
"background": "#131B21",
|
|
|
|
"socketPorts": [
|
|
|
|
socketPort
|
|
|
|
]
|
2016-01-24 18:03:01 -06:00
|
|
|
}
|
|
|
|
},
|
2016-04-11 22:18:51 -05:00
|
|
|
"debug": true
|
2016-04-09 05:09:53 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
const console = Scribe.create(options);
|
2016-01-24 18:03:01 -06:00
|
|
|
|
|
|
|
console.time('serverStartup');
|
|
|
|
|
|
|
|
// default tags
|
|
|
|
console.persistent('tags', ['mocha', 'scribe']);
|
|
|
|
|
|
|
|
// express
|
|
|
|
const app = express();
|
2016-04-11 06:16:51 -05:00
|
|
|
const logger = new Scribe.Middleware.ExpressRequestLogger(console);
|
2016-04-09 05:09:53 -05:00
|
|
|
const viewer = new Scribe.Router.Viewer(console);
|
2016-01-24 18:03:01 -06:00
|
|
|
|
|
|
|
// express logger
|
2016-04-09 05:09:53 -05:00
|
|
|
app.use(logger.getMiddleware());
|
|
|
|
|
|
|
|
// viewer
|
|
|
|
app.use('/scribe', viewer.getRouter());
|
2016-01-24 18:03:01 -06:00
|
|
|
|
|
|
|
// test harness
|
|
|
|
app.get('/test', (req, res) => {
|
|
|
|
console.log({multi: "object"}, {test: 5}, {date: new Date()}).then(()=> {
|
|
|
|
res.json({test: new Array(parseInt(Math.random() * 50)).join('.')})
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
app.listen(port, () => {
|
|
|
|
console.log(`Listening to ${port}`);
|
|
|
|
|
|
|
|
// basic logging
|
|
|
|
function func(foo, bar) {
|
|
|
|
console.log('func')
|
|
|
|
}
|
|
|
|
|
|
|
|
console.log(JSON2.parse(JSON2.stringify([func, new Promise((req, res)=>0)])));
|
|
|
|
|
|
|
|
console.log({multi: "object"}, {test: 5}, {date: new Date()});
|
|
|
|
|
|
|
|
console.log(`Go to http://localhost:${port}/scribe`);
|
|
|
|
|
|
|
|
console.trace('This is a trace');
|
|
|
|
|
|
|
|
console.timeEnd('serverStartup');
|
|
|
|
});
|