mirror of
https://github.com/ostris/ai-toolkit.git
synced 2026-04-24 00:09:26 +00:00
23 lines
648 B
TypeScript
23 lines
648 B
TypeScript
import { NextResponse } from 'next/server';
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
import { getDatasetsRoot } from '@/server/settings';
|
|
|
|
export async function POST(request: Request) {
|
|
try {
|
|
const body = await request.json();
|
|
const { name } = body;
|
|
let datasetsPath = await getDatasetsRoot();
|
|
let datasetPath = path.join(datasetsPath, name);
|
|
|
|
// if folder doesnt exist, create it
|
|
if (!fs.existsSync(datasetPath)) {
|
|
fs.mkdirSync(datasetPath);
|
|
}
|
|
|
|
return NextResponse.json({ success: true });
|
|
} catch (error) {
|
|
return NextResponse.json({ error: 'Failed to create dataset' }, { status: 500 });
|
|
}
|
|
}
|