Compare commits
4 Commits
53669dc6a8
...
R1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1f3b243da2 | ||
|
|
59036e033b | ||
|
|
c8121cc5e7 | ||
|
|
774bb54786 |
Binary file not shown.
@@ -147,8 +147,6 @@ paths:
|
|||||||
$ref: '#/components/schemas/Idea'
|
$ref: '#/components/schemas/Idea'
|
||||||
'400':
|
'400':
|
||||||
description: Bad Request - Id not a positive integer, or no fields provided
|
description: Bad Request - Id not a positive integer, or no fields provided
|
||||||
'401':
|
|
||||||
description: Unauthorized - Missing or invalid token
|
|
||||||
'404':
|
'404':
|
||||||
description: Not Found - No idea with that id belongs to this user
|
description: Not Found - No idea with that id belongs to this user
|
||||||
'409':
|
'409':
|
||||||
@@ -392,6 +390,10 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
format: binary
|
format: binary
|
||||||
|
'404':
|
||||||
|
description: Not Found or Unauthorized
|
||||||
|
'400':
|
||||||
|
description: Bad Request - Id not a positive integer
|
||||||
|
|
||||||
/api/materials:
|
/api/materials:
|
||||||
get:
|
get:
|
||||||
@@ -616,22 +618,17 @@ components:
|
|||||||
id:
|
id:
|
||||||
type: integer
|
type: integer
|
||||||
readOnly: true
|
readOnly: true
|
||||||
example: 1
|
example: 10
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
example: Project 1
|
example: alice_dev Project 4
|
||||||
description:
|
description:
|
||||||
type: string
|
type: string
|
||||||
example: Project 1 description
|
example: Workspace for project 4
|
||||||
date_created:
|
date_created:
|
||||||
type: string
|
type: string
|
||||||
format: date-time
|
format: date-time
|
||||||
readOnly: true
|
readOnly: true
|
||||||
files:
|
|
||||||
type: array
|
|
||||||
readOnly: true
|
|
||||||
items:
|
|
||||||
$ref: '#/components/schemas/File'
|
|
||||||
|
|
||||||
ProjectRequest:
|
ProjectRequest:
|
||||||
type: object
|
type: object
|
||||||
@@ -641,10 +638,10 @@ components:
|
|||||||
properties:
|
properties:
|
||||||
name:
|
name:
|
||||||
type: string
|
type: string
|
||||||
example: Project 1
|
example: alice_dev Project 4
|
||||||
description:
|
description:
|
||||||
type: string
|
type: string
|
||||||
example: Project 1 description
|
example: Workspace for project 4
|
||||||
|
|
||||||
ProjectUpdateRequest:
|
ProjectUpdateRequest:
|
||||||
type: object
|
type: object
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ export async function deleteProjectFileHandler(req, res) {
|
|||||||
return res.status(404).json({ error: 'File not found or unauthorized' });
|
return res.status(404).json({ error: 'File not found or unauthorized' });
|
||||||
}
|
}
|
||||||
|
|
||||||
res.status(200).json({ message: 'File deleted successfully' });
|
res.status(204).json({ message: 'File deleted successfully' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
res.status(400).json({ error: 'Invalid file ID' });
|
res.status(400).json({ error: 'Invalid file ID' });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ export async function getAll(
|
|||||||
orderBy: { [safeSortBy]: safeOrder },
|
orderBy: { [safeSortBy]: safeOrder },
|
||||||
skip: offset,
|
skip: offset,
|
||||||
take: limit,
|
take: limit,
|
||||||
include: { files: true },
|
include: { files: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
return projects;
|
return projects;
|
||||||
@@ -47,7 +47,7 @@ export async function getById(projectId, userId) {
|
|||||||
|
|
||||||
const project = await prisma.project.findUnique({
|
const project = await prisma.project.findUnique({
|
||||||
where: { id: projectId },
|
where: { id: projectId },
|
||||||
include: { files: true },
|
include: { files: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
if (project && project.userId !== userId) {
|
if (project && project.userId !== userId) {
|
||||||
@@ -64,7 +64,7 @@ export async function create(userId, projectData) {
|
|||||||
|
|
||||||
const newProject = await prisma.project.create({
|
const newProject = await prisma.project.create({
|
||||||
data: { ...projectData, userId },
|
data: { ...projectData, userId },
|
||||||
include: { files: true },
|
include: { files: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
return newProject;
|
return newProject;
|
||||||
@@ -92,7 +92,7 @@ export async function update(projectId, userId, updatedData) {
|
|||||||
const updatedProject = await prisma.project.update({
|
const updatedProject = await prisma.project.update({
|
||||||
where: { id: projectId },
|
where: { id: projectId },
|
||||||
data: updatedData,
|
data: updatedData,
|
||||||
include: { files: true },
|
include: { files: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
return updatedProject;
|
return updatedProject;
|
||||||
@@ -118,7 +118,7 @@ export async function remove(projectId, userId) {
|
|||||||
|
|
||||||
const deletedProject = await prisma.project.delete({
|
const deletedProject = await prisma.project.delete({
|
||||||
where: { id: projectId },
|
where: { id: projectId },
|
||||||
include: { files: true },
|
include: { files: false },
|
||||||
});
|
});
|
||||||
|
|
||||||
return deletedProject;
|
return deletedProject;
|
||||||
@@ -161,6 +161,13 @@ export async function getFilesByProjectId(projectId, userId) {
|
|||||||
|
|
||||||
const files = await prisma.file.findMany({
|
const files = await prisma.file.findMany({
|
||||||
where: { projectId },
|
where: { projectId },
|
||||||
|
select: {
|
||||||
|
id: true,
|
||||||
|
projectId: true,
|
||||||
|
name: true,
|
||||||
|
size: true,
|
||||||
|
mimeType: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return files;
|
return files;
|
||||||
|
|||||||
Reference in New Issue
Block a user