Skip to content

Commit

Permalink
fix: Vercel 500 crash error (#572)
Browse files Browse the repository at this point in the history
  • Loading branch information
hase0278 authored Feb 26, 2024
1 parent eb39bb9 commit 26fbd3c
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ export const redis =
password: process.env.REDIS_PASSWORD,
});

const fastify = Fastify({
maxParamLength: 1000,
logger: true,
});
export const tmdbApi = process.env.TMDB_KEY && process.env.TMDB_KEY;
(async () => {
const PORT = Number(process.env.PORT) || 3000;

const fastify = Fastify({
maxParamLength: 1000,
logger: true,
});
await fastify.register(FastifyCors, {
origin: '*',
methods: 'GET',
Expand Down Expand Up @@ -145,10 +145,9 @@ export const tmdbApi = process.env.TMDB_KEY && process.env.TMDB_KEY;
try {
fastify.get('/', (_, rp) => {
rp.status(200).send(
`Welcome to consumet api! 🎉 \n${
process.env.NODE_ENV === 'DEMO'
? 'This is a demo of the api. You should only use this for testing purposes.'
: ''
`Welcome to consumet api! 🎉 \n${process.env.NODE_ENV === 'DEMO'
? 'This is a demo of the api. You should only use this for testing purposes.'
: ''
}`,
);
});
Expand All @@ -168,3 +167,7 @@ export const tmdbApi = process.env.TMDB_KEY && process.env.TMDB_KEY;
process.exit(1);
}
})();
export default async function handler(req: any, res: any) {
await fastify.ready()
fastify.server.emit('request', req, res)
}

0 comments on commit 26fbd3c

Please sign in to comment.