streamby-core 0.6.0 → 0.7.0

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.
@@ -59,6 +59,24 @@ function createStreamByRouter(config) {
59
59
  res.status(500).json({ error: 'Failed to list files', details: err });
60
60
  }
61
61
  });
62
+ router.patch('/projects/:id/image', async (req, res) => {
63
+ try {
64
+ const auth = await config.authProvider(req);
65
+ if (auth.role !== 'admin' && auth.role !== 'editor') {
66
+ return res.status(403).json({ error: 'Permission denied' });
67
+ }
68
+ const projectId = req.params.id;
69
+ const { image } = req.body;
70
+ if (!image) {
71
+ return res.status(400).json({ error: 'Missing image key' });
72
+ }
73
+ const updated = await config.projectProvider.updateImage(projectId, image);
74
+ res.status(200).json(updated);
75
+ }
76
+ catch (err) {
77
+ res.status(500).json({ error: 'Failed to update project image', details: err.message });
78
+ }
79
+ });
62
80
  router.post('/upload', async (req, res) => {
63
81
  try {
64
82
  const auth = await config.authProvider(req);
@@ -6,6 +6,7 @@ export declare function createProjectService(req: Request, projectProvider: Proj
6
6
  id: string;
7
7
  name: string;
8
8
  description: string | undefined;
9
+ image: string | undefined;
9
10
  settings: {
10
11
  allowUpload?: boolean;
11
12
  allowSharing?: boolean;
@@ -8,10 +8,7 @@ async function createProjectService(req, projectProvider) {
8
8
  }
9
9
  const newProject = await projectProvider.create({
10
10
  name,
11
- description: description || '',
12
- rootFolders: [],
13
- allowUpload: true,
14
- allowSharing: false
11
+ description: description || ''
15
12
  });
16
13
  return {
17
14
  success: true,
@@ -19,6 +16,7 @@ async function createProjectService(req, projectProvider) {
19
16
  id: newProject.id,
20
17
  name: newProject.name,
21
18
  description: newProject.description,
19
+ image: newProject.image,
22
20
  settings: newProject.settings,
23
21
  rootFolders: newProject.rootFolders || [],
24
22
  }
@@ -44,6 +44,7 @@ export interface AuthContext {
44
44
  export type AuthProvider = (req: Request) => Promise<AuthContext>;
45
45
  export interface ProjectProvider {
46
46
  getById(projectId: string): Promise<ProjectInfo>;
47
+ updateImage: (projectId: string, imageKey: string) => Promise<ProjectInfo>;
47
48
  create(data: {
48
49
  name: string;
49
50
  image?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "streamby-core",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "StreamBy middleware framework for media storage management",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",