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"
|
2024-05-13 14:38:16 +02:00
|
|
|
import fsfCors from "@fastify/cors"
|
2024-05-13 14:36:23 +02:00
|
|
|
|
2024-05-02 01:11:01 +02:00
|
|
|
const fastify = Fastify({
|
|
|
|
|
logger: true,
|
|
|
|
|
})
|
|
|
|
|
|
2024-05-13 14:38:16 +02:00
|
|
|
fastify.register(fsfCors)
|
|
|
|
|
|
2024-05-02 09:48:59 +02:00
|
|
|
fastify.register(fsfStatic, {
|
2024-05-02 01:11:01 +02:00
|
|
|
root: join(import.meta.dirname, process.env.STATIC_DIR || "dist"),
|
2024-05-13 14:36:23 +02:00
|
|
|
preCompressed: true,
|
2024-05-02 01:11:01 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
try {
|
2024-05-02 10:53:51 +02:00
|
|
|
fastify.listen({ port: process.env.PORT || 3000, host: "0.0.0.0" })
|
2024-05-02 01:11:01 +02:00
|
|
|
} catch (err) {
|
|
|
|
|
fastify.log.error(err)
|
|
|
|
|
process.exit(1)
|
|
|
|
|
}
|