feat(api): deprecate v1 endpoints

This commit is contained in:
wanhose 2024-08-03 12:57:48 +02:00
parent c230bf1c4d
commit fd5ad33219
2 changed files with 16 additions and 35 deletions

View File

@ -1,17 +1,14 @@
import { FastifyInstance, RouteShorthandOptions } from 'fastify'; import { FastifyInstance, RouteShorthandOptions } from 'fastify';
import fetch from 'node-fetch';
/**
* @deprecated This API route is no longer supported. Please use a newer version
*/
export default (server: FastifyInstance, options: RouteShorthandOptions, done: () => void) => { export default (server: FastifyInstance, options: RouteShorthandOptions, done: () => void) => {
server.get('/entries/', async (request, reply) => { server.get('/entries/', async (request, reply) => {
try { reply.send({
const repositoryUrl = 'https://raw.githubusercontent.com/wanhose/cookie-dialog-monster/main'; success: false,
const dataUrl = `${repositoryUrl}/data/elements.txt`; errors: ['This API route is no longer supported. Please use a newer version'],
const entriesLength = (await (await fetch(dataUrl)).text()).split('\n').length; });
reply.send({ entries: entriesLength, success: true });
} catch {
reply.send({ success: false });
}
}); });
done(); done();

View File

@ -1,31 +1,15 @@
import { FastifyInstance, RouteShorthandOptions } from 'fastify'; import { FastifyInstance, RouteShorthandOptions } from 'fastify';
type PostReportBody = { /**
html?: string; * @deprecated This API route is no longer supported. Please use a newer version
subject: string; */
text?: string;
to: string;
};
export default (server: FastifyInstance, options: RouteShorthandOptions, done: () => void) => { export default (server: FastifyInstance, options: RouteShorthandOptions, done: () => void) => {
server.post<{ Body: PostReportBody }>( server.post('/report/', {}, async (_request, reply) => {
'/report/', reply.send({
{
schema: {
body: {
properties: {},
required: [],
type: 'object',
},
},
},
async (_request, reply) => {
reply.status(500).send({
success: false, success: false,
errors: ['This API route is no longer supported. Please upgrade to the latest version'], errors: ['This API route is no longer supported. Please use a newer version'],
});
}); });
}
);
done(); done();
}; };