@tridnguyen/fastify-server
v5.0.0
Published
```js require("dotenv").config();
Downloads
142
Readme
Simple fastify server
Usage
require("dotenv").config();
const server = require("@tridnguyen/fastify-server")({
auth0Domain: "tridnguyen.auth0.com",
audience: "https://example-api.tridnguyen.com",
allowedOrigins: [
"https://subdomain.tridnguyen.com",
"https://tridnguyen.com",
],
shouldPerformJwtCheck: false,
});
server.setErrorHandler((err, request, reply) => {
console.error(err);
reply.send(err);
});
async function start() {
try {
await server.listen(process.env.PORT || 3000, "0.0.0.0");
console.log("Server started");
} catch (err) {
console.error(err);
process.exit(1);
}
}
start();Options
options.logger: boolean. Defaults tofalse.options.ignoreTrailingSlash: boolean. Defaults totrue.options.auth0Domain: string. Required unlessshouldPerformJwtCheckisfalse.options.audience: string. Required unlessshouldPerformJwtCheckisfalse. Should be the Auth0 API identifier (e.g.https://your-api.example.com).options.allowedOrigins: array. Defaults to[].options.shouldPerformJwtCheck: boolean or a function. If a function, it should returntrueif jwt validation is needed,falseotherwise. Default to validate JWT.
