streamby-core 0.25.0 → 0.25.2

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.
@@ -7,7 +7,7 @@ const presign_1 = require("../../services/presign");
7
7
  const storage_1 = require("../../providers/storage");
8
8
  const manager_1 = require("../../models/manager");
9
9
  const auth_1 = require("../../utils/auth");
10
- const VALID_CATEGORIES = ['images', 'audios', 'videos', '3dmodels'];
10
+ const VALID_CATEGORIES = ['images', 'audios', 'videos', '3d-models'];
11
11
  const VALID_3D_EXTENSIONS = new Set(['.glb', '.gltf', '.obj', '.fbx', '.stl', '.ply']);
12
12
  function validateContentType(contentType, filename, category) {
13
13
  if (category === 'images')
@@ -16,7 +16,7 @@ function validateContentType(contentType, filename, category) {
16
16
  return contentType.startsWith('audio/');
17
17
  if (category === 'videos')
18
18
  return contentType.startsWith('video/');
19
- if (category === '3dmodels') {
19
+ if (category === '3d-models') {
20
20
  const ext = filename.split('.').pop()?.toLowerCase();
21
21
  return ext ? VALID_3D_EXTENSIONS.has(`.${ext}`) : false;
22
22
  }
@@ -92,7 +92,7 @@ function storageRouter(config) {
92
92
  return res.status(400).json({ message: 'Query params fileName and contentType are required' });
93
93
  }
94
94
  if (!validateContentType(contentType, fileName, category)) {
95
- const hint = category === '3dmodels'
95
+ const hint = category === '3d-models'
96
96
  ? '.glb, .gltf, .obj, .fbx, .stl, or .ply'
97
97
  : `${category.slice(0, -1)}/* content type`;
98
98
  return res.status(400).json({ message: `Files in the ${category} category must match ${hint}` });
@@ -173,20 +173,23 @@ function storageRouter(config) {
173
173
  router.get('/storages', async (req, res) => {
174
174
  try {
175
175
  const auth = await config.authProvider(req);
176
- if (!auth ||
177
- !auth.userId ||
178
- !auth.role) {
176
+ if (!auth || !auth.userId || !auth.role) {
179
177
  return res.status(401).json({ message: 'Unauthorized' });
180
178
  }
181
- const projectId = (req.query.projectId || req.headers['x-project-id']);
182
- if (!projectId) {
183
- return res.status(403).json({ message: 'Unauthorized or missing projectId' });
184
- }
185
- const files = await (0, file_1.listFilesService)(adapter, req, projectId);
186
- res.json({ files, message: 'Files listed successfully' });
179
+ const STORAGE_DISPLAY = {
180
+ s3: { value: 'aws-s3', name: 'AWS S3' },
181
+ gcs: { value: 'google-cloud-storage', name: 'Google Cloud Storage' },
182
+ azure: { value: 'azure-blob', name: 'Azure Blob Storage' },
183
+ r2: { value: 'cloudflare-r2', name: 'Cloudflare R2' },
184
+ };
185
+ const storages = (config.storageProviders || []).map(provider => ({
186
+ ...STORAGE_DISPLAY[provider.type],
187
+ type: provider.type,
188
+ }));
189
+ res.status(200).json({ storages });
187
190
  }
188
191
  catch (err) {
189
- res.status(500).json({ message: 'Failed to list files', details: err });
192
+ res.status(500).json({ message: err.message });
190
193
  }
191
194
  });
192
195
  return router;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "streamby-core",
3
- "version": "0.25.00",
3
+ "version": "0.25.2",
4
4
  "description": "StreamBy middleware framework for media storage management",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",