fastify.route({ method: ['DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT','OPTIONS'], url: '/v2/*', handler: async function(request, reply){ await mockApiImplementation(request, reply); } });
fastify.addContentTypeParser('application/x-protobuf', function (req, done) { var data = '' req.on('data', chunk => { data += chunk }) req.on('end', () => { done(messages.PushRequest.decode(data)) }) })
fp(async function onResponse (fastify, opts) { fastify.addHook('onResponse', async (request, reply) => { // Notice: the next callback is not available when using async/await // or returning a Promise. If you do invoke a next callback in this // situation unexpected behavior may occur, e.g. duplicate invocation // of handlers. }) // fastify.addHook('onResponse', (request, reply, next) => { // next() // }) })
test('hello is loaded', async (t) => { const app = build(t) const res = await app.inject({ url: '/hello' }) t.equal(res.payload, 'hello, world!') })
/** * * @param message * @param additionalData */ const logInfoDetails = ({ message = '', additionalData = {} }) => { fastify.log.info(message, additionalData); }
fastify.listen(config.api.port, config.api.host, (err, address) => { if (err) { reject(err); } console.log('\n'); console.log(`${chalk.blue('API Started at:')} ${address}`); resolve(); });
test('support works standalone', async (t) => { const fastify = Fastify() fastify.register(Support) await fastify.ready() t.equal(fastify.someSupport(), 'here support') })
test('default root route', async (t) => { const app = build(t) const res = await app.inject({ url: '/' }) t.deepEqual(JSON.parse(res.payload), { root: true }) })
fastify.route({ method: ['DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT','OPTIONS'], url: '/pet*', handler: async function(request, reply){ await mockApiImplementation(request, reply); } });
fp(async function preValidation (fastify, opts) { fastify.addHook('preValidation', async (request, reply) => { // Notice: the next callback is not available when using async/await // or returning a Promise. If you do invoke a next callback in this // situation unexpected behavior may occur, e.g. duplicate invocation // of handlers. }) // fastify.addHook('preValidation', (request, reply, next) => { // next() // }) })
fp(async function preValidation (fastify, opts) { fastify.addHook('preValidation', async (request, reply) => { // Notice: the next callback is not available when using async/await // or returning a Promise. If you do invoke a next callback in this // situation unexpected behavior may occur, e.g. duplicate invocation // of handlers. }) // fastify.addHook('preValidation', (request, reply, next) => { // next() // }) })
fp(async function preParsing (fastify, opts) { fastify.addHook('preParsing', async (request, reply) => { // Notice: the next callback is not available when using async/await // or returning a Promise. If you do invoke a next callback in this // situation unexpected behavior may occur, e.g. duplicate invocation // of handlers. }) // fastify.addHook('preParsing', (request, reply, next) => { // next() // }) })