Open twn39 opened 2 years ago
配置:
const indexTemplate = readFileSync(assetsPath + '/index.html', {encoding: 'utf-8'}); let compiled = Handlebars.compile(indexTemplate); const indexHandler = async (request: FastifyRequest, reply: FastifyReply) => { let indexHtml = await app.ioredis.get('index.html'); if (indexHtml == null) { indexHtml = compiled({env: process.env['APP_ENV']}); await app.ioredis.setex('index.html', 300, indexHtml); } return reply.type('text/html').send(indexHtml); } app.get('/', indexHandler); app.setNotFoundHandler(indexHandler);
配置: