fix(bsky): api

This commit is contained in:
DIYgod 2025-06-17 19:35:43 +08:00
parent 94160fa0f4
commit 63ceeecce2
No known key found for this signature in database
2 changed files with 2 additions and 24 deletions

View File

@ -415,9 +415,6 @@ export type Config = {
smzdm: {
cookie?: string;
};
bsky: {
authorization?: string;
};
};
const value: Config | Record<string, any> = {};
@ -873,9 +870,6 @@ const calculateValue = () => {
smzdm: {
cookie: envs.SMZDM_COOKIE,
},
bsky: {
authorization: envs.BSKY_AUTHORIZATION,
},
};
for (const name in _value) {

View File

@ -1,5 +1,3 @@
import { config } from '@/config';
import ConfigNotFoundError from '@/errors/types/config-not-found';
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
@ -9,13 +7,7 @@ export const route: Route = {
example: '/bsky/keyword/hello',
parameters: { keyword: 'N' },
features: {
requireConfig: [
{
name: 'BSKY_AUTHORIZATION',
description: 'The authorization token for the Bluesky API',
optional: false,
},
],
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
@ -28,17 +20,9 @@ export const route: Route = {
};
async function handler(ctx) {
if (!config.bsky.authorization) {
throw new ConfigNotFoundError('BSKY_AUTHORIZATION is not set');
}
const keyword = ctx.req.param('keyword');
const data = await ofetch(`https://stinkhorn.us-west.host.bsky.network/xrpc/app.bsky.feed.searchPosts?q=${encodeURIComponent(keyword)}&limit=25&sort=latest`, {
headers: {
Authorization: `Bearer ${config.bsky.authorization}`,
},
});
const data = await ofetch(`https://api.bsky.app/xrpc/app.bsky.feed.searchPosts?q=${encodeURIComponent(keyword)}&limit=25&sort=latest`);
const items = data.posts.map((post) => ({
title: post.record.text,