From fd5ad33219edeb689f0b4d40f8c7d27e6cfd8956 Mon Sep 17 00:00:00 2001 From: wanhose Date: Sat, 3 Aug 2024 12:57:48 +0200 Subject: [PATCH] feat(api): deprecate v1 endpoints --- packages/api/src/routes/v1/entries.ts | 17 ++++++-------- packages/api/src/routes/v1/report.ts | 34 +++++++-------------------- 2 files changed, 16 insertions(+), 35 deletions(-) diff --git a/packages/api/src/routes/v1/entries.ts b/packages/api/src/routes/v1/entries.ts index dc0ccb2..24f7d38 100644 --- a/packages/api/src/routes/v1/entries.ts +++ b/packages/api/src/routes/v1/entries.ts @@ -1,17 +1,14 @@ 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) => { server.get('/entries/', async (request, reply) => { - try { - const repositoryUrl = 'https://raw.githubusercontent.com/wanhose/cookie-dialog-monster/main'; - const dataUrl = `${repositoryUrl}/data/elements.txt`; - const entriesLength = (await (await fetch(dataUrl)).text()).split('\n').length; - - reply.send({ entries: entriesLength, success: true }); - } catch { - reply.send({ success: false }); - } + reply.send({ + success: false, + errors: ['This API route is no longer supported. Please use a newer version'], + }); }); done(); diff --git a/packages/api/src/routes/v1/report.ts b/packages/api/src/routes/v1/report.ts index 9b67c7f..4bedb23 100644 --- a/packages/api/src/routes/v1/report.ts +++ b/packages/api/src/routes/v1/report.ts @@ -1,31 +1,15 @@ import { FastifyInstance, RouteShorthandOptions } from 'fastify'; -type PostReportBody = { - html?: string; - subject: string; - text?: string; - to: string; -}; - +/** + * @deprecated This API route is no longer supported. Please use a newer version + */ export default (server: FastifyInstance, options: RouteShorthandOptions, done: () => void) => { - server.post<{ Body: PostReportBody }>( - '/report/', - { - schema: { - body: { - properties: {}, - required: [], - type: 'object', - }, - }, - }, - async (_request, reply) => { - reply.status(500).send({ - success: false, - errors: ['This API route is no longer supported. Please upgrade to the latest version'], - }); - } - ); + server.post('/report/', {}, async (_request, reply) => { + reply.send({ + success: false, + errors: ['This API route is no longer supported. Please use a newer version'], + }); + }); done(); };