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 8 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.

26 changes: 22 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,36 @@
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}`
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved
: process.env.PROD_CLIENT_HOSTNAME;
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved
const SERVER_PORT = process.env.NODE_ENV === 'development' ?
process.env.DEV_SERVER_PORT
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved
: process.env.PROD_SERVER_PORT;
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved

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
});

Check failure on line 36 in app.js

View workflow job for this annotation

GitHub Actions / eslint

[eslint] reported by reviewdog 🐶 Delete `⏎` Raw Output: {"ruleId":"prettier/prettier","severity":2,"message":"Delete `⏎`","line":36,"column":1,"nodeType":null,"messageId":"delete","endLine":37,"endColumn":1,"fix":{"range":[1061,1062],"text":""}}
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;
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved
const accessKeyId = process.env.NODE_ENV === 'development' ?
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved
process.env.DEV_S3_ACCESS_KEY_ID
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved
: process.env.PROD_S3_ACCESS_KEY_ID;
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved
const secretAccessKey = process.env.NODE_ENV === 'development' ?
process.env.DEV_SECRET_ACCESS_KEY
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved
: process.env.PROD_S3_SECRET_ACCESS_KEY;
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved

// 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,
};

Check failure on line 45 in common/s3.js

View workflow job for this annotation

GitHub Actions / eslint

[eslint] reported by reviewdog 🐶 Delete `⏎` Raw Output: {"ruleId":"prettier/prettier","severity":2,"message":"Delete `⏎`","line":45,"column":1,"nodeType":null,"messageId":"delete","endLine":46,"endColumn":1,"fix":{"range":[1060,1061],"text":""}}
30 changes: 30 additions & 0 deletions common/transporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// 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
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved
: process.env.PROD_EMAIL_USERNAME;
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved
const pass = process.env.NODE_ENV === 'development' ?
process.env.DEV_EMAIL_PASSWORD
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved
: process.env.PROD_EMAIL_PASSWORD;
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved
const emailSender = process.env.NODE_ENV === 'development' ?
`${process.env.DEV_EMAIL_FIRSTNAME} ${process.env.DEV_EMAIL_LASTNAME}`
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved
: `${process.env.PROD_EMAIL_FIRSTNAMS} ${process.env.DEV_EMAIL_LASTNAME}`;
jrock-3 marked this conversation as resolved.
Show resolved Hide resolved

// 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