Skip to content

Commit

Permalink
feat: use restfull api path convention
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrsxx committed Nov 17, 2023
1 parent 4254a1a commit ba18db5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/app/(public)/links/route.ts → src/app/(public)/l/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import type { LinkMeta } from '@/lib/types/meta';
export async function POST(
request: Request
): Promise<NextResponse<APIResponse<LinkMeta>>> {
try {
const body = (await request.json().catch(() => null)) as Link | null;
const body = (await request.json().catch(() => null)) as Link | null;

if (!body)
return NextResponse.json(
{ message: 'Invalid request body' },
{ status: 400 }
);
if (!body)
return NextResponse.json(
{ message: 'Invalid request body' },
{ status: 400 }
);

try {
const { url, slug } = linkSchema.parse(body);

const isValidUrl = checkIfUrlIsValid(url);
Expand Down
2 changes: 1 addition & 1 deletion src/app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function createLink(
let successUrl: string;

try {
const response = await fetch(`${NEXT_PUBLIC_URL}/links`, {
const response = await fetch(`${NEXT_PUBLIC_URL}/l`, {
method: 'POST',
headers: {
Origin: NEXT_PUBLIC_URL,
Expand Down
2 changes: 1 addition & 1 deletion src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,5 @@ type Config = {
};

export const config: Config = {
matcher: '/links'
matcher: '/l'
};

0 comments on commit ba18db5

Please sign in to comment.