I stumble upon this code snippet while working on fastify.
module.exports = async function (fastify, opts) {
fastify.register(proxy, {
upstream: 'https://news.ycombinator.com/',
async preHandler(request, reply) {
if (request.query.token !== 'abc') {
throw fastify.httpErrors.unauthorized();
}
},
});
};
Looks like it calls fastify.register
with two parameters and the second parameter is an object. The first field is upstream
but I don't get what comes next. What is this syntax after async preHandler(request, reply)...
?