ZhengCornell / Guardians

AG Hackathon

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Launch script: node app.js

  1. view folder There are three front-end pages: main.ejs: where the form exists fail.ejs: either the email is invalid or the email is already subscribed success.ejs: email subscribed successfully. Also, footer.ejs and header.ejs for refactory to make files clean.

  2. routes/index.js: Three get routes: "/": get the main.ejs "/success": get the success.ejs "/fail": get the fail.ejs And One post routes: "/": post the form information into MongoDB In this case, the email validation will be checked by the regular expression. If it passes the check, it will be stored in to User Collection with email and location info.

  3. Service folder: contains Mailer.js and emailTemplate.js Call the API from sendgrid to help me send emails. I will use emailTemplate to generate the formatted email, and pass it to construct an email.

  4. db.js: for the CLI program, I use this file to export a function. First, it connects with my local database. then iterate all elements in User collection and generate email subject and email content to all the Mailer.js to send all emails. Command-line script: npm run myScript (in the Guardian folder)

  5. models folder: contains user schema and email schema

  6. config folder: contains key.js, including sendgrid API key and azure API key.

About

AG Hackathon


Languages

Language:JavaScript 55.9%Language:HTML 44.1%