mirror of
https://github.com/Litlyx/litlyx
synced 2025-12-12 08:38:38 +01:00
new selfhosted version
This commit is contained in:
21
dashboard/server/api/project/change_name.ts
Normal file
21
dashboard/server/api/project/change_name.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { ProjectModel } from "~/shared/schema/project/ProjectSchema";
|
||||
|
||||
export default defineEventHandler(async event => {
|
||||
|
||||
const ctx = await getRequestContext(event, 'pid');
|
||||
|
||||
const { project_id } = ctx;
|
||||
|
||||
const body = await readBody(event);
|
||||
|
||||
const name = body.name.trim();
|
||||
|
||||
if (name.trim().length == 0) throw createError({ status: 400, message: 'Name is required' });
|
||||
if (name.trim().length <= 2) throw createError({ status: 400, message: 'Name too short' });
|
||||
if (name.trim().length >= 24) throw createError({ status: 400, message: 'Name too long' });
|
||||
|
||||
await ProjectModel.updateOne({ _id: project_id }, { name });
|
||||
|
||||
return { ok: true };
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user