Skip to content

Commit

Permalink
Merge pull request #211 from purujitb/master
Browse files Browse the repository at this point in the history
added new response headers
  • Loading branch information
Purujit Bahl authored Oct 5, 2020
2 parents de8a875 + 7c5ed7f commit 70c4fd6
Showing 1 changed file with 19 additions and 18 deletions.
37 changes: 19 additions & 18 deletions server.ts
Original file line number Diff line number Diff line change
@@ -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();
Expand All @@ -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)
Expand All @@ -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'
Expand All @@ -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]);
});
})

Expand Down Expand Up @@ -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",
Expand All @@ -113,7 +113,7 @@ async function sendMail(content, callback) {
<li> Have you contributed to any open source ML based framework? <br>
${content.exp}, ${content.otherExp}
</ul>
</ul>
`
};

Expand All @@ -123,3 +123,4 @@ async function sendMail(content, callback) {
}

export * from './src/main.server';

0 comments on commit 70c4fd6

Please sign in to comment.