Add boilerplate accounts controller and fallback controller

This commit is contained in:
Alex Gleason 2023-03-04 21:49:33 -06:00
parent b36b8ea7d2
commit 7285d71bda
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
4 changed files with 25 additions and 4 deletions

7
src/api/accounts.ts Normal file
View File

@ -0,0 +1,7 @@
import type { Context } from '@/deps.ts';
function credentialsController(c: Context) {
return c.json({});
}
export { credentialsController };

View File

@ -14,8 +14,8 @@ function createAppController(c: Context) {
return c.json(FAKE_APP); return c.json(FAKE_APP);
} }
function appVerifyCredentials(c: Context) { function appCredentialsController(c: Context) {
return c.json(FAKE_APP); return c.json(FAKE_APP);
} }
export { appVerifyCredentials, createAppController }; export { appCredentialsController, createAppController };

5
src/api/fallback.ts Normal file
View File

@ -0,0 +1,5 @@
import type { Context } from '@/deps.ts';
const emptyArrayController = (c: Context) => c.json([]);
export { emptyArrayController };

View File

@ -1,6 +1,8 @@
import { Hono } from '@/deps.ts'; import { Hono } from '@/deps.ts';
import { appVerifyCredentials, createAppController } from './api/apps.ts'; import { credentialsController } from './api/accounts.ts';
import { appCredentialsController, createAppController } from './api/apps.ts';
import { emptyArrayController } from './api/fallback.ts';
import instanceController from './api/instance.ts'; import instanceController from './api/instance.ts';
import { createTokenController } from './api/oauth.ts'; import { createTokenController } from './api/oauth.ts';
@ -8,9 +10,16 @@ const app = new Hono();
app.get('/api/v1/instance', instanceController); app.get('/api/v1/instance', instanceController);
app.get('/api/v1/apps/verify_credentials', appVerifyCredentials); app.get('/api/v1/apps/verify_credentials', appCredentialsController);
app.post('/api/v1/apps', createAppController); app.post('/api/v1/apps', createAppController);
app.post('/oauth/token', createTokenController); app.post('/oauth/token', createTokenController);
app.get('/api/v1/accounts/verify_credentials', credentialsController);
// Not (yet) implemented.
app.get('/api/v1/timelines/*', emptyArrayController);
app.get('/api/v1/accounts/:id/statuses', emptyArrayController);
app.get('/api/v1/bookmarks', emptyArrayController);
export default app; export default app;