2024-05-02 01:11:01 +02:00
|
|
|
import { join } from "path"
|
|
|
|
|
import Fastify from "fastify"
|
2024-05-02 09:48:59 +02:00
|
|
|
import fsfStatic from "@fastify/static"
|
|
|
|
|
import fsfCompress from "@fastify/compress"
|
2024-05-02 01:11:01 +02:00
|
|
|
const fastify = Fastify({
|
|
|
|
|
logger: true,
|
|
|
|
|
})
|
|
|
|
|
|
2024-05-02 09:48:59 +02:00
|
|
|
fastify.register(fsfCompress)
|
|
|
|
|
|
|
|
|
|
fastify.register(fsfStatic, {
|
2024-05-02 01:11:01 +02:00
|
|
|
root: join(import.meta.dirname, process.env.STATIC_DIR || "dist"),
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
fastify.listen({ port: process.env.PORT || 3000 })
|
|
|
|
|
} catch (err) {
|
|
|
|
|
fastify.log.error(err)
|
|
|
|
|
process.exit(1)
|
|
|
|
|
}
|