Skip to content

Commit

Permalink
server: add vercel.json
Browse files Browse the repository at this point in the history
  • Loading branch information
Shubham-Lal committed Jul 18, 2024
1 parent 28df664 commit c56574e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 30 deletions.
32 changes: 2 additions & 30 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,6 @@ fastify.decorate('upload', upload)

fastify.decorate('mysql', require('./db'))

const logs = [];
fastify.addHook('onRequest', async (request, reply) => {
request.logEntry = {
method: request.method,
url: request.url,
headers: request.headers,
body: request.body,
timestamp: new Date().toISOString()
};
});
fastify.addHook('onSend', async (request, reply, payload) => {
const responseLog = {
statusCode: reply.statusCode,
headers: reply.getHeaders(),
payload: payload,
timestamp: new Date().toISOString()
};
logs.push({ request: request.logEntry, response: responseLog });

if (logs.length > 1000) logs.shift();
});
fastify.get('/logs', (request, reply) => {
reply.send(logs);
});

fastify.register(require('@fastify/oauth2'), {
name: 'googleOAuth2',
scope: 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email',
Expand All @@ -67,14 +42,11 @@ fastify.register(require('fastify-mailer'), {
defaults: { from: `${process.env.EMAIL_USER} <${process.env.EMAIL_ADDRESS}>` },
transport: {
host: 'smtp.gmail.com',
port: 587,
secure: false,
port: 465,
secure: true,
auth: {
user: process.env.EMAIL_ADDRESS,
pass: process.env.EMAIL_PASSWORD
},
tls: {
rejectUnauthorized: true
}
}
})
Expand Down
17 changes: 17 additions & 0 deletions server/vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"env": {
"BRANCH": "vercel"
},
"builds": [
{
"src": "./server.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "server.js"
}
]
}

0 comments on commit c56574e

Please sign in to comment.