streamby-core 0.6.0 → 0.7.1

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);
@@ -87,7 +105,7 @@ function createStreamByRouter(config) {
87
105
  res.status(404).json({ error: 'Project not found', details: err });
88
106
  }
89
107
  });
90
- router.post('/projects', async (req, res) => {
108
+ router.post('/projects/create', async (req, res) => {
91
109
  try {
92
110
  const auth = await config.authProvider(req);
93
111
  if (auth.role !== 'admin' && auth.role !== 'editor') {
@@ -3,8 +3,9 @@ import { ProjectProvider } from '../types';
3
3
  export declare function createProjectService(req: Request, projectProvider: ProjectProvider): Promise<{
4
4
  success: boolean;
5
5
  project: {
6
- id: string;
6
+ _id: string;
7
7
  name: string;
8
+ image: string | undefined;
8
9
  description: string | undefined;
9
10
  settings: {
10
11
  allowUpload?: boolean;
@@ -8,16 +8,14 @@ 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,
18
15
  project: {
19
- id: newProject.id,
16
+ _id: newProject._id,
20
17
  name: newProject.name,
18
+ image: newProject.image,
21
19
  description: newProject.description,
22
20
  settings: newProject.settings,
23
21
  rootFolders: newProject.rootFolders || [],
@@ -12,7 +12,7 @@ export interface StorageAdapter {
12
12
  getPresignedUrl?: (filename: string, contentType: string) => Promise<string>;
13
13
  }
14
14
  export interface ProjectInfo {
15
- id: string;
15
+ _id: string;
16
16
  name: string;
17
17
  image?: string;
18
18
  description?: string;
@@ -23,7 +23,7 @@ export interface ProjectInfo {
23
23
  };
24
24
  }
25
25
  export interface FolderNode {
26
- id: string;
26
+ _id: string;
27
27
  name: string;
28
28
  children?: FolderNode[];
29
29
  }
@@ -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.1",
4
4
  "description": "StreamBy middleware framework for media storage management",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",