streamby-core 0.25.6 → 0.25.7

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.
@@ -170,6 +170,44 @@ function storageRouter(config) {
170
170
  res.status(500).json({ message: 'Failed to list files', details: err.message });
171
171
  }
172
172
  });
173
+ router.patch('/projects/:projectId/storage/:category/:key', async (req, res) => {
174
+ try {
175
+ const auth = await config.authProvider(req);
176
+ if (!auth || !auth.userId || !auth.role) {
177
+ return res.status(401).json({ message: 'Unauthorized' });
178
+ }
179
+ const { projectId, category } = req.params;
180
+ const key = decodeURIComponent(req.params.key);
181
+ const { contentType } = req.body;
182
+ if (!VALID_CATEGORIES.includes(category)) {
183
+ return res.status(400).json({ message: `Invalid category. Must be one of: ${VALID_CATEGORIES.join(', ')}` });
184
+ }
185
+ if (!contentType) {
186
+ return res.status(400).json({ message: 'contentType is required' });
187
+ }
188
+ if (!validateContentType(contentType, key, category)) {
189
+ const hint = category === '3d-models'
190
+ ? '.glb, .gltf, .obj, .fbx, .stl, or .ply'
191
+ : `${category.slice(0, -1)}/* content type`;
192
+ return res.status(400).json({ message: `Files in the ${category} category must match ${hint}` });
193
+ }
194
+ const project = await Project.findOne({ _id: projectId });
195
+ if (!project) {
196
+ return res.status(404).json({ message: 'Project not found' });
197
+ }
198
+ if (!(0, auth_1.isProjectMember)(project, auth.userId)) {
199
+ return res.status(403).json({ message: 'Unauthorized access' });
200
+ }
201
+ if (!adapter.getPresignedUploadUrl) {
202
+ return res.status(501).json({ message: 'Storage adapter does not support presigned uploads' });
203
+ }
204
+ const url = await adapter.getPresignedUploadUrl(key, contentType);
205
+ res.json({ url });
206
+ }
207
+ catch (err) {
208
+ res.status(500).json({ message: 'Failed to generate overwrite URL', details: err.message });
209
+ }
210
+ });
173
211
  router.delete('/projects/:projectId/storage/:category/:key', async (req, res) => {
174
212
  try {
175
213
  const auth = await config.authProvider(req);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "streamby-core",
3
- "version": "0.25.6",
3
+ "version": "0.25.7",
4
4
  "description": "StreamBy middleware framework for media storage management",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",