Skip to content
← Public packages

@kentcdodds/x

X API v2 helpers for tweets, search, legacy DMs, and encrypted X Chat via a Fly XDK sidecar.

src/owner-config.ts

60 lines · 1.8 KB · TypeScript
/**
 * Owner-specific defaults for this copy of the X package.
 *
 * After a community fork this is the file to edit — or skip the edit and set
 * the named value / secrets instead. Call `./adapt` for the full swap list.
 *
 * Do not put secrets here. The Chat PIN and sidecar bearer stay in user secrets.
 */

/** Fly app name in `sidecar/fly.toml`. Forks must use an app they own. */
export const FLY_APP_NAME = 'kody-x-chat'

export const FLY_PRIMARY_REGION = 'sjc'

/** Fallback sidecar origin when `sidecarUrl` and package storage `xChatSidecarUrl` are unset. */
export const DEFAULT_SIDECAR_URL = 'https://kody-x-chat.fly.dev'

export const SIDECAR_HOST = 'kody-x-chat.fly.dev'

/** Package storage key: your Fly sidecar origin. Set this after a fork instead of editing code. */
export const SIDECAR_URL_VALUE = 'xChatSidecarUrl'

/** User secret: existing x.com Chat PIN. Never generate a new Chat keypair. */
export const CHAT_PIN_SECRET = 'xChatPin'

/** User secret: shared bearer for the Fly sidecar (`SIDECAR_TOKEN` on the machine). */
export const SIDECAR_TOKEN_SECRET = 'xChatSidecarToken'

/** Default OAuth integration. Extra accounts are `x-<purpose>`. */
export const DEFAULT_OAUTH_INTEGRATION = 'x'

export function buildFlyToml(appName = FLY_APP_NAME, region = FLY_PRIMARY_REGION) {
	return `# Forks: change \`app\` to a Fly app you own, then store ${SIDECAR_URL_VALUE}
# to https://<app>.fly.dev (or call kody:@scope/x/adapt).
app = "${appName}"
primary_region = "${region}"

[build]
  dockerfile = "Dockerfile"

[env]
  PORT = "8080"

[http_service]
  internal_port = 8080
  force_https = true
  auto_stop_machines = "off"
  auto_start_machines = true
  min_machines_running = 1

[[vm]]
  size = "shared-cpu-1x"
  memory = "512mb"
  cpus = 1
`
}

export function sidecarUrlFromApp(appName: string) {
	return `https://${appName}.fly.dev`
}