Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

main.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. Licensed to the Apache Software Foundation (ASF) under one
  3. or more contributor license agreements. See the NOTICE file
  4. distributed with this work for additional information
  5. regarding copyright ownership. The ASF licenses this file
  6. to you under the Apache License, Version 2.0 (the
  7. 'License'); you may not use this file except in compliance
  8. with the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  10. Unless required by applicable law or agreed to in writing,
  11. software distributed under the License is distributed on an
  12. 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  13. KIND, either express or implied. See the License for the
  14. specific language governing permissions and limitations
  15. under the License.
  16. */
  17. var chalk = require('chalk');
  18. var compression = require('compression');
  19. var express = require('express');
  20. module.exports = function () {
  21. return new CordovaServe();
  22. };
  23. function CordovaServe () {
  24. this.app = express();
  25. // Attach this before anything else to provide status output
  26. this.app.use(function (req, res, next) {
  27. res.on('finish', function () {
  28. var color = this.statusCode === '404' ? chalk.red : chalk.green;
  29. var msg = color(this.statusCode) + ' ' + this.req.originalUrl;
  30. var encoding = this._headers && this._headers['content-encoding'];
  31. if (encoding) {
  32. msg += chalk.gray(' (' + encoding + ')');
  33. }
  34. require('./server').log(msg);
  35. });
  36. next();
  37. });
  38. // Turn on compression
  39. this.app.use(compression());
  40. this.servePlatform = require('./platform');
  41. this.launchServer = require('./server');
  42. this.launchBrowser = require('./browser');
  43. }
  44. module.exports.launchBrowser = require('./browser');
  45. // Expose some useful express statics
  46. module.exports.Router = express.Router;
  47. module.exports.static = express.static;