You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.1 KiB

9 years ago
9 years ago
8 years ago
8 years ago
8 years ago
8 years ago
  1. 'use strict'
  2. const Lws = require('lws')
  3. /**
  4. * @module local-web-server
  5. */
  6. /**
  7. * @alias module:local-web-server
  8. */
  9. class LocalWebServer extends Lws {
  10. constructor (options) {
  11. const path = require('path')
  12. const stack = [
  13. 'lws-log',
  14. 'lws-cors',
  15. 'lws-json',
  16. 'lws-rewrite',
  17. 'lws-body-parser',
  18. 'lws-blacklist',
  19. 'lws-conditional-get',
  20. 'lws-mime',
  21. 'lws-compress',
  22. 'lws-mock-response',
  23. 'lws-spa',
  24. 'lws-static',
  25. 'lws-index'
  26. ].map(name => {
  27. return path.resolve(__dirname, `../node_modules/${name}`)
  28. })
  29. options = Object.assign({ stack }, options)
  30. super(options)
  31. }
  32. getVersion () {
  33. const path = require('path')
  34. const pkg = require(path.resolve(__dirname, '..', 'package.json'))
  35. return pkg.version
  36. }
  37. getUsageHeader () {
  38. return {
  39. header: 'local-web-server',
  40. content: 'A convenient local web server to support productive, full-stack Javascript development.'
  41. }
  42. }
  43. getUsageFooter () {
  44. return {
  45. content: 'Project home: [underline]{https://github.com/lwsjs/local-web-server}'
  46. }
  47. }
  48. }
  49. module.exports = LocalWebServer