diff --git a/server.ts b/server.ts index 5286d34f..13f37582 100644 --- a/server.ts +++ b/server.ts @@ -1,19 +1,19 @@ /*************************************************************************************************** * Load `$localize` onto the global scope - used if i18n tags appear in Angular templates. */ +import { APP_BASE_HREF } from '@angular/common'; import '@angular/localize/init'; -import 'zone.js/dist/zone-node'; - import { ngExpressEngine } from '@nguniversal/express-engine'; import * as express from 'express'; -import { join } from 'path'; - -import { AppServerModule } from './src/main.server'; -import { APP_BASE_HREF } from '@angular/common'; -import { existsSync } from 'fs'; import * as fs from 'fs'; +import { existsSync } from 'fs'; import * as nodemailer from 'nodemailer'; -import {tsParticles} from 'tsparticles'; +import { join } from 'path'; +import { tsParticles } from 'tsparticles'; +import 'zone.js/dist/zone-node'; +import { AppServerModule } from './src/main.server'; + + const domino = require('domino'); const template = fs.readFileSync(join('dist', 'fe-website', 'browser', 'index.html')).toString(); @@ -29,6 +29,13 @@ export function app() { const distFolder = join(process.cwd(), 'dist/fe-website/browser'); const indexHtml = existsSync(join(distFolder, 'index.original.html')) ? 'index.original.html' : 'index'; + server.use(function (req, res, next) { + res.setHeader('Cache-Control', 'no-cache, no-store, must-revalidate'); + res.setHeader('Pragma', 'no-cache'); + res.setHeader('Expires', '0'); + next(); + }); + server.use(express.urlencoded()) // add to handle slack form // Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine) @@ -39,8 +46,6 @@ export function app() { server.set('view engine', 'html'); server.set('views', distFolder); - // Example Express Rest API endpoints - // server.get('/api/**', (req, res) => { }); // Serve static files from /browser server.get('*.*', express.static(distFolder, { maxAge: '1y' @@ -52,14 +57,11 @@ export function app() { }); //add to handle slack form - server.post('/submit-form', (req, res)=>{ + server.post('/submit-form', (req, res) => { let content = req.body; - // console.log("request came"); - // console.log(req); sendMail(content, info => { // parse the 250 code from info.response - // console.log("in callback"); - res.redirect('/community?slackEmailResponse='+info.response.split(' ')[0]); + res.redirect('/community?slackEmailResponse=' + info.response.split(' ')[0]); }); }) @@ -88,8 +90,6 @@ if (moduleFilename === __filename || moduleFilename.includes('iisnode')) { async function sendMail(content, callback) { - // console.log("in sendEmail"); - // console.log(content); // create reusable transporter object using the default SMTP transport let transporter = nodemailer.createTransport({ host: "email-smtp.us-west-2.amazonaws.com", @@ -113,7 +113,7 @@ async function sendMail(content, callback) {