streamby-core 0.10.2 → 0.10.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -97,24 +97,6 @@ function createStreamByRouter(config) {
|
|
|
97
97
|
res.status(500).json({ error: 'Failed to list files', details: err });
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
|
-
router.patch('/projects/:id', async (req, res) => {
|
|
101
|
-
try {
|
|
102
|
-
const auth = await config.authProvider(req);
|
|
103
|
-
if (auth.role !== 'admin' && auth.role !== 'editor') {
|
|
104
|
-
return res.status(403).json({ error: 'Permission denied' });
|
|
105
|
-
}
|
|
106
|
-
const projectId = req.params.id;
|
|
107
|
-
const updates = req.body;
|
|
108
|
-
if (!updates || typeof updates !== 'object') {
|
|
109
|
-
return res.status(400).json({ error: 'Missing updates payload' });
|
|
110
|
-
}
|
|
111
|
-
const updated = await config.projectProvider.update(projectId, updates);
|
|
112
|
-
res.status(200).json({ success: true, project: updated });
|
|
113
|
-
}
|
|
114
|
-
catch (err) {
|
|
115
|
-
res.status(500).json({ error: 'Failed to update project', details: err.message });
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
100
|
router.get('/projects/:id', async (req, res) => {
|
|
119
101
|
try {
|
|
120
102
|
const auth = await config.authProvider(req);
|
|
@@ -145,6 +127,24 @@ function createStreamByRouter(config) {
|
|
|
145
127
|
res.status(500).json({ error: 'Failed to create project', details: err.message });
|
|
146
128
|
}
|
|
147
129
|
});
|
|
130
|
+
router.patch('/projects/:id', async (req, res) => {
|
|
131
|
+
try {
|
|
132
|
+
const auth = await config.authProvider(req);
|
|
133
|
+
if (auth.role !== 'admin' && auth.role !== 'editor') {
|
|
134
|
+
return res.status(403).json({ error: 'Permission denied' });
|
|
135
|
+
}
|
|
136
|
+
const projectId = req.params.id;
|
|
137
|
+
const updates = req.body;
|
|
138
|
+
if (!updates || typeof updates !== 'object') {
|
|
139
|
+
return res.status(400).json({ error: 'Missing updates payload' });
|
|
140
|
+
}
|
|
141
|
+
const updated = await config.projectProvider.update(projectId, updates);
|
|
142
|
+
res.status(200).json({ success: true, project: updated });
|
|
143
|
+
}
|
|
144
|
+
catch (err) {
|
|
145
|
+
res.status(500).json({ error: 'Failed to update project', details: err.message });
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
148
|
router.delete('/projects/:id', async (req, res) => {
|
|
149
149
|
try {
|
|
150
150
|
const auth = await config.authProvider(req);
|
|
@@ -156,8 +156,8 @@ function createStreamByRouter(config) {
|
|
|
156
156
|
if (!isProjectMember(project, auth.userId)) {
|
|
157
157
|
return res.status(403).json({ error: 'Unauthorized project access' });
|
|
158
158
|
}
|
|
159
|
-
await config.projectProvider
|
|
160
|
-
await
|
|
159
|
+
await (0, project_1.deleteProjectService)(req, config.authProvider, config.projectProvider);
|
|
160
|
+
await (0, file_1.deleteProjectImage)(adapter, projectId);
|
|
161
161
|
res.status(200).json({ success: true });
|
|
162
162
|
}
|
|
163
163
|
catch (err) {
|
|
@@ -10,9 +10,6 @@ export declare function updateProjectService(req: Request, authProvider: AuthPro
|
|
|
10
10
|
}>;
|
|
11
11
|
export declare function deleteProjectService(req: Request, authProvider: AuthProvider, projectProvider: ProjectProvider): Promise<{
|
|
12
12
|
success: boolean;
|
|
13
|
-
project: {
|
|
14
|
-
success: boolean;
|
|
15
|
-
};
|
|
16
13
|
}>;
|
|
17
14
|
export declare function deleteProjectImageService(req: Request, authProvider: AuthProvider, projectProvider: ProjectProvider): Promise<{
|
|
18
15
|
success: boolean;
|
package/dist/services/project.js
CHANGED
|
@@ -28,7 +28,7 @@ async function updateProjectService(req, authProvider, projectProvider) {
|
|
|
28
28
|
if (!project) {
|
|
29
29
|
throw new Error('Project not found');
|
|
30
30
|
}
|
|
31
|
-
if (!project.members?.find((e) => e.userId === auth.userId)) {
|
|
31
|
+
if (!project.members?.find((e) => e.userId.toString() === auth.userId.toString())) {
|
|
32
32
|
throw new Error('Unauthorized');
|
|
33
33
|
}
|
|
34
34
|
const updatedProject = await projectProvider.update(projectId, updates);
|
|
@@ -44,13 +44,12 @@ async function deleteProjectService(req, authProvider, projectProvider) {
|
|
|
44
44
|
if (!project) {
|
|
45
45
|
throw new Error('Project not found');
|
|
46
46
|
}
|
|
47
|
-
if (!project.members?.find((e) => e.userId === auth.userId)) {
|
|
47
|
+
if (!project.members?.find((e) => e.userId.toString() === auth.userId.toString())) {
|
|
48
48
|
throw new Error('Unauthorized');
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
await projectProvider.delete(projectId);
|
|
51
51
|
return {
|
|
52
52
|
success: true,
|
|
53
|
-
project: updatedProject,
|
|
54
53
|
};
|
|
55
54
|
}
|
|
56
55
|
async function deleteProjectImageService(req, authProvider, projectProvider) {
|