a cache for slack profile pictures and emojis

docs: update tagline

dunkirk.sh e49b5262 25b1a4dd

verified
Changed files
+26 -13
+26 -13
README.md
··· 6 6 </h1> 7 7 8 8 <p align="center"> 9 - <i><b>noun</b> - A mark or quality, as of distinction, individuality, or authenticity.</i> 9 + <i>the slack emoji and profile cache serving the hackclub slack</i> 10 10 </p> 11 11 12 12 <p align="center"> ··· 66 66 67 67 ### Usage 68 68 69 - The 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`. 69 + The 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`. 70 70 71 71 Additionally, you can manually purge a specific user's cache with `POST /users/:user/purge` (requires authentication with a bearer token). 72 72 73 - There are also complete swagger docs available at [`/swagger`](https://cachet.dunkirk.sh/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 ^_^) 73 + There are also complete swagger docs available at [`/swagger`](https://cachet.dunkirk.sh/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 ^\_^) 74 74 75 75 ![Swagger Docs](https://raw.githubusercontent.com/taciturnaxolotl/cachet/master/.github/images/swagger.webp) 76 76 ··· 109 109 }, 110 110 ); 111 111 112 - await cache.insertUser("U062UG485EE", "https://avatars.slack-edge.com/2024-11-30/8105375749571_53898493372773a01a1f_original.jpg", null); 113 - await cache.insertEmoji("hackshark", "https://emoji.slack-edge.com/T0266FRGM/hackshark/0bf4771247471a48.png"); 112 + await cache.insertUser( 113 + "U062UG485EE", 114 + "https://avatars.slack-edge.com/2024-11-30/8105375749571_53898493372773a01a1f_original.jpg", 115 + null, 116 + ); 117 + await cache.insertEmoji( 118 + "hackshark", 119 + "https://emoji.slack-edge.com/T0266FRGM/hackshark/0bf4771247471a48.png", 120 + ); 114 121 115 122 const emoji = await cache.getEmoji("hackshark"); 116 123 const user = await cache.getUser("U062UG485EE"); ··· 123 130 The final bit was at this point a bit of a ridiculous one. I didn't like how heavyweight the `bolt` or `slack-edge` packages were so I rolled my own slack api wrapper. It's again fully typed and designed to be as lightweight as possible. 124 131 125 132 ```typescript 126 - const slack = new Slack(process.env.SLACK_TOKEN, process.env.SLACK_SIGNING_SECRET); 133 + const slack = new Slack( 134 + process.env.SLACK_TOKEN, 135 + process.env.SLACK_SIGNING_SECRET, 136 + ); 127 137 128 138 const user = await slack.getUser("U062UG485EE"); 129 139 const emojis = await slack.getEmoji(); 130 140 131 141 // Manually purge a specific user's cache using the API endpoint 132 - const response = await fetch("https://cachet.example.com/users/U062UG485EE/purge", { 133 - method: "POST", 134 - headers: { 135 - "Authorization": `Bearer ${process.env.BEARER_TOKEN}` 136 - } 137 - }); 142 + const response = await fetch( 143 + "https://cachet.example.com/users/U062UG485EE/purge", 144 + { 145 + method: "POST", 146 + headers: { 147 + Authorization: `Bearer ${process.env.BEARER_TOKEN}`, 148 + }, 149 + }, 150 + ); 138 151 const result = await response.json(); 139 152 // { message: "User cache purged", userId: "U062UG485EE", success: true } 140 153 ``` ··· 157 170 export const myNewMigration: Migration = { 158 171 version: "0.3.2", // Should match package.json version 159 172 description: "What this migration does", 160 - 173 + 161 174 async up(db: Database): Promise<void> { 162 175 // Migration code here 163 176 db.run(`ALTER TABLE my_table ADD COLUMN new_column TEXT`);