|
| 1 | +/* jshint -W079 */ |
| 2 | +(function() { |
| 3 | + var express = require('express'), |
| 4 | + app = express(), |
| 5 | + scribe = require('../scribe')(), |
| 6 | + console = process.console; |
| 7 | + |
| 8 | + |
| 9 | + app.set('port', (process.env.PORT || 5000)); |
| 10 | + |
| 11 | + /** |
| 12 | + * User : test |
| 13 | + * Pwd : tes |
| 14 | + */ |
| 15 | + |
| 16 | + app.get('/', function(req, res) { |
| 17 | + res.send('Hello world, see you at /logs'); |
| 18 | + }); |
| 19 | + |
| 20 | + //Handle your authentication here... use next if valid... redirect away otherwise! |
| 21 | + var auth = function(req, res, next) { |
| 22 | + if (req.user.admin) { |
| 23 | + return next(); |
| 24 | + } |
| 25 | + return res.redirect("/"); |
| 26 | + }; |
| 27 | + |
| 28 | + app.use('/logs', auth, scribe.webPanel()); |
| 29 | + |
| 30 | + //Make some logs |
| 31 | + console.addLogger('log'); |
| 32 | + console.addLogger('debug', 'inverse'); |
| 33 | + console.addLogger('fun', 'rainbow'); |
| 34 | + |
| 35 | + console.time().fun('hello world'); |
| 36 | + console.tag('This is a test').debug('A test'); |
| 37 | + console.tag('An object').log({ |
| 38 | + a: 'b', |
| 39 | + c: [1, 2, 3] |
| 40 | + }); |
| 41 | + |
| 42 | + var port = app.get("port"); |
| 43 | + |
| 44 | + app.listen(port, function() { |
| 45 | + console.time().log('Server listening at port ' + port); |
| 46 | + }); |
| 47 | +})(); |
| 48 | +/* jshint -W079 */ |
| 49 | +(function() { |
| 50 | + var express = require('express'), |
| 51 | + app = express(), |
| 52 | + scribe = require('../scribe')(), |
| 53 | + console = process.console; |
| 54 | + |
| 55 | + |
| 56 | + app.set('port', (process.env.PORT || 5000)); |
| 57 | + |
| 58 | + /** |
| 59 | + * User : test |
| 60 | + * Pwd : tes |
| 61 | + */ |
| 62 | + |
| 63 | + app.get('/', function(req, res) { |
| 64 | + res.send('Hello world, see you at /logs'); |
| 65 | + }); |
| 66 | + |
| 67 | + //Handle your authentication here... use next if valid... redirect away otherwise! |
| 68 | + var auth = function(req, res, next) { |
| 69 | + if (req.user.admin) { |
| 70 | + return next(); |
| 71 | + } |
| 72 | + return res.redirect("/"); |
| 73 | + }; |
| 74 | + |
| 75 | + app.use('/logs', auth, scribe.webPanel()); |
| 76 | + |
| 77 | + //Make some logs |
| 78 | + console.addLogger('log'); |
| 79 | + console.addLogger('debug', 'inverse'); |
| 80 | + console.addLogger('fun', 'rainbow'); |
| 81 | + |
| 82 | + console.time().fun('hello world'); |
| 83 | + console.tag('This is a test').debug('A test'); |
| 84 | + console.tag('An object').log({ |
| 85 | + a: 'b', |
| 86 | + c: [1, 2, 3] |
| 87 | + }); |
| 88 | + |
| 89 | + var port = app.get("port"); |
| 90 | + |
| 91 | + app.listen(port, function() { |
| 92 | + console.time().log('Server listening at port ' + port); |
| 93 | + }); |
| 94 | +})(); |
0 commit comments