Skip to content

Commit

Permalink
Lexicon cleanup:
Browse files Browse the repository at this point in the history
* Removes src/lexicons
* Replaces with imports from respective upstream packages
* Replaces ts-node with tsx, namely because @atproto/bsky doesn't export lexicons
  * See: bluesky-social/atproto#2353
  * Merging bluesky-social/atproto#2354 will allow reverting to ts-node

Fixes bluesky-social#41.
  • Loading branch information
Ændra Rininsland committed Mar 20, 2024
1 parent 1207363 commit 8185d66
Show file tree
Hide file tree
Showing 141 changed files with 923 additions and 16,563 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
"license": "MIT",
"scripts": {
"publishFeed": "ts-node scripts/publishFeedGen.ts",
"start": "ts-node src/index.ts",
"start": "tsx src/index.ts",
"build": "tsc"
},
"dependencies": {
"@atproto/api": "^0.6.20",
"@atproto/bsky": "^0.0.43",
"@atproto/identity": "^0.2.1",
"@atproto/lexicon": "^0.2.2",
"@atproto/lexicon": "^0.2.3",
"@atproto/repo": "^0.3.2",
"@atproto/syntax": "^0.1.2",
"@atproto/xrpc-server": "^0.3.2",
Expand All @@ -28,7 +29,7 @@
"@types/better-sqlite3": "^7.6.4",
"@types/express": "^4.17.17",
"@types/node": "^20.1.2",
"ts-node": "^10.9.1",
"tsx": "^4.7.1",
"typescript": "^5.0.4"
}
}
2 changes: 1 addition & 1 deletion scripts/publishFeedGen.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import dotenv from 'dotenv'
import { AtpAgent, BlobRef } from '@atproto/api'
import fs from 'fs/promises'
import { ids } from '../src/lexicon/lexicons'
import { ids } from '@atproto/bsky/src/lexicon/lexicons'

const run = async () => {
dotenv.config()
Expand Down
10 changes: 5 additions & 5 deletions src/algos/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { AppContext } from '../config'
import {
QueryParams,
OutputSchema as AlgoOutput,
} from '../lexicon/types/app/bsky/feed/getFeedSkeleton'
import { AppBskyFeedGetFeedSkeleton } from '@atproto/api'
import * as whatsAlf from './whats-alf'

type AlgoHandler = (ctx: AppContext, params: QueryParams) => Promise<AlgoOutput>
type AlgoHandler = (
ctx: AppContext,
params: AppBskyFeedGetFeedSkeleton.QueryParams,
) => Promise<AppBskyFeedGetFeedSkeleton.OutputSchema>

const algos: Record<string, AlgoHandler> = {
[whatsAlf.shortname]: whatsAlf.handler,
Expand Down
9 changes: 6 additions & 3 deletions src/algos/whats-alf.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { InvalidRequestError } from '@atproto/xrpc-server'
import { QueryParams } from '../lexicon/types/app/bsky/feed/getFeedSkeleton'
import { AppBskyFeedGetFeedSkeleton } from '@atproto/api'
import { AppContext } from '../config'

// max 15 chars
export const shortname = 'whats-alf'

export const handler = async (ctx: AppContext, params: QueryParams) => {
export const handler = async (
ctx: AppContext,
params: AppBskyFeedGetFeedSkeleton.QueryParams,
) => {
let builder = ctx.db
.selectFrom('post')
.selectAll()
.orderBy('indexedAt', 'desc')
.orderBy('cid', 'desc')
.limit(params.limit)
.limit(params.limit || 50)

if (params.cursor) {
const [indexedAt, cid] = params.cursor.split('::')
Expand Down
Loading

0 comments on commit 8185d66

Please sign in to comment.