minecraft-docker/src/link/get.ts

10 lines
346 B
TypeScript

import { FastifyInstance } from 'fastify';
export default async (server: FastifyInstance) =>
server.get<{ Params: { id: string } }>('/:id', (req, reply) =>
server.db.link
.findFirstOrThrow({ where: { id: req.params.id } })
.then(link => reply.redirect(link.link))
.catch(() => reply.code(404).send('URL not found'))
);