Narrow pubkey paths with regex
This commit is contained in:
parent
70f69b80f3
commit
07e072bc48
|
@ -17,11 +17,7 @@ const credentialsController: AppController = async (c) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const accountController: AppController = async (c) => {
|
const accountController: AppController = async (c) => {
|
||||||
const pubkey = c.req.param('id');
|
const pubkey = c.req.param('pubkey');
|
||||||
|
|
||||||
if (!isNostrId(pubkey)) {
|
|
||||||
return c.json({ error: 'Invalid account ID.' }, 422);
|
|
||||||
}
|
|
||||||
|
|
||||||
const event = await getAuthor(pubkey);
|
const event = await getAuthor(pubkey);
|
||||||
if (event) {
|
if (event) {
|
||||||
|
@ -72,4 +68,4 @@ const accountSearchController: AppController = async (c) => {
|
||||||
return c.json([]);
|
return c.json([]);
|
||||||
};
|
};
|
||||||
|
|
||||||
export { accountController, accountSearchController, accountLookupController, credentialsController };
|
export { accountController, accountLookupController, accountSearchController, credentialsController };
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
import { type Context, cors, type Handler, Hono, type HonoEnv, type MiddlewareHandler } from '@/deps.ts';
|
import { type Context, cors, type Handler, Hono, type HonoEnv, type MiddlewareHandler } from '@/deps.ts';
|
||||||
|
|
||||||
import { accountController, accountLookupController, accountSearchController, credentialsController } from './api/accounts.ts';
|
import {
|
||||||
|
accountController,
|
||||||
|
accountLookupController,
|
||||||
|
accountSearchController,
|
||||||
|
credentialsController,
|
||||||
|
} from './api/accounts.ts';
|
||||||
import { appCredentialsController, createAppController } from './api/apps.ts';
|
import { appCredentialsController, createAppController } from './api/apps.ts';
|
||||||
import { emptyArrayController, emptyObjectController } from './api/fallback.ts';
|
import { emptyArrayController, emptyObjectController } from './api/fallback.ts';
|
||||||
import homeController from './api/home.ts';
|
import homeController from './api/home.ts';
|
||||||
|
@ -35,7 +40,7 @@ app.post('/oauth/revoke', emptyObjectController);
|
||||||
app.get('/api/v1/accounts/verify_credentials', requireAuth, credentialsController);
|
app.get('/api/v1/accounts/verify_credentials', requireAuth, credentialsController);
|
||||||
app.get('/api/v1/accounts/search', accountSearchController);
|
app.get('/api/v1/accounts/search', accountSearchController);
|
||||||
app.get('/api/v1/accounts/lookup', accountLookupController);
|
app.get('/api/v1/accounts/lookup', accountLookupController);
|
||||||
app.get('/api/v1/accounts/:id', accountController);
|
app.get('/api/v1/accounts/:pubkey{[0-9a-f]{64}}', accountController);
|
||||||
|
|
||||||
app.post('/api/v1/statuses', requireAuth, createStatusController);
|
app.post('/api/v1/statuses', requireAuth, createStatusController);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue