Skip to content

Commit

Permalink
move api routes to top level
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser committed Oct 23, 2024
1 parent 5608069 commit a10ddbd
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import OpenAPIParser from "@readme/openapi-parser"
import algoliasearch from "algoliasearch"
import type { ExpandedDocument, Operation } from "../../../types/openapi"
import type { ExpandedDocument, Operation } from "../../types/openapi"
import path from "path"
import getSectionId from "../../../utils/get-section-id"
import getSectionId from "../../utils/get-section-id"
import { NextResponse } from "next/server"
import { JSDOM } from "jsdom"
import getUrl from "../../../utils/get-url"
import getUrl from "../../utils/get-url"
import { capitalize } from "docs-ui"

export async function GET() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NextResponse } from "next/server"
import path from "path"
import { existsSync } from "fs"
import getSchemaContent from "../../../utils/get-schema-content"
import getSchemaContent from "../../utils/get-schema-content"

export async function GET(request: Request) {
const { searchParams } = new URL(request.url)
Expand Down
File renamed without changes.
6 changes: 2 additions & 4 deletions www/apps/api-reference/components/Tags/Section/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const TagSectionComponent = ({ tag }: TagSectionProps) => {
}>(
loadData && tag["x-associatedSchema"]
? basePathUrl(
`/api/schema?name=${tag["x-associatedSchema"].$ref}&area=${area}`
`/schema?name=${tag["x-associatedSchema"].$ref}&area=${area}`
)
: null,
swrFetcher,
Expand All @@ -81,9 +81,7 @@ const TagSectionComponent = ({ tag }: TagSectionProps) => {
const { data: pathsData } = useSWR<{
paths: PathsObject
}>(
loadData
? basePathUrl(`/api/tag?tagName=${slugTagName}&area=${area}`)
: null,
loadData ? basePathUrl(`/tag?tagName=${slugTagName}&area=${area}`) : null,
swrFetcher,
{
errorRetryInterval: 2000,
Expand Down
2 changes: 1 addition & 1 deletion www/apps/api-reference/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const URL = `${process.env.NEXT_PUBLIC_BASE_URL}${process.env.NEXT_PUBLIC_BASE_P

export async function getBaseSpecs(area: Area) {
try {
const res = await fetch(`${URL}/api/base-specs?area=${area}`, {
const res = await fetch(`${URL}/base-specs?area=${area}`, {
next: {
revalidate: 3000,
tags: [area],
Expand Down
9 changes: 9 additions & 0 deletions www/apps/api-reference/next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ const nextConfig = {
return config
},
transpilePackages: ["docs-ui"],
async redirects() {
return [
{
source: "/api/download/:path",
destination: "/download/:path",
permanent: true,
},
]
},
}

const withMDX = mdx({
Expand Down
2 changes: 1 addition & 1 deletion www/apps/api-reference/vercel.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"crons": [{
"path": "/api/api/algolia",
"path": "/api/algolia",
"schedule": "0 0 * * 4"
}],
"framework": "nextjs",
Expand Down

0 comments on commit a10ddbd

Please sign in to comment.