Skip to content

Commit ca1fee8

Browse files
committed
Format the code with prettier
1 parent 70341f7 commit ca1fee8

26 files changed

+2485
-2468
lines changed

.github/workflows/node.js.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Node.js CI
22

33
on:
44
push:
5-
branches: [ "master" ]
5+
branches: ['master']
66
pull_request:
7-
branches: [ "master" ]
7+
branches: ['master']
88

99
permissions:
1010
contents: read
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717
strategy:
1818
matrix:
19-
node-version: [ 22.x ]
19+
node-version: [22.x]
2020
steps:
2121
- uses: actions/checkout@v4
2222
- name: Use Node.js ${{ matrix.node-version }}
@@ -25,5 +25,5 @@ jobs:
2525
node-version: ${{ matrix.node-version }}
2626
cache: 'npm'
2727
- run: npm install
28-
- run: npm run lint
28+
- run: npm run lint-check
2929
- run: npm run test

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
npm test
2-
npm run lint
2+
npm run lint

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Ignore artifacts:
2+
build
3+
coverage

.prettierrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"singleQuote": true,
3+
"printWidth": 300
4+
}

CHANGELOG.md

Lines changed: 580 additions & 528 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 342 additions & 317 deletions
Large diffs are not rendered by default.

SECURITY.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,16 @@ Use this section to tell people about which versions of your project are current
1010
| master | :white_check_mark: |
1111
| other | :x: |
1212

13-
1413
## Reporting a Vulnerability
14+
1515
PRIOR TO SUBMITTING SECURITY CONCERNS/REPORTS:
16+
1617
1. Research Wikipedia and other sources about hackathons to get more familiar with the potential uses of this project, the intended settings, and usage environments.
17-
2. Read README.MD entirely, including the intro paragraph and steps for Obtaining API Keys which includes replacing the .env values. The provided values in the .env file are placeholders, not a batch of keys exposed thru GitHub.
18-
3. Read prod-checklist.md. Hackathon projects are not production projects, and this checklist is to help users with their next steps to move from a prototype state to a production state.
18+
2. Read README.MD entirely, including the intro paragraph and steps for Obtaining API Keys which includes replacing the .env values. The provided values in the .env file are placeholders, not a batch of keys exposed thru GitHub.
19+
3. Read prod-checklist.md. Hackathon projects are not production projects, and this checklist is to help users with their next steps to move from a prototype state to a production state.
1920

2021
SUBMITTING SECURITY CONCERNS/REPORTS:
22+
2123
1. Complete the above steps 1 to 3.
2224
2. If you still believe you have identified an issue, please submit it as a GitHub Issue at https://github.com/sahat/hackathon-starter/issues with the relevant information for discussion and clarification.
23-
Submissions requiring registration with 3rd party websites will be marked/reported as spam.
25+
Submissions requiring registration with 3rd party websites will be marked/reported as spam.

app.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ dotenv.config({ path: '.env.example' });
2323
/**
2424
* Set config values
2525
*/
26-
const secureTransfer = (process.env.BASE_URL.startsWith('https'));
26+
const secureTransfer = process.env.BASE_URL.startsWith('https');
2727

2828
// Consider adding a proxy such as cloudflare for production.
2929
const limiter = rateLimit({
@@ -37,7 +37,8 @@ const limiter = rateLimit({
3737
// behind cloudflare, etc. You may need to change it for more complex network settings.
3838
// See readme.md for more info.
3939
let numberOfProxies;
40-
if (secureTransfer) numberOfProxies = 1; else numberOfProxies = 0;
40+
if (secureTransfer) numberOfProxies = 1;
41+
else numberOfProxies = 0;
4142

4243
/**
4344
* Controllers (route handlers).
@@ -64,7 +65,7 @@ console.log('Run this app using "npm start" to include sass/scss/css builds.\n')
6465
mongoose.connect(process.env.MONGODB_URI);
6566
mongoose.connection.on('error', (err) => {
6667
console.error(err);
67-
console.log('%s MongoDB connection error. Please make sure MongoDB is running.');
68+
console.log('MongoDB connection error. Please make sure MongoDB is running.');
6869
process.exit(1);
6970
});
7071

@@ -81,17 +82,19 @@ app.use(logger('dev'));
8182
app.use(express.json());
8283
app.use(express.urlencoded({ extended: true }));
8384
app.use(limiter);
84-
app.use(session({
85-
resave: true, // Only save session if modified
86-
saveUninitialized: false, // Do not save sessions until we have something to store
87-
secret: process.env.SESSION_SECRET,
88-
name: 'startercookie', // change the cookie name for additional security in production
89-
cookie: {
90-
maxAge: 1209600000, // Two weeks in milliseconds
91-
secure: secureTransfer
92-
},
93-
store: MongoStore.create({ mongoUrl: process.env.MONGODB_URI })
94-
}));
85+
app.use(
86+
session({
87+
resave: true, // Only save session if modified
88+
saveUninitialized: false, // Do not save sessions until we have something to store
89+
secret: process.env.SESSION_SECRET,
90+
name: 'startercookie', // change the cookie name for additional security in production
91+
cookie: {
92+
maxAge: 1209600000, // Two weeks in milliseconds
93+
secure: secureTransfer,
94+
},
95+
store: MongoStore.create({ mongoUrl: process.env.MONGODB_URI }),
96+
}),
97+
);
9598
app.use(passport.initialize());
9699
app.use(passport.session());
97100
app.use(flash());
@@ -115,19 +118,14 @@ app.use((req, res, next) => {
115118
const isSafeRedirect = (url) => /^\/[a-zA-Z0-9/]*$/.test(url);
116119

117120
// After successful login, redirect back to the intended page
118-
if (!req.user
119-
&& req.path !== '/login'
120-
&& req.path !== '/signup'
121-
&& !req.path.match(/^\/auth/)
122-
&& !req.path.match(/\./)) {
121+
if (!req.user && req.path !== '/login' && req.path !== '/signup' && !req.path.match(/^\/auth/) && !req.path.match(/\./)) {
123122
const returnTo = req.originalUrl;
124123
if (isSafeRedirect(returnTo)) {
125124
req.session.returnTo = returnTo;
126125
} else {
127126
req.session.returnTo = '/';
128127
}
129-
} else if (req.user
130-
&& (req.path === '/account' || req.path.match(/^\/api/))) {
128+
} else if (req.user && (req.path === '/account' || req.path.match(/^\/api/))) {
131129
const returnTo = req.originalUrl;
132130
if (isSafeRedirect(returnTo)) {
133131
req.session.returnTo = returnTo;
@@ -276,7 +274,9 @@ app.listen(app.get('port'), () => {
276274
const port = parseInt(BASE_URL.slice(colonIndex + 1), 10);
277275

278276
if (!BASE_URL.startsWith('http://localhost')) {
279-
console.log(`The BASE_URL env variable is set to ${BASE_URL}. If you directly test the application through http://localhost:${app.get('port')} instead of the BASE_URL, it may cause a CSRF mismatch or an Oauth authentication failure. To avoid the issues, change the BASE_URL or configure your proxy to match it.\n`);
277+
console.log(
278+
`The BASE_URL env variable is set to ${BASE_URL}. If you directly test the application through http://localhost:${app.get('port')} instead of the BASE_URL, it may cause a CSRF mismatch or an Oauth authentication failure. To avoid the issues, change the BASE_URL or configure your proxy to match it.\n`,
279+
);
280280
} else if (app.get('port') !== port) {
281281
console.warn(`WARNING: The BASE_URL environment variable and the App have a port mismatch. If you plan to view the app in your browser using the localhost address, you may need to adjust one of the ports to make them match. BASE_URL: ${BASE_URL}\n`);
282282
}

config/nodemailer.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ exports.sendMail = (settings) => {
1010
secure: true,
1111
auth: {
1212
user: process.env.SMTP_USER,
13-
pass: process.env.SMTP_PASSWORD
14-
}
13+
pass: process.env.SMTP_PASSWORD,
14+
},
1515
};
1616

1717
let transporter = nodemailer.createTransport(transportConfig);
1818

19-
return transporter.sendMail(settings.mailOptions)
19+
return transporter
20+
.sendMail(settings.mailOptions)
2021
.then(() => {
2122
settings.req.flash(settings.successfulType, { msg: settings.successfulMsg });
2223
})
@@ -26,7 +27,8 @@ exports.sendMail = (settings) => {
2627
transportConfig.tls = transportConfig.tls || {};
2728
transportConfig.tls.rejectUnauthorized = false;
2829
transporter = nodemailer.createTransport(transportConfig);
29-
return transporter.sendMail(settings.mailOptions)
30+
return transporter
31+
.sendMail(settings.mailOptions)
3032
.then(() => {
3133
settings.req.flash(settings.successfulType, { msg: settings.successfulMsg });
3234
})

0 commit comments

Comments
 (0)