22 lines
716 B
TypeScript
22 lines
716 B
TypeScript
import Fastify from 'fastify';
|
|
import fastifyMiddie from '@fastify/middie';
|
|
import fastifyStatic from '@fastify/static';
|
|
import { fileURLToPath } from 'node:url';
|
|
import { handler as ssrHandler } from './dist/server/entry.mjs';
|
|
import { config } from './src/config.ts';
|
|
|
|
const app = Fastify({ logger: true });
|
|
await app
|
|
.register(fastifyStatic, {
|
|
root: fileURLToPath(new URL('./dist/client', import.meta.url)),
|
|
})
|
|
.register(fastifyMiddie);
|
|
app.use(ssrHandler);
|
|
app.listen({ host: '0.0.0.0', port: config.port }, (err, address) => {
|
|
if (err) {
|
|
app.log.error(err);
|
|
process.exit(1);
|
|
}
|
|
app.log.info(`Fastify web server with Astro middleware listening at ${address}.`)
|
|
});
|