30 lines
753 B
TypeScript
30 lines
753 B
TypeScript
import Fastify from 'fastify';
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
import { app } from './app/app';
|
|
|
|
const host = process.env.API_HOST ?? 'localhost';
|
|
const port = process.env.API_PORT ? Number(process.env.API_PORT) : 3000;
|
|
|
|
// Instantiate Fastify with some config
|
|
const server = Fastify({
|
|
logger: true,
|
|
https: {
|
|
key: fs.readFileSync(path.join(__dirname, '..', 'certs', 'key.pem')),
|
|
cert: fs.readFileSync(path.join(__dirname, '..', 'certs', 'cert.pem')),
|
|
}
|
|
});
|
|
|
|
// Register your application as a normal plugin.
|
|
server.register(app);
|
|
|
|
// Start listening.
|
|
server.listen({ port, host }, (err) => {
|
|
if (err) {
|
|
server.log.error(err);
|
|
process.exit(1);
|
|
} else {
|
|
console.log(`[ ready ] https://${host}:${port}`);
|
|
}
|
|
});
|