-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
338d8ae
commit 5cd584b
Showing
8 changed files
with
124 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Elysia, t } from "elysia" | ||
import { botBannerBucket, guildedBotProfileScrape, streamToBuffer } from "../libs" | ||
|
||
export const botBannerController = new Elysia() | ||
.get('/:id', async ({ params }) => { | ||
if (await botBannerBucket.checkAssetExists(params.id)) { | ||
const lastModified = await botBannerBucket.getAssetLastModified(params.id) | ||
if (Date.now() - lastModified.valueOf() > 24 * 60 * 60 * 1000) { | ||
(async () => guildedBotProfileScrape(params.id, 'banner'))().catch((e) => console.error(e)) | ||
} | ||
const banner = await botBannerBucket.getAsset(params.id) | ||
return new Response(await streamToBuffer(banner), { headers: { 'Content-Type': 'image/webp' } }) | ||
} | ||
const imageBlob = await guildedBotProfileScrape(params.id, 'banner') | ||
if (imageBlob instanceof Error || !imageBlob) { | ||
return new Response('Bot not found', { status: 404 }) | ||
} | ||
return new Response(imageBlob, { headers: { 'Content-Type': 'image/webp' } }) | ||
}, { | ||
params: t.Object({ | ||
id: t.String() | ||
}), | ||
body: t.Undefined(), | ||
response: t.Object({ | ||
body: t.File({ | ||
type: 'image/webp', | ||
maxItems: 1, | ||
minItems: 0, | ||
maxSize: '10m', | ||
minSize: '0k' | ||
}), | ||
}, | ||
{description: 'The bot banner image.'}), | ||
detail: { | ||
description: 'Get the banner of a bot by its ID.', | ||
summary: 'Get bot banner by ID.', | ||
tags: ['bot'], | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Elysia, t } from "elysia" | ||
import { botIconBucket, guildedBotProfileScrape, streamToBuffer } from "../libs" | ||
|
||
export const botIconController = new Elysia() | ||
.get('/:id', async ({ params }) => { | ||
if (await botIconBucket.checkAssetExists(params.id)) { | ||
const lastModified = await botIconBucket.getAssetLastModified(params.id) | ||
if (Date.now() - lastModified.valueOf() > 24 * 60 * 60 * 1000) { | ||
(async () => guildedBotProfileScrape(params.id, 'icon'))().catch((e) => console.error(e)) | ||
} | ||
const avatar = await botIconBucket.getAsset(params.id) | ||
const res = new Response(await streamToBuffer(avatar), { headers: { 'Content-Type': 'image/webp' } }) | ||
return res | ||
} | ||
const imageBlob = await guildedBotProfileScrape(params.id, 'icon') | ||
if (imageBlob instanceof Error || !imageBlob) { | ||
return new Response('Bot not found', { status: 404 }) | ||
} | ||
const res = new Response(imageBlob, { headers: { 'Content-Type': 'image/webp' } }) | ||
return res | ||
}, { | ||
params: t.Object({ | ||
id: t.String() | ||
}), | ||
body: t.Undefined(), | ||
response: t.Object({ | ||
body: t.File({ | ||
type: 'image/webp', | ||
maxItems: 1, | ||
minItems: 0, | ||
maxSize: '10m', | ||
minSize: '0k' | ||
}), | ||
}, | ||
{description: 'The bot icon image.'}), | ||
detail: { | ||
description: "Get the bot icon of a bot by it's ID.", | ||
summary: 'Get bot icon by ID.', | ||
tags: ['bot'], | ||
} | ||
}) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
export * from './user-avatar.controller' | ||
export * from './user-banner.controller' | ||
export * from './server-icon.controller' | ||
export * from './server-banner.controller' | ||
export * from './server-banner.controller' | ||
export * from './bot-icon.controller' | ||
export * from './bot-banner.controller' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters