From bacb872a18bc41dc79a38bc6163ec1736505bc07 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Mon, 11 Sep 2023 04:55:15 -0500 Subject: [PATCH] Add /api not implemented controller --- src/app.ts | 4 +++- src/controllers/api/fallback.ts | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app.ts b/src/app.ts index ff57ec0..ef59c8f 100644 --- a/src/app.ts +++ b/src/app.ts @@ -29,7 +29,7 @@ import { verifyCredentialsController, } from './controllers/api/accounts.ts'; import { appCredentialsController, createAppController } from './controllers/api/apps.ts'; -import { emptyArrayController, emptyObjectController } from './controllers/api/fallback.ts'; +import { emptyArrayController, emptyObjectController, notImplementedController } from './controllers/api/fallback.ts'; import { instanceController } from './controllers/api/instance.ts'; import { mediaController } from './controllers/api/media.ts'; import { notificationsController } from './controllers/api/notifications.ts'; @@ -157,6 +157,8 @@ app.get('/api/v1/markers', emptyObjectController); app.get('/api/v1/conversations', emptyArrayController); app.get('/api/v1/lists', emptyArrayController); +app.use('/api/*', notImplementedController); + app.get('*', serveStatic({ root: './public/' })); app.get('*', serveStatic({ path: './public/index.html' })); diff --git a/src/controllers/api/fallback.ts b/src/controllers/api/fallback.ts index c57de7a..b46460e 100644 --- a/src/controllers/api/fallback.ts +++ b/src/controllers/api/fallback.ts @@ -2,5 +2,6 @@ import type { Context } from '@/deps.ts'; const emptyArrayController = (c: Context) => c.json([]); const emptyObjectController = (c: Context) => c.json({}); +const notImplementedController = (c: Context) => Promise.resolve(c.json({ error: 'Not implemented' }, 404)); -export { emptyArrayController, emptyObjectController }; +export { emptyArrayController, emptyObjectController, notImplementedController };