{"id":31137699,"url":"https://github.com/itshivams/slack-connect-backend","last_synced_at":"2026-05-09T05:33:50.475Z","repository":{"id":313504395,"uuid":"1033638571","full_name":"itshivams/Slack-Connect-Backend","owner":"itshivams","description":"A lightweight Node.js (TypeScript) backend that powers Slack Connect, a demo application that lets users - connect, send messages and schedule.","archived":false,"fork":false,"pushed_at":"2025-08-07T06:04:15.000Z","size":28,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-12T16:29:40.092Z","etag":null,"topics":["express","slack"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/itshivams.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-08-07T06:02:37.000Z","updated_at":"2025-08-30T09:20:33.000Z","dependencies_parsed_at":"2025-09-06T14:55:52.144Z","dependency_job_id":"5f182d8d-ebe4-4d8c-8267-e7aa6c7b70d1","html_url":"https://github.com/itshivams/Slack-Connect-Backend","commit_stats":null,"previous_names":["itshivams/slack-connect-backend"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/itshivams/Slack-Connect-Backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itshivams%2FSlack-Connect-Backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itshivams%2FSlack-Connect-Backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itshivams%2FSlack-Connect-Backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itshivams%2FSlack-Connect-Backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/itshivams","download_url":"https://codeload.github.com/itshivams/Slack-Connect-Backend/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/itshivams%2FSlack-Connect-Backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32808498,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T08:22:46.396Z","status":"online","status_checked_at":"2026-05-09T02:00:06.633Z","response_time":123,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["express","slack"],"created_at":"2025-09-18T09:35:33.072Z","updated_at":"2026-05-09T05:33:50.460Z","avatar_url":"https://github.com/itshivams.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Slack Connect Backend\n\nA lightweight Node.js (TypeScript) backend that powers **Slack Connect**, a demo application that lets users:\n\n* Connect their Slack workspace via OAuth 2.0\n* Send messages to any channel instantly\n* Schedule messages for the future and manage (list/cancel) them\n* Reliably deliver scheduled messages even after restarts\n\n\u003e **Tech stack:** Node.js · Express · TypeScript · LowDB (JSON) · node‑schedule · Axios · dotenv\n\n---\n\n## ✨ Architecture Overview\n\n```\n┌─────────────┐     OAuth               ┌──────────────┐\n│ Front‑end   │ ────────────►          │   Slack API  │\n└─────────────┘  auth code \u0026 tokens     └──────────────┘\n        ▲                                   ▲\n        │ REST (/messages/*)                │ chat.postMessage\n        │                                   │\n┌──────────────────────────────┐            │\n│  Express API (this project)  │◄───────────┘\n│  • /auth/slack               │\n│  • /messages/send            │\n│  • /messages/schedule        │\n│  • /messages/scheduled       │\n│                              │\n│  Token store \u0026 Scheduler     │\n│  ─────────────────────────   │\n│  • LowDB (db.json)           │\n│  • node‑schedule jobs        │\n└──────────────────────────────┘\n```\n\n* **OAuth 2.0 Flow** – `/auth/slack` redirects the user to Slack’s consent page.  \n  On callback, we exchange the code for `access_token` (and optionally `refresh_token`).  \n  Tokens are stored per team and automatically refreshed when close to expiry.\n\n* **Persistence** – LowDB writes a simple `db.json` file that holds `tokens[]` and `messages[]`.  \n  This keeps the demo dependency‑free (no external DB). Swap‑in Mongo/SQL easily.\n\n* **Scheduling** – On startup we scan pending messages and register one‑off `node‑schedule` jobs.  \n  Each job refreshes the team’s token (if needed) and calls Slack `chat.postMessage`.  \n  Cancelling simply marks the message `cancelled` and aborts the job.\n\n---\n\n## 🚀 Quick Start\n\n1. **Clone**\n\n```bash\ngit clone https://github.com/itshivams/slack-connect-backend.git\ncd slack-connect-backend\n```\n\n2. **Install**\n\n```bash\nnpm install\n```\n\n3. **Configure**\n\nCopy `.env.example` to `.env` and fill in your Slack credentials:\n\n```\nSLACK_CLIENT_ID=...\nSLACK_CLIENT_SECRET=...\nSLACK_SIGNING_SECRET=...\nBASE_URL=http://localhost:4000\nPORT=4000\n```\n\nCreate a Slack **App** → **OAuth \u0026 Permissions**  \n*Redirect URL:* `http://localhost:4000/auth/slack/callback`\n\n4. **Run**\n\n```bash\nnpm run dev      # nodemon + ts-node\n```\n\nServer logs:\n\n```\n2025‑08‑07T09:32:10Z [app] Server listening on port 4000\n```\n\n---\n\n## 🛠️ API Reference\n\n| Method | Endpoint | Body / Query | Description |\n| ------ | -------- | ------------ | ----------- |\n| `GET`  | `/auth/slack` | — | Redirects to Slack OAuth 2.0 consent |\n| `GET`  | `/auth/slack/callback` | `?code=` | Handles OAuth, saves tokens |\n| `POST` | `/messages/send` | `{ teamId, channel, text }` | Send message immediately |\n| `POST` | `/messages/schedule` | `{ teamId, channel, text, sendAt }` | Schedule UNIX epoch ms |\n| `GET`  | `/messages/scheduled` | — | List all scheduled jobs |\n| `DELETE`| `/messages/scheduled/:id` | — | Cancel a pending job |\n\n---\n\n## 🧩 Folder Structure\n\n```\nsrc/\n  routes/         Express route handlers\n  services/       Slack API, scheduler, token logic\n  utils/          Logger, helpers\n  db.ts           LowDB wrapper\n  index.ts        App entrypoint\n```\n\n---\n\n## 🧑‍💻 Dev Scripts\n\n| Command | Description |\n| ------- | ----------- |\n| `npm run dev` | Start in watch mode (ts-node-dev) |\n| `npm run build` | Compile TypeScript to `dist/` |\n| `npm start` | Run compiled JS |\n\n---\n\n## 📚 Challenges \u0026 Learnings\n\n* **Token longevity** – Slack’s classic tokens never expire, but granular‑scoped apps can.  \n  Implemented generic refresh flow that will gracefully no‑op when `expires_in` is absent.\n\n* **Job resilience** – Node process restarts wipe in‑memory timers.  \n  Persisted jobs in DB and re‑hydrate at boot to guarantee delivery.\n\n* **Minimalism vs. Scalability** – Chose LowDB + node‑schedule to keep the demo single‑file \u0026 docker‑friendly.  \n  For production, swap in PostgreSQL + BullMQ/Redis for at‑least‑once delivery and retries.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitshivams%2Fslack-connect-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitshivams%2Fslack-connect-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitshivams%2Fslack-connect-backend/lists"}