Created
December 15, 2021 05:43
-
-
Save tjmonsi/051864dc2d102c7bc10d630cdfc857ef to your computer and use it in GitHub Desktop.
App JS for fastify
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import stat from 'fastify-static'; | |
import { join, dirname } from 'path'; | |
import { fileURLToPath } from 'url'; | |
import { readFileSync } from 'fs'; | |
// ... | |
app.register(stat, { | |
root: join(dirname(fileURLToPath(import.meta.url)), './public'), | |
preCompressed: true | |
}); | |
app.setNotFoundHandler((_req, res) => res.sendFile('index.html')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment