// this sould only be used by the docker file !

import fastify, { FastifyInstance } from 'fastify';
import app from './app';

const start = async () => {
	const envToLogger = {
		development: {
			transport: {
				target: 'pino',
				options: {
					translateTime: 'HH:MM:ss Z',
					ignore: 'pid,hostname',
				},
			},
		},
		production: true,
		test: false,
	};

	const f: FastifyInstance = fastify({ logger: envToLogger.development });
	try {
		process.on('SIGTERM', () => {
			f.log.info('Requested to shutdown');
			process.exit(134);
		});
		console.log('-------->Serving static files from:');
		await f.register(app, {});
		await f.listen({ port: 80, host: '0.0.0.0' });
	}
	catch (err) {
		f.log.error(err);
		process.exit(1);
	};
};
start();
