-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathserver.ts
33 lines (27 loc) · 789 Bytes
/
server.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import fastify from "fastify";
import * as serverBuild from "@remix-run/dev/server-build";
import { remixFastifyPlugin } from "@mcansh/remix-fastify";
let MODE = process.env.NODE_ENV;
async function start() {
let app = fastify();
await app.register(remixFastifyPlugin, {
assetsBuildDirectory: serverBuild.assetsBuildDirectory,
build: serverBuild,
mode: MODE,
publicPath: serverBuild.publicPath,
});
let port = process.env.PORT ? Number(process.env.PORT) : 3000;
app
.listen({ port, host: "0.0.0.0" })
.then((address) => {
console.log(`Fastify server listening at ${address}`);
})
.catch((error) => {
console.error(error);
process.exit(1);
});
}
start().catch((error) => {
console.error(error);
process.exit(1);
});