app.js 627 B

1234567891011121314151617181920212223242526272829
  1. /**
  2. * @author oldj
  3. * @blog https://oldj.net
  4. */
  5. 'use strict'
  6. const {PORT} = require('../../configs')
  7. const express = require('express')
  8. const app = express()
  9. app.use(function (req, res, next) {
  10. console.log(`> "${(new Date()).toString()}"`, req.method, req.originalUrl, `"${req.headers['user-agent']}"`)
  11. next()
  12. })
  13. app.get('/', function (req, res) {
  14. res.send('Hello SwitchHost!')
  15. })
  16. app.get('/remote-test', function (req, res) {
  17. res.send(`# remote-test\n# ${(new Date()).toString()}`)
  18. })
  19. app.listen(PORT, function () {
  20. console.log(`SwitchHosts! HTTP server listening on port ${PORT}!`)
  21. })
  22. module.exports = app