port config
This commit is contained in:
parent
35476348e2
commit
9e0946d80e
1 changed files with 10 additions and 1 deletions
11
src/main.ts
11
src/main.ts
|
@ -26,6 +26,15 @@ if (!FILESIZE) {
|
|||
process.exit(1);
|
||||
}
|
||||
|
||||
const PORT = process.env.PORT
|
||||
if (!PORT) {
|
||||
console.error("no file size detected");
|
||||
process.exit(1);
|
||||
} else if (isNaN(Number(PORT)) && FILESIZE.trim() !== '') {
|
||||
console.error("file size cannot be parsed.");
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
||||
export const __filename = fileURLToPath(import.meta.url);
|
||||
export const __dirname = path.dirname(__filename);
|
||||
|
@ -103,7 +112,7 @@ fastify.get('/', async (request, reply) => {
|
|||
})
|
||||
|
||||
|
||||
fastify.listen({port: 3000}, (err, address) => {
|
||||
fastify.listen({port: PORT}, (err, address) => {
|
||||
if (err) {
|
||||
fastify.log.error(err)
|
||||
process.exit(1)
|
||||
|
|
Loading…
Add table
Reference in a new issue