index.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. var chalk = {};
  2. const express = require('express');
  3. module.exports = function() {
  4. return {
  5. name: '@mws/carmen-castillo-landing-page',
  6. type: 'website',
  7. auto_load: true,
  8. initialize: function(system) {
  9. this.system = system;
  10. chalk = this.system.chalk;
  11. },
  12. install: function(){
  13. this.system.carmenLandingPage = this;
  14. if(this.system.carmenLandingPage == undefined)
  15. this.system.log(this.system.chalk.red('Error: mws-carmen-castillo-landing-page module not found on system!'));
  16. this.server = this.system.module_loader.instantiate_module(this.system, '@mws/server');
  17. if(this.server == undefined)
  18. this.system.log(this.system.chalk.red('Error: Could not install mws-server for mws-carmen-castillo-landing-page module.'));
  19. else {
  20. this.system.modules.push(this.server);
  21. this.server.port = 3000;
  22. this.server.install();
  23. this.system.log(` ${this.system.logSymbols.tick} Instantiated ${chalk.bold(this.server.name)} ${chalk.gray('v' + this.server.version)} from ${chalk.green('\'' + this.server.packagePath + '\'')}`);
  24. }
  25. },
  26. setup: function(){
  27. let viewPath = __dirname + '/views';
  28. //if(this.system.cpanel.server.viewPaths == undefined) this.system.cpanel.server.viewPaths = [];
  29. if(this.server == undefined){
  30. this.system.log(chalk.red('Error: Could not find server!'));
  31. } else if(this.server.app == undefined){
  32. this.system.log(chalk.red('Error: Could not find cpanel server app!'));
  33. }
  34. this.server.viewPaths.push(viewPath);
  35. this.server.app.use("/", express.static(__dirname + "/public"));
  36. this.server.app.get('/', (req, res) => {
  37. //res.send('Hello World!')
  38. res.render('start-page', {system: this.system, title: 'Carmen Castillo Imóveis'});
  39. })
  40. },
  41. start: function(){},
  42. execute: function(){}
  43. };
  44. }