sendcode
Version:
Send the generated code to the given phone number with any SMS sending service
40 lines (29 loc) • 995 B
JavaScript
const path = require('path')
const AutoLoad = require('@fastify/autoload')
const {swaggerSchema, swaggerUISchema} = require('./schema/swaggerSchema')
const fastifyJwt = require('@fastify/jwt/jwt')
module.exports.options = {}
module.exports = async function (fastify, opts) {
fastify.register(require('@fastify/jwt'), {
secret: 'supersecret'
})
fastify.decorate('authentication', async (req, reply) => {
try{
await req.jwtVerify()
}catch (err) {
reply.send(err)
}
})
await fastify.register(require('@fastify/swagger'), {swagger: swaggerSchema})
await fastify.register(require('@fastify/swagger-ui'), swaggerUISchema)
fastify.register(require('@fastify/redis'))
fastify.register(AutoLoad, {
dir: path.join(__dirname, 'plugins'),
options: Object.assign({}, opts)
})
fastify.register(AutoLoad, {
dir: path.join(__dirname, 'routes'),
options: Object.assign({}, opts)
})
}