freeptcha/index.js

23 lines
713 B
JavaScript
Raw Normal View History

2023-06-23 13:08:16 +02:00
require('dotenv').config();
2023-06-23 18:14:01 +02:00
const { APP_DEBUG, SCRIPT_PROD } = process.env;
2023-06-23 13:08:16 +02:00
const fastify = require('fastify')({ logger: APP_DEBUG == 'true' });
const path = require('path');
fastify.register(require('@fastify/static'), {
root: path.join(__dirname, 'public'),
prefix: '/'
});
2023-06-23 15:11:59 +02:00
// load routes from routes.js
require('./routes')(fastify);
2023-06-23 18:14:01 +02:00
console.log('Starting up');
if (SCRIPT_PROD == 'true' && APP_DEBUG == 'true') {
console.warn('\x1b[33mYou are running a production script with APP_DEBUG=true. App will run \x1b[1;31min development mode.\x1b[0m');
}
2023-06-23 15:11:59 +02:00
2023-06-23 13:08:16 +02:00
fastify.listen({ port: process.env.APP_PORT ?? 8000 }, (err, address) => {
if (err) throw err;
console.log(`Listening on ${address}`);
})