@tridnguyen/fastify-server
v4.0.2
Published
### Usage
Readme
Simple fastify server
Usage
require("dotenv").config();
const server = require("@tridnguyen/fastify-server")({
auth0Domain: process.env.AUTH0_DOMAIN,
auth0ClientId: process.env.AUTH0_CLIENT_ID,
allowedOrigins: ["https://lab.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.auth0ClientId: string. Required unlessshouldPerformJwtCheckisfalse.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.
