Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions app/(root)/dashboard/api-integrations/page.tsx

This file was deleted.

8 changes: 8 additions & 0 deletions app/(root)/dashboard/apikeys/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react'
import ApiKeysDashboard from '@/components/apikey/ApikeysManagement';

const page = () => {
return <ApiKeysDashboard/>
}

export default page
6 changes: 6 additions & 0 deletions app/(root)/dashboard/webhooks/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { WebhookManager } from '@/components/Layout/Dashboard/webhooks/WebhookManager';

export default function Page(){

return <WebhookManager/>
}
52 changes: 52 additions & 0 deletions app/api/contents/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { NextRequest, NextResponse } from 'next/server';
import { fetchContentsFromDB, resolveUserIdFromApiKey } from '@/lib/db/content';

export const runtime = 'nodejs';


export async function GET(request: NextRequest) {
try {
const apiKey = request.headers.get('x-api-key');

if (!apiKey) {
return NextResponse.json(
{ error: 'Unauthorized: Invalid or missing API Key' },
{ status: 401 }
);
}

const authenticatedUserId = await resolveUserIdFromApiKey(apiKey);

if (!authenticatedUserId) {
return NextResponse.json(
{ error: 'Unauthorized: Invalid or revoked API Key.' },
{ status: 401 }
);
}


const searchParams = request.nextUrl.searchParams;
const limit = parseInt(searchParams.get('limit'));
const versions = parseInt(searchParams.get('versions'));
const authorID = searchParams.get('author_id');

// Ensure limit is a positive number
const safeLimit = Math.max(1, limit);
// Ensure versions is a non-negative number
const safeVersions = Math.max(0, versions);

const contentData = await fetchContentsFromDB(safeLimit, safeVersions, authorID);

return NextResponse.json({
success: true,
count: contentData.length,
data: contentData,
}, { status: 200 });

} catch (error) {
return NextResponse.json(
{ error: 'Internal Server Error' },
{ status: 500 }
);
}
}
Empty file removed app/api/format/route.ts
Empty file.
30 changes: 30 additions & 0 deletions app/api/keys/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { generateAndStoreNewApiKey } from "@/lib/db/content";
import { NextRequest, NextResponse } from "next/server";

export const runtime = 'nodejs';

export async function POST(request: NextRequest) {

try {
const { keyName } = await request.json();

// 2. Input Validation
if (!keyName || typeof keyName !== 'string' || keyName.trim().length === 0) {
return NextResponse.json({ error: 'A valid key name is required.' }, { status: 400 });
}

// 3. Generate, Hash, and Store the new key
const plainTextKey = await generateAndStoreNewApiKey(keyName.trim());

// 4. Return the plaintext key (ONLY return it on creation!)
return NextResponse.json({
success: true,
plainTextKey: plainTextKey,
message: "Key generated. Store this key securely, it will not be shown again."
}, { status: 201 });

} catch (error) {
console.error('API Key Generation Error:', error);
return NextResponse.json({ error: 'Failed to process key generation request.' }, { status: 500 });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Context {
};
}

const API_ENDPOINT = 'http://localhost:3000/api/scheduled';
const API_ENDPOINT = 'http://localhost:3000/api/schedule';

export async function GET(request: NextRequest, context: Context) {
const { time } = await context.params;
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion components/Layout/Navigations/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ const navigation = [
title: 'Other',
items: [
{ href: '/dashboard/explore', icon: Globe, label: 'Explore Tools' },
{ href: '/dashboard/api-integrations', icon: Globe, label: 'API Intgrations' },
{ href: '/dashboard/webhooks', icon: Globe, label: 'Webhook Intgrations' },
{ href: '/dashboard/apikeys', icon: Globe, label: 'Api Keys' },
],
},
];
Expand Down
Loading
Loading