Skip to content

Commit 37f2af7

Browse files
committed
chore: format
1 parent 78bb021 commit 37f2af7

File tree

1 file changed

+38
-38
lines changed

1 file changed

+38
-38
lines changed

server.mjs

+38-38
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,48 @@
1-
import path, { dirname } from "path";
2-
import { fileURLToPath } from "url";
3-
import fastifyStatic from "@fastify/static";
4-
import fastify from "fastify";
5-
import { h } from "preact";
6-
import { renderToString } from "preact-render-to-string";
1+
import path, { dirname } from 'path'
2+
import { fileURLToPath } from 'url'
3+
import fastifyStatic from '@fastify/static'
4+
import fastify from 'fastify'
5+
import { h } from 'preact'
6+
import { renderToString } from 'preact-render-to-string'
77

8-
const app = fastify({ logger: true });
8+
const app = fastify({ logger: true })
99

10-
const __dirname = dirname(fileURLToPath(import.meta.url));
10+
const __dirname = dirname(fileURLToPath(import.meta.url))
1111

1212
app.register(fastifyStatic, {
13-
root: path.join(__dirname, "out/client"),
14-
prefix: "/client",
15-
});
13+
root: path.join(__dirname, 'out/client'),
14+
prefix: '/client',
15+
})
1616

1717
app.register(fastifyStatic, {
1818
decorateReply: false,
19-
root: path.join(__dirname, "public"),
20-
prefix: "/",
21-
});
19+
root: path.join(__dirname, 'public'),
20+
prefix: '/',
21+
})
2222

2323
async function mapComponent(path, req, res) {
24-
const appFile = await import("./out/_app.js");
25-
const Component = await import(path);
24+
const appFile = await import('./out/_app.js')
25+
const Component = await import(path)
2626
let pageProps = {
2727
props: {},
28-
};
29-
if ("getServerSideProps" in Component) {
28+
}
29+
if ('getServerSideProps' in Component) {
3030
Object.assign(
3131
pageProps,
3232
await Component.getServerSideProps({
3333
request: req,
3434
response: res,
3535
query: req.query,
3636
})
37-
);
37+
)
3838
}
39-
const mod = "default" in appFile ? appFile.default : appFile;
39+
const mod = 'default' in appFile ? appFile.default : appFile
4040
const FinalComponent = () =>
4141
h(mod, {
4242
Component: Component.default,
4343
pageProps: pageProps.props,
44-
});
45-
const toString = renderToString(h(FinalComponent));
44+
})
45+
const toString = renderToString(h(FinalComponent))
4646
return toString
4747
.replace(
4848
/<\/head\>/,
@@ -51,29 +51,29 @@ async function mapComponent(path, req, res) {
5151
.replace(
5252
/<\/body\>/,
5353
`<script type="module" src="/client/${path.replace(
54-
"./out/",
55-
""
54+
'./out/',
55+
''
5656
)}"></script>
5757
<script type="application/json" id="pageProps">${JSON.stringify(
5858
pageProps.props
5959
)}</script>
6060
</body>`
61-
);
61+
)
6262
}
6363

64-
app.get("/", async (req, res) => {
65-
res.header("content-type", "text/html");
66-
return mapComponent("./out/index.js", req, res);
67-
});
64+
app.get('/', async (req, res) => {
65+
res.header('content-type', 'text/html')
66+
return mapComponent('./out/index.js', req, res)
67+
})
6868

69-
app.get("/devices", async (req, res) => {
70-
res.header("content-type", "text/html");
71-
return mapComponent("./out/devices.js", req, res);
72-
});
69+
app.get('/devices', async (req, res) => {
70+
res.header('content-type', 'text/html')
71+
return mapComponent('./out/devices.js', req, res)
72+
})
7373

74-
app.get("/submit-rom", async (req, res) => {
75-
res.header("content-type", "text/html");
76-
return mapComponent("./out/submit-rom.js", req, res);
77-
});
74+
app.get('/submit-rom', async (req, res) => {
75+
res.header('content-type', 'text/html')
76+
return mapComponent('./out/submit-rom.js', req, res)
77+
})
7878

79-
await app.listen({ host: "0.0.0.0", port: 3000 });
79+
await app.listen({ host: '0.0.0.0', port: 3000 })

0 commit comments

Comments
 (0)