fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma strängvärde byggs med konkatenering i stället för att matcha mönstret.
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { ANSLUT_CLAUDE_MD } from '@/lib/docs/content/anslut-claude'
|
||||
import { withPublicSecurityHeaders } from '@/lib/api/v1/security-headers'
|
||||
|
||||
export async function GET() {
|
||||
return new NextResponse(ANSLUT_CLAUDE_MD, {
|
||||
status: 200,
|
||||
headers: withPublicSecurityHeaders({
|
||||
'Content-Type': 'text/markdown; charset=utf-8',
|
||||
'Cache-Control': 'public, max-age=300, s-maxage=300',
|
||||
}),
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { Metadata } from 'next'
|
||||
import { DocsLayout } from '@/components/docs/DocsLayout'
|
||||
import { DocsMarkdown } from '@/lib/docs/markdown'
|
||||
import { ANSLUT_CLAUDE_MD } from '@/lib/docs/content/anslut-claude'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Anslut Claude · accounted API',
|
||||
description:
|
||||
'Koppla Accounted till Claude (claude.ai, Claude Desktop, Claude Code) via MCP-servern: OAuth 2.1-connector, Claude Code-plugin eller npx accounted-mcp.',
|
||||
}
|
||||
|
||||
export default function DocsApiAnslutClaudePage() {
|
||||
return (
|
||||
<DocsLayout currentPath="/docs/api/anslut-claude">
|
||||
<DocsMarkdown source={ANSLUT_CLAUDE_MD} />
|
||||
</DocsLayout>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { CHANGELOG_MD } from '@/lib/docs/content/changelog'
|
||||
import { withPublicSecurityHeaders } from '@/lib/api/v1/security-headers'
|
||||
|
||||
export async function GET() {
|
||||
return new NextResponse(CHANGELOG_MD, {
|
||||
status: 200,
|
||||
headers: withPublicSecurityHeaders({
|
||||
'Content-Type': 'text/markdown; charset=utf-8',
|
||||
'Cache-Control': 'public, max-age=300, s-maxage=300',
|
||||
}),
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import type { Metadata } from 'next'
|
||||
import { DocsLayout } from '@/components/docs/DocsLayout'
|
||||
import { DocsMarkdown } from '@/lib/docs/markdown'
|
||||
import { CHANGELOG_MD } from '@/lib/docs/content/changelog'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Changelog · accounted API',
|
||||
description: 'Reverse-chronological release notes for the accounted REST API.',
|
||||
}
|
||||
|
||||
export default function DocsApiChangelogPage() {
|
||||
return (
|
||||
<DocsLayout currentPath="/docs/api/changelog">
|
||||
<DocsMarkdown source={CHANGELOG_MD} />
|
||||
</DocsLayout>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { CONNECT_CLAUDE_MD } from '@/lib/docs/content/connect-claude'
|
||||
import { withPublicSecurityHeaders } from '@/lib/api/v1/security-headers'
|
||||
|
||||
export async function GET() {
|
||||
return new NextResponse(CONNECT_CLAUDE_MD, {
|
||||
status: 200,
|
||||
headers: withPublicSecurityHeaders({
|
||||
'Content-Type': 'text/markdown; charset=utf-8',
|
||||
'Cache-Control': 'public, max-age=300, s-maxage=300',
|
||||
}),
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { Metadata } from 'next'
|
||||
import { DocsLayout } from '@/components/docs/DocsLayout'
|
||||
import { DocsMarkdown } from '@/lib/docs/markdown'
|
||||
import { CONNECT_CLAUDE_MD } from '@/lib/docs/content/connect-claude'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Connect with Claude · accounted API',
|
||||
description:
|
||||
'Connect Accounted to Claude (claude.ai, Claude Desktop, Claude Code) via the MCP server: OAuth 2.1 connector or the npx accounted-mcp stdio bridge.',
|
||||
}
|
||||
|
||||
export default function DocsApiConnectClaudePage() {
|
||||
return (
|
||||
<DocsLayout currentPath="/docs/api/connect-claude">
|
||||
<DocsMarkdown source={CONNECT_CLAUDE_MD} />
|
||||
</DocsLayout>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { findRecipe, buildPlaceholderMd, COOKBOOK_SLUGS } from '@/lib/docs/content/cookbook'
|
||||
import { withPublicSecurityHeaders } from '@/lib/api/v1/security-headers'
|
||||
|
||||
// Pre-validate the slug against the closed allow-list before any lookup
|
||||
// runs. Defense-in-depth (V1.2.5): findRecipe is dictionary-based so the
|
||||
// raw value can't reach SQL or filesystem code paths, but if the lookup
|
||||
// is ever swapped (e.g. dynamic file load) the explicit allow-list
|
||||
// gate keeps the contract safe by construction.
|
||||
const SLUG_ALLOW = new Set<string>(COOKBOOK_SLUGS)
|
||||
|
||||
// Next.js 16 does not extract the dynamic segment name from a directory
|
||||
// like `[slug].md/`: the literal `.md` suffix breaks the inference and
|
||||
// the framework types `params` as `{}`. Workaround: parse the slug from
|
||||
// request.url.pathname directly. Routing still works (Next.js still
|
||||
// matches /docs/api/cookbook/foo.md to this handler): only the
|
||||
// `params` typing is unusable.
|
||||
export async function GET(request: Request) {
|
||||
const url = new URL(request.url)
|
||||
const match = url.pathname.match(/\/cookbook\/([^/]+)\.md$/)
|
||||
const raw = match?.[1]
|
||||
// URL-decode before the allow-list check so a percent-encoded slug
|
||||
// can't slip through the literal Set lookup. The allow-list is pure
|
||||
// ASCII so any decoded value matching means the caller could have
|
||||
// requested the canonical slug directly: no behaviour change for
|
||||
// legitimate clients, defense-in-depth for adversarial ones.
|
||||
let slug: string | undefined
|
||||
try {
|
||||
slug = raw ? decodeURIComponent(raw) : undefined
|
||||
} catch {
|
||||
return new NextResponse('Not found', { status: 404 })
|
||||
}
|
||||
if (!slug || !SLUG_ALLOW.has(slug)) {
|
||||
return new NextResponse('Not found', { status: 404 })
|
||||
}
|
||||
|
||||
const entry = findRecipe(slug)
|
||||
if (!entry) return new NextResponse('Not found', { status: 404 })
|
||||
|
||||
const md = entry.markdown ?? buildPlaceholderMd(entry)
|
||||
return new NextResponse(md, {
|
||||
status: 200,
|
||||
headers: withPublicSecurityHeaders({
|
||||
'Content-Type': 'text/markdown; charset=utf-8',
|
||||
'Cache-Control': 'public, max-age=300, s-maxage=300',
|
||||
}),
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { Metadata } from 'next'
|
||||
import { notFound } from 'next/navigation'
|
||||
import { DocsLayout } from '@/components/docs/DocsLayout'
|
||||
import { DocsMarkdown } from '@/lib/docs/markdown'
|
||||
import { findRecipe, COOKBOOK_SLUGS, buildPlaceholderMd } from '@/lib/docs/content/cookbook'
|
||||
|
||||
export function generateStaticParams() {
|
||||
return COOKBOOK_SLUGS.map((slug) => ({ slug }))
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }): Promise<Metadata> {
|
||||
const { slug } = await params
|
||||
const entry = findRecipe(slug)
|
||||
if (!entry) return { title: 'Not found' }
|
||||
return {
|
||||
title: `${entry.title} · accounted API cookbook`,
|
||||
description: entry.description,
|
||||
}
|
||||
}
|
||||
|
||||
export default async function DocsApiCookbookRecipePage({ params }: { params: Promise<{ slug: string }> }) {
|
||||
const { slug } = await params
|
||||
const entry = findRecipe(slug)
|
||||
if (!entry) notFound()
|
||||
const md = entry.markdown ?? buildPlaceholderMd(entry)
|
||||
return (
|
||||
<DocsLayout currentPath={`/docs/api/cookbook/${slug}`}>
|
||||
<DocsMarkdown source={md} />
|
||||
</DocsLayout>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { buildErrorReferenceMd } from '@/lib/docs/content/errors'
|
||||
import { withPublicSecurityHeaders } from '@/lib/api/v1/security-headers'
|
||||
|
||||
export async function GET() {
|
||||
return new NextResponse(buildErrorReferenceMd(), {
|
||||
status: 200,
|
||||
headers: withPublicSecurityHeaders({
|
||||
'Content-Type': 'text/markdown; charset=utf-8',
|
||||
'Cache-Control': 'public, max-age=300, s-maxage=300',
|
||||
}),
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import type { Metadata } from 'next'
|
||||
import { DocsLayout } from '@/components/docs/DocsLayout'
|
||||
import { DocsMarkdown } from '@/lib/docs/markdown'
|
||||
import { buildErrorReferenceMd } from '@/lib/docs/content/errors'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Errors · accounted API',
|
||||
description: 'Every stable error code returned by the accounted REST API, with HTTP status, description, and remediation.',
|
||||
}
|
||||
|
||||
export default function DocsApiErrorsPage() {
|
||||
const md = buildErrorReferenceMd()
|
||||
return (
|
||||
<DocsLayout currentPath="/docs/api/errors">
|
||||
<DocsMarkdown source={md} />
|
||||
</DocsLayout>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
import type { Metadata } from 'next'
|
||||
import { DocsLayout } from '@/components/docs/DocsLayout'
|
||||
import { DocsMarkdown } from '@/lib/docs/markdown'
|
||||
import { DOCS_NAV } from '@/lib/docs/nav'
|
||||
import { LANDING_MD } from '@/lib/docs/content/landing'
|
||||
import Link from 'next/link'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'accounted API · Documentation',
|
||||
description: 'Swedish double-entry bookkeeping as a public REST API for agents and integrations.',
|
||||
}
|
||||
|
||||
export default function DocsApiLandingPage() {
|
||||
// Highlight the cookbook + reference grids on the landing page itself,
|
||||
// Stripe-style cards. The markdown body provides the prose context;
|
||||
// the cards below give visual scannability.
|
||||
const cookbooks = DOCS_NAV.find((s) => s.label === 'Cookbooks')?.links ?? []
|
||||
const reference = DOCS_NAV.find((s) => s.label === 'API reference')?.links?.slice(0, 8) ?? []
|
||||
|
||||
return (
|
||||
<DocsLayout currentPath="/docs/api">
|
||||
<DocsMarkdown source={LANDING_MD} />
|
||||
|
||||
<section className="mt-16">
|
||||
<h2 className="font-display text-2xl tracking-tight mb-4 pb-2 border-b border-border">Cookbooks</h2>
|
||||
<p className="text-[15px] leading-7 text-foreground/80 mb-6">
|
||||
End-to-end recipes for the most common integrations. Copy-paste ready, tested against the sandbox.
|
||||
</p>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
{cookbooks.map((c) => (
|
||||
<Link
|
||||
key={c.href}
|
||||
href={c.href}
|
||||
className="block rounded-lg border border-border p-5 hover:bg-secondary/40 transition-colors"
|
||||
>
|
||||
<div className="font-display text-lg tracking-tight mb-1">{c.label}</div>
|
||||
{c.summary && (
|
||||
<div className="text-[13px] text-muted-foreground leading-relaxed">{c.summary}</div>
|
||||
)}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="mt-16">
|
||||
<h2 className="font-display text-2xl tracking-tight mb-4 pb-2 border-b border-border">API reference</h2>
|
||||
<p className="text-[15px] leading-7 text-foreground/80 mb-6">
|
||||
Every endpoint, grouped by resource. Auto-generated from the same Zod registry that powers the OpenAPI spec, MCP tools, and runtime validators.
|
||||
</p>
|
||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-2">
|
||||
{reference.map((r) => (
|
||||
<Link
|
||||
key={r.href}
|
||||
href={r.href}
|
||||
className="block rounded-lg border border-border px-3 py-2 hover:bg-secondary/40 transition-colors text-sm"
|
||||
>
|
||||
{r.label}
|
||||
</Link>
|
||||
))}
|
||||
<Link
|
||||
href="/docs/api/reference"
|
||||
className="block rounded-lg border border-border px-3 py-2 hover:bg-secondary/40 transition-colors text-sm text-muted-foreground"
|
||||
>
|
||||
See all →
|
||||
</Link>
|
||||
</div>
|
||||
</section>
|
||||
</DocsLayout>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { buildReferenceOverviewMd } from '@/lib/docs/content/reference'
|
||||
import { withPublicSecurityHeaders } from '@/lib/api/v1/security-headers'
|
||||
|
||||
export async function GET() {
|
||||
return new NextResponse(buildReferenceOverviewMd(), {
|
||||
status: 200,
|
||||
headers: withPublicSecurityHeaders({
|
||||
'Content-Type': 'text/markdown; charset=utf-8',
|
||||
'Cache-Control': 'public, max-age=300, s-maxage=300',
|
||||
}),
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { buildResourcePages, RESOURCE_SLUGS } from '@/lib/docs/content/reference'
|
||||
import { withPublicSecurityHeaders } from '@/lib/api/v1/security-headers'
|
||||
|
||||
// Pre-validate the slug against the closed allow-list before any lookup
|
||||
// runs. Defense-in-depth (V1.2.5): the lookup is array-find on a
|
||||
// memoised in-process collection so a bad slug couldn't escape into a
|
||||
// SQL or filesystem path, but the explicit allow-list gate keeps the
|
||||
// contract safe by construction if the lookup mechanism ever changes.
|
||||
const SLUG_ALLOW = new Set<string>(RESOURCE_SLUGS)
|
||||
|
||||
// Next.js 16 does not extract the dynamic segment name from a directory
|
||||
// like `[slug].md/`: the literal `.md` suffix breaks the inference and
|
||||
// the framework types `params` as `{}`. Workaround: parse the slug from
|
||||
// request.url.pathname directly. Routing still works (Next.js still
|
||||
// matches /docs/api/reference/foo.md to this handler): only the
|
||||
// `params` typing is unusable.
|
||||
export async function GET(request: Request) {
|
||||
const url = new URL(request.url)
|
||||
const match = url.pathname.match(/\/reference\/([^/]+)\.md$/)
|
||||
const raw = match?.[1]
|
||||
// URL-decode before the allow-list check so a percent-encoded slug
|
||||
// can't slip through the literal Set lookup. Same pattern as the
|
||||
// cookbook .md route handler.
|
||||
let slug: string | undefined
|
||||
try {
|
||||
slug = raw ? decodeURIComponent(raw) : undefined
|
||||
} catch {
|
||||
return new NextResponse('Not found', { status: 404 })
|
||||
}
|
||||
if (!slug || !SLUG_ALLOW.has(slug)) {
|
||||
return new NextResponse('Not found', { status: 404 })
|
||||
}
|
||||
|
||||
const page = buildResourcePages().find((p) => p.slug === slug)
|
||||
if (!page) return new NextResponse('Not found', { status: 404 })
|
||||
|
||||
return new NextResponse(page.markdown, {
|
||||
status: 200,
|
||||
headers: withPublicSecurityHeaders({
|
||||
'Content-Type': 'text/markdown; charset=utf-8',
|
||||
'Cache-Control': 'public, max-age=300, s-maxage=300',
|
||||
}),
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { Metadata } from 'next'
|
||||
import { notFound } from 'next/navigation'
|
||||
import { DocsLayout } from '@/components/docs/DocsLayout'
|
||||
import { DocsMarkdown } from '@/lib/docs/markdown'
|
||||
import { buildResourcePages, RESOURCE_SLUGS } from '@/lib/docs/content/reference'
|
||||
|
||||
export function generateStaticParams() {
|
||||
return RESOURCE_SLUGS.map((slug) => ({ slug }))
|
||||
}
|
||||
|
||||
export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }): Promise<Metadata> {
|
||||
const { slug } = await params
|
||||
const page = buildResourcePages().find((p) => p.slug === slug)
|
||||
if (!page) return { title: 'Not found' }
|
||||
return {
|
||||
title: `${page.label} · accounted API`,
|
||||
description: page.description,
|
||||
}
|
||||
}
|
||||
|
||||
export default async function DocsApiReferenceResourcePage({ params }: { params: Promise<{ slug: string }> }) {
|
||||
const { slug } = await params
|
||||
const page = buildResourcePages().find((p) => p.slug === slug)
|
||||
if (!page) notFound()
|
||||
|
||||
return (
|
||||
<DocsLayout currentPath={`/docs/api/reference/${slug}`}>
|
||||
<DocsMarkdown source={page.markdown} />
|
||||
</DocsLayout>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import type { Metadata } from 'next'
|
||||
import { DocsLayout } from '@/components/docs/DocsLayout'
|
||||
import { DocsMarkdown } from '@/lib/docs/markdown'
|
||||
import { buildReferenceOverviewMd } from '@/lib/docs/content/reference'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'API reference · accounted API',
|
||||
description: 'Every endpoint exposed by the accounted REST API, grouped by resource.',
|
||||
}
|
||||
|
||||
export default function DocsApiReferencePage() {
|
||||
return (
|
||||
<DocsLayout currentPath="/docs/api/reference">
|
||||
<DocsMarkdown source={buildReferenceOverviewMd()} />
|
||||
</DocsLayout>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { VERSIONING_MD } from '@/lib/docs/content/versioning'
|
||||
import { withPublicSecurityHeaders } from '@/lib/api/v1/security-headers'
|
||||
|
||||
export async function GET() {
|
||||
return new NextResponse(VERSIONING_MD, {
|
||||
status: 200,
|
||||
headers: withPublicSecurityHeaders({
|
||||
'Content-Type': 'text/markdown; charset=utf-8',
|
||||
'Cache-Control': 'public, max-age=300, s-maxage=300',
|
||||
}),
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import type { Metadata } from 'next'
|
||||
import { DocsLayout } from '@/components/docs/DocsLayout'
|
||||
import { DocsMarkdown } from '@/lib/docs/markdown'
|
||||
import { VERSIONING_MD } from '@/lib/docs/content/versioning'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Versioning · accounted API',
|
||||
description: 'How API versions are pinned, upgraded, and deprecated. Plus idempotency, dry-run, and strict-mode write semantics.',
|
||||
}
|
||||
|
||||
export default function DocsApiVersioningPage() {
|
||||
return (
|
||||
<DocsLayout currentPath="/docs/api/versioning">
|
||||
<DocsMarkdown source={VERSIONING_MD} />
|
||||
</DocsLayout>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { NextResponse } from 'next/server'
|
||||
import { WEBHOOKS_MD } from '@/lib/docs/content/webhooks'
|
||||
import { withPublicSecurityHeaders } from '@/lib/api/v1/security-headers'
|
||||
|
||||
export async function GET() {
|
||||
return new NextResponse(WEBHOOKS_MD, {
|
||||
status: 200,
|
||||
headers: withPublicSecurityHeaders({
|
||||
'Content-Type': 'text/markdown; charset=utf-8',
|
||||
'Cache-Control': 'public, max-age=300, s-maxage=300',
|
||||
}),
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import type { Metadata } from 'next'
|
||||
import { DocsLayout } from '@/components/docs/DocsLayout'
|
||||
import { DocsMarkdown } from '@/lib/docs/markdown'
|
||||
import { WEBHOOKS_MD } from '@/lib/docs/content/webhooks'
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: 'Webhooks · accounted API',
|
||||
description: 'Receive HMAC-signed POST notifications when state changes in accounted. Includes signature verification samples in Node.js and Python.',
|
||||
}
|
||||
|
||||
export default function DocsApiWebhooksPage() {
|
||||
return (
|
||||
<DocsLayout currentPath="/docs/api/webhooks">
|
||||
<DocsMarkdown source={WEBHOOKS_MD} />
|
||||
</DocsLayout>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user