..
Viewing
key.ts
24 lines (20 loc) • 816.0 B
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 | import axios from 'axios';
import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify';
class ZoroKey {
getKey = async (fastify: FastifyInstance, options: RegisterOptions) => {
fastify.get('/key/:keyID', async (request: FastifyRequest, reply: FastifyReply) => {
const keyID = parseInt((request.params as { keyID: string }).keyID);
if (keyID !== 4 && keyID !== 6)
return reply.status(400).send({ message: 'keyID can either be 4 or 6.' });
try {
const { data } = await axios.get(`http://9anime.to/key/e${keyID}.txt`);
reply.status(200).send(data);
} catch (err) {
reply
.status(500)
.send({ message: 'Something went wrong. Contact developer for help.' });
}
});
};
}
export default ZoroKey;
|
|