diff options
author | devin ivy <devinivy@gmail.com> | 2024-06-21 12:41:06 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-21 12:41:06 -0400 |
commit | 55812b03940852f1f91cd0a46b5c093601c854a9 (patch) | |
tree | 54956cb522786b1260b0a556f6f7c3ea1b0aed11 /bskylink/src/context.ts | |
parent | ba21fddd7897513fef663b826094878ad0ff1556 (diff) | |
download | voidsky-55812b03940852f1f91cd0a46b5c093601c854a9.tar.zst |
Bsky short link service (#4542)
* bskylink: scaffold service w/ initial config and schema * bskylink: implement link creation and redirects * bskylink: tidy * bskylink: tests * bskylink: tidy, add error handler * bskylink: add dockerfile * bskylink: add build * bskylink: fix some express plumbing * bskyweb: proxy fallthrough routes to link service redirects * bskyweb: build w/ link proxy * Add AASA to bskylink (#4588) --------- Co-authored-by: Hailey <me@haileyok.com>
Diffstat (limited to 'bskylink/src/context.ts')
-rw-r--r-- | bskylink/src/context.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/bskylink/src/context.ts b/bskylink/src/context.ts new file mode 100644 index 000000000..7e6f2f34e --- /dev/null +++ b/bskylink/src/context.ts @@ -0,0 +1,33 @@ +import {Config} from './config.js' +import Database from './db/index.js' + +export type AppContextOptions = { + cfg: Config + db: Database +} + +export class AppContext { + cfg: Config + db: Database + abortController = new AbortController() + + constructor(private opts: AppContextOptions) { + this.cfg = this.opts.cfg + this.db = this.opts.db + } + + static async fromConfig(cfg: Config, overrides?: Partial<AppContextOptions>) { + const db = Database.postgres({ + url: cfg.db.url, + schema: cfg.db.schema, + poolSize: cfg.db.pool.size, + poolMaxUses: cfg.db.pool.maxUses, + poolIdleTimeoutMs: cfg.db.pool.idleTimeoutMs, + }) + return new AppContext({ + cfg, + db, + ...overrides, + }) + } +} |