mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-17 09:59:10 +00:00
miniflare init
This commit is contained in:
parent
8c07ed3123
commit
688954a2e0
52 changed files with 898 additions and 25 deletions
23
packages/api/old-src/handlers/sync-from-legacy.ts
Normal file
23
packages/api/old-src/handlers/sync-from-legacy.ts
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { asEditor, GuildRateLimiterKey } from '../utils/guild';
|
||||
import { fetchLegacyServer, transformLegacyGuild } from '../utils/import-from-legacy';
|
||||
import { GuildData } from '../utils/kv';
|
||||
import { notFound, ok } from '../utils/responses';
|
||||
|
||||
export const SyncFromLegacy = asEditor(
|
||||
{
|
||||
rateLimitKey: GuildRateLimiterKey.legacyImport,
|
||||
rateLimitTimeoutSeconds: 60 * 20,
|
||||
},
|
||||
(session, { guildID }) =>
|
||||
async (request: Request): Promise<Response> => {
|
||||
const legacyGuild = await fetchLegacyServer(guildID);
|
||||
if (!legacyGuild) {
|
||||
return notFound();
|
||||
}
|
||||
|
||||
const newGuildData = transformLegacyGuild(legacyGuild);
|
||||
await GuildData.put(guildID, newGuildData);
|
||||
|
||||
return ok();
|
||||
}
|
||||
);
|
Loading…
Add table
Add a link
Reference in a new issue