a cache for slack profile pictures and emojis
1<h1 align="center">
2 <img src="https://raw.githubusercontent.com/taciturnaxolotl/cachet/master/.github/images/cachet.webp" width="200" alt="Logo"/><br/>
3 <img src="https://raw.githubusercontent.com/taciturnaxolotl/carriage/master/.github/images/transparent.png" height="45" width="0px"/>
4 Cachet
5 <img src="https://raw.githubusercontent.com/taciturnaxolotl/carriage/master/.github/images/transparent.png" height="30" width="0px"/>
6</h1>
7
8<p align="center">
9 <i><b>noun</b> - A mark or quality, as of distinction, individuality, or authenticity.</i>
10</p>
11
12<p align="center">
13 <img src="https://raw.githubusercontent.com/taciturnaxolotl/carriage/master/.github/images/line-break-thin.svg" />
14</p>
15
16## What's this?
17
18Cachet is a cache / proxy for profile pictures and emojis on the hackclub slack! I made it because calling the slack api every time you want a profile image or emoji is expensive and annoying. Now you can just call the cachet api and get a link to the image or emoji you want! Best of all we are just linking to slack's cdn so it doesn't cost me much of anything (besides db space) to run!
19
20## How do I use it?
21
22Well first the question is how do I host it lol.
23
24### Hosting
25
26I'm hosting on nest so I just setup a systemd service file that runs `bun run index.ts` in the root dir of this repo. Then I setup caddy to reverse proxy `cachet.dunkirk.sh` to the app.
27
28Your `.env` file should look like this:
29
30```bash
31SLACK_TOKEN=xoxb-123456789012-123456789012-123456789012-123456789012
32SLACK_SIGNING_SECRET=12345678901234567890123456789012
33DATABASE_PATH=/path/to/db.sqlite # Optional
34PORT=3000 # Optional
35```
36
37The slack app can be created from the [`manifest.yaml`](./manifest.yaml) in this repo. It just needs the `emoji:read` and `users:read` scopes.
38
39### Usage
40
41The api is pretty simple. You can get a profile picture by calling `GET /profile/:id` where `:id` is the slack user id. You can get an emoji by calling `GET /emoji/:name` where `:name` is the name of the emoji. You can also get a list of all emojis by calling `GET /emojis`. (WIP - subject to rapid change)
42
43There are also complete swagger docs available at `/swagger`! They are dynamically generated from the code so they should always be up to date! (The types force me to keep them up to date ^_^)
44
45## How does it work?
46
47The app is honestly super simple. It's pretty much just a cache layer on top of the slack api. When you request a profile picture or emoji it first checks the cache. If the image is in the cache it returns the link to the image. If the image is not in the cache it calls the slack api to get the link to image and then stores that in the cache before returning the image link to you!
48
49<p align="center">
50 <img src="https://raw.githubusercontent.com/taciturnaxolotl/carriage/master/.github/images/line-break.svg" />
51</p>
52
53<p align="center">
54 © 2024-present <a href="https://github.com/taciturnaxolotl">Kieran Klukas</a>
55</p>
56
57<p align="center">
58 <a href="https://github.com/taciturnaxolotl/carriage/blob/master/LICENSE.md"><img src="https://img.shields.io/static/v1.svg?style=for-the-badge&label=License&message=AGPL 3.0&logoColor=d9e0ee&colorA=363a4f&colorB=b7bdf8"/></a>
59</p>