mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-16 09:39:09 +00:00
chore: sync from legacy redo
This commit is contained in:
parent
dde05c402e
commit
c4dda617b1
7 changed files with 67 additions and 2 deletions
18
packages/api/handlers/fetch-from-legacy.ts
Normal file
18
packages/api/handlers/fetch-from-legacy.ts
Normal file
|
@ -0,0 +1,18 @@
|
|||
import { respond } from '@roleypoly/api/utils/api-tools';
|
||||
import { asEditor } from '@roleypoly/api/utils/guild';
|
||||
import {
|
||||
fetchLegacyServer,
|
||||
transformLegacyGuild,
|
||||
} from '@roleypoly/api/utils/import-from-legacy';
|
||||
import { notFound } from '@roleypoly/api/utils/responses';
|
||||
|
||||
export const FetchFromLegacy = asEditor({}, (session, { guildID }) => async () => {
|
||||
const legacyGuild = await fetchLegacyServer(guildID);
|
||||
if (!legacyGuild) {
|
||||
return notFound();
|
||||
}
|
||||
|
||||
const transformedGuild = transformLegacyGuild(legacyGuild);
|
||||
|
||||
return respond(transformedGuild);
|
||||
});
|
|
@ -1,5 +1,6 @@
|
|||
import { BotJoin } from './handlers/bot-join';
|
||||
import { ClearGuildCache } from './handlers/clear-guild-cache';
|
||||
import { FetchFromLegacy } from './handlers/fetch-from-legacy';
|
||||
import { GetPickerData } from './handlers/get-picker-data';
|
||||
import { GetSession } from './handlers/get-session';
|
||||
import { GetSlug } from './handlers/get-slug';
|
||||
|
@ -29,9 +30,12 @@ router.add('GET', 'get-slug', GetSlug);
|
|||
router.add('GET', 'get-picker-data', GetPickerData);
|
||||
router.add('PATCH', 'update-roles', UpdateRoles);
|
||||
router.add('PATCH', 'update-guild', UpdateGuild);
|
||||
router.add('POST', 'sync-from-legacy', SyncFromLegacy);
|
||||
router.add('POST', 'clear-guild-cache', ClearGuildCache);
|
||||
|
||||
// Legacy sync stuff
|
||||
router.add('POST', 'sync-from-legacy', SyncFromLegacy);
|
||||
router.add('GET', 'fetch-from-legacy', FetchFromLegacy);
|
||||
|
||||
// Tester Routes
|
||||
router.add('GET', 'x-headers', (request) => {
|
||||
const headers: { [x: string]: string } = {};
|
||||
|
|
|
@ -168,7 +168,9 @@ export const getGuildData = async (id: string): Promise<GuildDataT> => {
|
|||
};
|
||||
|
||||
if (!guildData) {
|
||||
return empty;
|
||||
return {
|
||||
...empty,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue