Skip to content

Commit

Permalink
fix(website): edge-config fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
iCrawl committed Apr 2, 2023
1 parent 6aba9e9 commit 0645bf0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
36 changes: 19 additions & 17 deletions apps/website/src/app/api/cron/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,26 @@ import type { ServerRuntime } from 'next/types';
export const runtime: ServerRuntime = 'edge';

export async function GET() {
const url = await get<string>('DISCORD_WEBHOOK_URL');
const imageUrl = await get<string>('IT_IS_WEDNESDAY_MY_DUDES');
if (url && imageUrl) {
await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
username: 'It is wednesday, my dudes',
embeds: [
{
image: {
url: imageUrl,
try {
const url = await get<string>('DISCORD_WEBHOOK_URL');
const imageUrl = await get<string>('IT_IS_WEDNESDAY_MY_DUDES');
if (url && imageUrl) {
await fetch(url, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
username: 'It is wednesday, my dudes',
embeds: [
{
image: {
url: imageUrl,
},
},
},
],
}),
});
}
],
}),
});
}
} catch {}

return NextResponse.json({ message: 'It is wednesday, my dudes' });
}
12 changes: 7 additions & 5 deletions apps/website/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ async function fetchLatestVersion(packageName: string) {

export default async function middleware(request: NextRequest) {
if (request.nextUrl.pathname === '/docs') {
const skip = await get<boolean>('SKIP_PACKAGE_VERSION_SELECTION');
if (skip) {
const latestVersion = await fetchLatestVersion('builders');
return NextResponse.redirect(new URL(`/docs/packages/builders/${latestVersion}`, request.url));
}
try {
const skip = await get<boolean>('SKIP_PACKAGE_VERSION_SELECTION');
if (skip) {
const latestVersion = await fetchLatestVersion('builders');
return NextResponse.redirect(new URL(`/docs/packages/builders/${latestVersion}`, request.url));
}
} catch {}
}

if (request.nextUrl.pathname.includes('discord.js')) {
Expand Down

1 comment on commit 0645bf0

@vercel
Copy link

@vercel vercel bot commented on 0645bf0 Apr 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.