Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2023-2024 refresh #12

Open
wants to merge 15 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 0 additions & 13 deletions .github/workflows/heroku-deploy-logs.yml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/issue-assigned.yml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/review-requested.yml

This file was deleted.

24 changes: 0 additions & 24 deletions .github/workflows/review-reviewed.yml

This file was deleted.

51 changes: 0 additions & 51 deletions .github/workflows/scripts/issueAssigned.js

This file was deleted.

52 changes: 0 additions & 52 deletions .github/workflows/scripts/reviewRequested.js

This file was deleted.

71 changes: 0 additions & 71 deletions .github/workflows/scripts/reviewReviewed.js

This file was deleted.

27 changes: 23 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,37 @@
const express = require('express');
const cors = require('cors');
const cookieParser = require('cookie-parser'); // FIXME: Keep only if using cookies
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved
const schedule = require('node-schedule'); // FIXME: Keep only if scheduling cronjobs
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved

// Routes
const sampleRouter = require('./routes/sample'); // FIXME: delete sample router

require('dotenv').config();

schedule.scheduleJob('0 0 0 0 0', () => console.log('Hello Cron Job!')); // FIXME: delete sample cronjob
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved

const app = express();

const PORT = process.env.PORT || 3001;
const CLIENT_HOSTNAME =
process.env.NODE_ENV === 'development'
? `${process.env.DEV_CLIENT_HOSTNAME}:${process.env.DEV_CLIENT_PORT}`
: process.env.PROD_CLIENT_HOSTNAME;
const SERVER_PORT =
process.env.NODE_ENV === 'development'
? process.env.DEV_SERVER_PORT
: process.env.PROD_SERVER_PORT;

app.use(
cors({
origin: `${process.env.REACT_APP_HOST}:${process.env.REACT_APP_PORT}`,
origin: CLIENT_HOSTNAME,
}),
);

app.listen(PORT, () => {
console.log(`Server listening on ${PORT}`);
app.use(cookieParser());

app.use(express.json()); // for req.body
app.use('/', sampleRouter); // FIXME: delete sample endpoint

app.listen(SERVER_PORT, () => {
console.log(`Server listening on ${SERVER_PORT}`);
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved
});
45 changes: 45 additions & 0 deletions common/s3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// FIXME: keep file only if using s3 file upload

const aws = require('aws-sdk');
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved
const crypto = require('crypto');

const region =
process.env.NODE_ENV === 'development' ? process.env.DEV_S3_REGION : process.env.PROD_S3_REGION;
const accessKeyId =
process.env.NODE_ENV === 'development'
? process.env.DEV_S3_ACCESS_KEY_ID
: process.env.PROD_S3_ACCESS_KEY_ID;
const secretAccessKey =
process.env.NODE_ENV === 'development'
? process.env.DEV_SECRET_ACCESS_KEY
: process.env.PROD_S3_SECRET_ACCESS_KEY;

// initialize a S3 instance
const s3 = new aws.S3({
region,
accessKeyId,
secretAccessKey,
signatureVersion: 'v4',
});

const getS3UploadURL = async () => {
// generate a unique name for image
const imageName = crypto.randomBytes(16).toString('hex');

// set up s3 params
const params = {
Bucket: process.env.S3_BUCKET_NAME,
Key: imageName,
Expires: 60,
};

// get a s3 upload url
const uploadURL = await s3.getSignedUrl('putObject', params);

return uploadURL;
};

module.exports = {
s3,
getS3UploadURL,
};
33 changes: 33 additions & 0 deletions common/transporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// FIXME: keep file only if using nodemailer

const nodemailer = require('nodemailer');
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved

require('dotenv').config();

const user =
process.env.NODE_ENV === 'development'
? process.env.DEV_EMAIL_USERNAME
: process.env.PROD_EMAIL_USERNAME;
const pass =
process.env.NODE_ENV === 'development'
? process.env.DEV_EMAIL_PASSWORD
: process.env.PROD_EMAIL_PASSWORD;
const emailSender =
process.env.NODE_ENV === 'development'
? `${process.env.DEV_EMAIL_FIRSTNAME} ${process.env.DEV_EMAIL_LASTNAME}`
: `${process.env.PROD_EMAIL_FIRSTNAMS} ${process.env.DEV_EMAIL_LASTNAME}`;

// sender information
const transport = {
host: 'smtp.gmail.com', // e.g. smtp.gmail.com
auth: {
user,
pass,
},
from: user,
secure: true,
};

const transporter = nodemailer.createTransport(transport);

module.exports = { transporter, emailSender };
Loading
Loading