streamby-core 0.21.1 β 0.21.3
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.
- package/README.md +206 -206
- package/dist/adapters/database/connectionManager.js +38 -38
- package/dist/adapters/storage/s3.js +5 -2
- package/dist/middleware/createRouter.js +14 -385
- package/dist/middleware/routes/auth.d.ts +3 -0
- package/dist/middleware/routes/auth.js +22 -0
- package/dist/middleware/routes/database.d.ts +3 -0
- package/dist/middleware/routes/database.js +27 -0
- package/dist/middleware/routes/export.d.ts +3 -0
- package/dist/middleware/routes/export.js +65 -0
- package/dist/middleware/routes/file.d.ts +5 -0
- package/dist/middleware/routes/file.js +78 -0
- package/dist/middleware/routes/project.d.ts +3 -0
- package/dist/middleware/routes/project.js +290 -0
- package/dist/models/Model.d.ts +1 -0
- package/dist/models/Model.js +84 -58
- package/dist/models/registry.d.ts +1 -1
- package/dist/models/registry.js +4 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/utils/auth.d.ts +1 -0
- package/dist/utils/auth.js +6 -0
- package/package.json +60 -60
package/README.md
CHANGED
|
@@ -1,206 +1,206 @@
|
|
|
1
|
-
# @streamby/core
|
|
2
|
-
|
|
3
|
-
Middleware framework for building storage-agnostic media APIs.
|
|
4
|
-
Part of the [StreamBy](https://streamby.nhexa.cl) ecosystem by TerminalCore Labs.
|
|
5
|
-
|
|
6
|
-
---
|
|
7
|
-
|
|
8
|
-
## π What is it?
|
|
9
|
-
|
|
10
|
-
`@streamby/core` is a plug-and-play middleware for Express (or compatible frameworks) that enables file uploads, listings and **multi-project access** over services like:
|
|
11
|
-
|
|
12
|
-
- β
AWS S3
|
|
13
|
-
- β
Google Cloud Storage (soon)
|
|
14
|
-
- β
Cloudflare R2 (soon)
|
|
15
|
-
- β
Local/Personal servers (soon)
|
|
16
|
-
|
|
17
|
-
It's designed to be installed inside your existing API as a library β **no need to run a separate backend**.
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## π¦ Installation
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
npm install @streamby/core
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
---
|
|
28
|
-
|
|
29
|
-
## π§± Basic usage
|
|
30
|
-
|
|
31
|
-
```ts
|
|
32
|
-
import express from 'express';
|
|
33
|
-
import { createStreamByRouter } from '@streamby/core';
|
|
34
|
-
|
|
35
|
-
const app = express();
|
|
36
|
-
|
|
37
|
-
app.use('/streamby', createStreamByRouter({
|
|
38
|
-
storageProvider: {
|
|
39
|
-
type: 's3',
|
|
40
|
-
config: {
|
|
41
|
-
bucket: 'your-bucket-name',
|
|
42
|
-
region: 'your-region',
|
|
43
|
-
accessKeyId: 'YOUR_AWS_KEY',
|
|
44
|
-
secretAccessKey: 'YOUR_AWS_SECRET'
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
authProvider: async (req) => {
|
|
48
|
-
// extract token/cookie and validate
|
|
49
|
-
return {
|
|
50
|
-
userId: 'demo',
|
|
51
|
-
projects: ['demo-project'],
|
|
52
|
-
role: 'admin',
|
|
53
|
-
};
|
|
54
|
-
},
|
|
55
|
-
projectProvider: async (projectId) => {
|
|
56
|
-
// fetch project from your DB
|
|
57
|
-
return {
|
|
58
|
-
id: projectId,
|
|
59
|
-
name: 'Demo Project',
|
|
60
|
-
description: 'Demo for StreamBy integration',
|
|
61
|
-
rootFolders: [],
|
|
62
|
-
settings: { allowUpload: true }
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}));
|
|
66
|
-
|
|
67
|
-
app.listen(3000);
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
---
|
|
71
|
-
|
|
72
|
-
## π§ͺ Testing
|
|
73
|
-
|
|
74
|
-
```bash
|
|
75
|
-
npm run test
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
Unit tests use [Vitest](https://vitest.dev) and [Supertest](https://www.npmjs.com/package/supertest).
|
|
79
|
-
|
|
80
|
-
---
|
|
81
|
-
|
|
82
|
-
## π Features
|
|
83
|
-
|
|
84
|
-
- π Multi-project access control
|
|
85
|
-
- π Project-aware file uploads & listings
|
|
86
|
-
- π§Ή Modular adapters per storage provider
|
|
87
|
-
- π§° Built-in testability with mock auth & storage
|
|
88
|
-
- β¨ Simple to extend for custom business logic
|
|
89
|
-
|
|
90
|
-
---
|
|
91
|
-
|
|
92
|
-
## πΊοΈ API Endpoints
|
|
93
|
-
|
|
94
|
-
Here's a summary of the key API endpoints provided by `@streamby/core`:
|
|
95
|
-
|
|
96
|
-
### `GET /streamby/projects`
|
|
97
|
-
|
|
98
|
-
Lists all projects accessible by the authenticated user.
|
|
99
|
-
|
|
100
|
-
**Query Parameters:**
|
|
101
|
-
- `archived`: (Optional) Filter projects by their archived status.
|
|
102
|
-
- `true`: Returns only archived projects.
|
|
103
|
-
- `false`: Returns only unarchived projects.
|
|
104
|
-
- (Omitted): Returns all projects (both archived and unarchived).
|
|
105
|
-
|
|
106
|
-
**Example Response:**
|
|
107
|
-
```json
|
|
108
|
-
{
|
|
109
|
-
"projects": [
|
|
110
|
-
{
|
|
111
|
-
"id": "project1_id",
|
|
112
|
-
"dbType": "nosql",
|
|
113
|
-
"name": "My NoSQL Project",
|
|
114
|
-
"image": "url_to_image",
|
|
115
|
-
"archived": false
|
|
116
|
-
},
|
|
117
|
-
{
|
|
118
|
-
"id": "project2_id",
|
|
119
|
-
"dbType": "sql",
|
|
120
|
-
"name": "My SQL Project",
|
|
121
|
-
"image": "url_to_image",
|
|
122
|
-
"archived": true
|
|
123
|
-
}
|
|
124
|
-
]
|
|
125
|
-
}
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
### `PATCH /streamby/projects/:id/archive`
|
|
129
|
-
|
|
130
|
-
Archives a specific project. After archiving, it returns the complete list of projects for the user, including the updated project.
|
|
131
|
-
|
|
132
|
-
**Example Response:**
|
|
133
|
-
```json
|
|
134
|
-
{
|
|
135
|
-
"success": true,
|
|
136
|
-
"projects": [
|
|
137
|
-
{
|
|
138
|
-
"id": "project1_id",
|
|
139
|
-
"dbType": "nosql",
|
|
140
|
-
"name": "My NoSQL Project",
|
|
141
|
-
"image": "url_to_image",
|
|
142
|
-
"archived": true
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
"id": "project2_id",
|
|
146
|
-
"dbType": "sql",
|
|
147
|
-
"name": "My SQL Project",
|
|
148
|
-
"image": "url_to_image",
|
|
149
|
-
"archived": false
|
|
150
|
-
}
|
|
151
|
-
]
|
|
152
|
-
}
|
|
153
|
-
```
|
|
154
|
-
|
|
155
|
-
### `PATCH /streamby/projects/:id/unarchive`
|
|
156
|
-
|
|
157
|
-
Unarchives a specific project. After unarchiving, it returns the complete list of projects for the user, including the updated project.
|
|
158
|
-
|
|
159
|
-
**Example Response:**
|
|
160
|
-
```json
|
|
161
|
-
{
|
|
162
|
-
"success": true,
|
|
163
|
-
"projects": [
|
|
164
|
-
{
|
|
165
|
-
"id": "project1_id",
|
|
166
|
-
"dbType": "nosql",
|
|
167
|
-
"name": "My NoSQL Project",
|
|
168
|
-
"image": "url_to_image",
|
|
169
|
-
"archived": false
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
"id": "project2_id",
|
|
173
|
-
"dbType": "sql",
|
|
174
|
-
"name": "My SQL Project",
|
|
175
|
-
"image": "url_to_image",
|
|
176
|
-
"archived": false
|
|
177
|
-
}
|
|
178
|
-
]
|
|
179
|
-
}
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
---
|
|
183
|
-
|
|
184
|
-
## π£ Roadmap
|
|
185
|
-
|
|
186
|
-
- [ ] Support for Google Cloud Storage
|
|
187
|
-
- [ ] CLI tool for uploading files
|
|
188
|
-
- [ ] Role-based access control middleware
|
|
189
|
-
- [ ] Plugin system for extended routes
|
|
190
|
-
- [ ] Streaming support (HLS, audio, etc.)
|
|
191
|
-
|
|
192
|
-
---
|
|
193
|
-
|
|
194
|
-
## π§βπ» Maintained by
|
|
195
|
-
|
|
196
|
-
**TerminalCore Labs** β part of [Nhexa Entertainment](https://nhexa.cl)
|
|
197
|
-
Developed as open-source infrastructure for creative and media-oriented apps.
|
|
198
|
-
|
|
199
|
-
Visit us [here](https://terminalcore.cl)
|
|
200
|
-
|
|
201
|
-
---
|
|
202
|
-
|
|
203
|
-
## π License
|
|
204
|
-
|
|
205
|
-
[MIT](./LICENSE)
|
|
206
|
-
|
|
1
|
+
# @streamby/core
|
|
2
|
+
|
|
3
|
+
Middleware framework for building storage-agnostic media APIs.
|
|
4
|
+
Part of the [StreamBy](https://streamby.nhexa.cl) ecosystem by TerminalCore Labs.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## π What is it?
|
|
9
|
+
|
|
10
|
+
`@streamby/core` is a plug-and-play middleware for Express (or compatible frameworks) that enables file uploads, listings and **multi-project access** over services like:
|
|
11
|
+
|
|
12
|
+
- β
AWS S3
|
|
13
|
+
- β
Google Cloud Storage (soon)
|
|
14
|
+
- β
Cloudflare R2 (soon)
|
|
15
|
+
- β
Local/Personal servers (soon)
|
|
16
|
+
|
|
17
|
+
It's designed to be installed inside your existing API as a library β **no need to run a separate backend**.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## π¦ Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @streamby/core
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## π§± Basic usage
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import express from 'express';
|
|
33
|
+
import { createStreamByRouter } from '@streamby/core';
|
|
34
|
+
|
|
35
|
+
const app = express();
|
|
36
|
+
|
|
37
|
+
app.use('/streamby', createStreamByRouter({
|
|
38
|
+
storageProvider: {
|
|
39
|
+
type: 's3',
|
|
40
|
+
config: {
|
|
41
|
+
bucket: 'your-bucket-name',
|
|
42
|
+
region: 'your-region',
|
|
43
|
+
accessKeyId: 'YOUR_AWS_KEY',
|
|
44
|
+
secretAccessKey: 'YOUR_AWS_SECRET'
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
authProvider: async (req) => {
|
|
48
|
+
// extract token/cookie and validate
|
|
49
|
+
return {
|
|
50
|
+
userId: 'demo',
|
|
51
|
+
projects: ['demo-project'],
|
|
52
|
+
role: 'admin',
|
|
53
|
+
};
|
|
54
|
+
},
|
|
55
|
+
projectProvider: async (projectId) => {
|
|
56
|
+
// fetch project from your DB
|
|
57
|
+
return {
|
|
58
|
+
id: projectId,
|
|
59
|
+
name: 'Demo Project',
|
|
60
|
+
description: 'Demo for StreamBy integration',
|
|
61
|
+
rootFolders: [],
|
|
62
|
+
settings: { allowUpload: true }
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}));
|
|
66
|
+
|
|
67
|
+
app.listen(3000);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## π§ͺ Testing
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
npm run test
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Unit tests use [Vitest](https://vitest.dev) and [Supertest](https://www.npmjs.com/package/supertest).
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## π Features
|
|
83
|
+
|
|
84
|
+
- π Multi-project access control
|
|
85
|
+
- π Project-aware file uploads & listings
|
|
86
|
+
- π§Ή Modular adapters per storage provider
|
|
87
|
+
- π§° Built-in testability with mock auth & storage
|
|
88
|
+
- β¨ Simple to extend for custom business logic
|
|
89
|
+
|
|
90
|
+
---
|
|
91
|
+
|
|
92
|
+
## πΊοΈ API Endpoints
|
|
93
|
+
|
|
94
|
+
Here's a summary of the key API endpoints provided by `@streamby/core`:
|
|
95
|
+
|
|
96
|
+
### `GET /streamby/projects`
|
|
97
|
+
|
|
98
|
+
Lists all projects accessible by the authenticated user.
|
|
99
|
+
|
|
100
|
+
**Query Parameters:**
|
|
101
|
+
- `archived`: (Optional) Filter projects by their archived status.
|
|
102
|
+
- `true`: Returns only archived projects.
|
|
103
|
+
- `false`: Returns only unarchived projects.
|
|
104
|
+
- (Omitted): Returns all projects (both archived and unarchived).
|
|
105
|
+
|
|
106
|
+
**Example Response:**
|
|
107
|
+
```json
|
|
108
|
+
{
|
|
109
|
+
"projects": [
|
|
110
|
+
{
|
|
111
|
+
"id": "project1_id",
|
|
112
|
+
"dbType": "nosql",
|
|
113
|
+
"name": "My NoSQL Project",
|
|
114
|
+
"image": "url_to_image",
|
|
115
|
+
"archived": false
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"id": "project2_id",
|
|
119
|
+
"dbType": "sql",
|
|
120
|
+
"name": "My SQL Project",
|
|
121
|
+
"image": "url_to_image",
|
|
122
|
+
"archived": true
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### `PATCH /streamby/projects/:id/archive`
|
|
129
|
+
|
|
130
|
+
Archives a specific project. After archiving, it returns the complete list of projects for the user, including the updated project.
|
|
131
|
+
|
|
132
|
+
**Example Response:**
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"success": true,
|
|
136
|
+
"projects": [
|
|
137
|
+
{
|
|
138
|
+
"id": "project1_id",
|
|
139
|
+
"dbType": "nosql",
|
|
140
|
+
"name": "My NoSQL Project",
|
|
141
|
+
"image": "url_to_image",
|
|
142
|
+
"archived": true
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
"id": "project2_id",
|
|
146
|
+
"dbType": "sql",
|
|
147
|
+
"name": "My SQL Project",
|
|
148
|
+
"image": "url_to_image",
|
|
149
|
+
"archived": false
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### `PATCH /streamby/projects/:id/unarchive`
|
|
156
|
+
|
|
157
|
+
Unarchives a specific project. After unarchiving, it returns the complete list of projects for the user, including the updated project.
|
|
158
|
+
|
|
159
|
+
**Example Response:**
|
|
160
|
+
```json
|
|
161
|
+
{
|
|
162
|
+
"success": true,
|
|
163
|
+
"projects": [
|
|
164
|
+
{
|
|
165
|
+
"id": "project1_id",
|
|
166
|
+
"dbType": "nosql",
|
|
167
|
+
"name": "My NoSQL Project",
|
|
168
|
+
"image": "url_to_image",
|
|
169
|
+
"archived": false
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
"id": "project2_id",
|
|
173
|
+
"dbType": "sql",
|
|
174
|
+
"name": "My SQL Project",
|
|
175
|
+
"image": "url_to_image",
|
|
176
|
+
"archived": false
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
---
|
|
183
|
+
|
|
184
|
+
## π£ Roadmap
|
|
185
|
+
|
|
186
|
+
- [ ] Support for Google Cloud Storage
|
|
187
|
+
- [ ] CLI tool for uploading files
|
|
188
|
+
- [ ] Role-based access control middleware
|
|
189
|
+
- [ ] Plugin system for extended routes
|
|
190
|
+
- [ ] Streaming support (HLS, audio, etc.)
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## π§βπ» Maintained by
|
|
195
|
+
|
|
196
|
+
**TerminalCore Labs** β part of [Nhexa Entertainment](https://nhexa.cl)
|
|
197
|
+
Developed as open-source infrastructure for creative and media-oriented apps.
|
|
198
|
+
|
|
199
|
+
Visit us [here](https://terminalcore.cl)
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## π License
|
|
204
|
+
|
|
205
|
+
[MIT](./LICENSE)
|
|
206
|
+
|
|
@@ -43,53 +43,53 @@ const getConnection = (id) => {
|
|
|
43
43
|
exports.getConnection = getConnection;
|
|
44
44
|
const ensureTablesExist = async (pool) => {
|
|
45
45
|
try {
|
|
46
|
-
await pool.query(`
|
|
47
|
-
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
|
48
|
-
CREATE TABLE IF NOT EXISTS projects (
|
|
49
|
-
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
50
|
-
name VARCHAR(255) NOT NULL,
|
|
51
|
-
description TEXT,
|
|
52
|
-
"createdAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
53
|
-
"updatedAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
|
54
|
-
);
|
|
46
|
+
await pool.query(`
|
|
47
|
+
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
|
|
48
|
+
CREATE TABLE IF NOT EXISTS projects (
|
|
49
|
+
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
50
|
+
name VARCHAR(255) NOT NULL,
|
|
51
|
+
description TEXT,
|
|
52
|
+
"createdAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
53
|
+
"updatedAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
|
54
|
+
);
|
|
55
55
|
`);
|
|
56
56
|
console.log('β
"projects" table ensured to exist.');
|
|
57
57
|
// Ensure dbType column exists and is correctly configured
|
|
58
|
-
await pool.query(`
|
|
59
|
-
ALTER TABLE projects ADD COLUMN IF NOT EXISTS "dbType" VARCHAR(50);
|
|
58
|
+
await pool.query(`
|
|
59
|
+
ALTER TABLE projects ADD COLUMN IF NOT EXISTS "dbType" VARCHAR(50);
|
|
60
60
|
`);
|
|
61
|
-
await pool.query(`
|
|
62
|
-
UPDATE projects SET "dbType" = 'nosql' WHERE "dbType" IS NULL;
|
|
61
|
+
await pool.query(`
|
|
62
|
+
UPDATE projects SET "dbType" = 'nosql' WHERE "dbType" IS NULL;
|
|
63
63
|
`);
|
|
64
|
-
await pool.query(`
|
|
65
|
-
ALTER TABLE projects ALTER COLUMN "dbType" SET NOT NULL;
|
|
64
|
+
await pool.query(`
|
|
65
|
+
ALTER TABLE projects ALTER COLUMN "dbType" SET NOT NULL;
|
|
66
66
|
`);
|
|
67
|
-
await pool.query(`
|
|
68
|
-
ALTER TABLE projects ALTER COLUMN "dbType" SET DEFAULT 'nosql';
|
|
67
|
+
await pool.query(`
|
|
68
|
+
ALTER TABLE projects ALTER COLUMN "dbType" SET DEFAULT 'nosql';
|
|
69
69
|
`);
|
|
70
|
-
await pool.query(`
|
|
71
|
-
CREATE TABLE IF NOT EXISTS exports (
|
|
72
|
-
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
73
|
-
"projectId" UUID NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
74
|
-
status VARCHAR(50) NOT NULL DEFAULT 'pending',
|
|
75
|
-
"filePath" TEXT,
|
|
76
|
-
"createdAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
77
|
-
"updatedAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
|
78
|
-
);
|
|
70
|
+
await pool.query(`
|
|
71
|
+
CREATE TABLE IF NOT EXISTS exports (
|
|
72
|
+
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
73
|
+
"projectId" UUID NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
74
|
+
status VARCHAR(50) NOT NULL DEFAULT 'pending',
|
|
75
|
+
"filePath" TEXT,
|
|
76
|
+
"createdAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
77
|
+
"updatedAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
|
78
|
+
);
|
|
79
79
|
`);
|
|
80
80
|
console.log('β
"exports" table ensured to exist.');
|
|
81
|
-
await pool.query(`
|
|
82
|
-
CREATE TABLE IF NOT EXISTS project_members (
|
|
83
|
-
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
84
|
-
"projectId" UUID NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
85
|
-
"userId" VARCHAR(255) NOT NULL,
|
|
86
|
-
archived BOOLEAN NOT NULL DEFAULT FALSE,
|
|
87
|
-
"archivedBy" VARCHAR(255),
|
|
88
|
-
"archivedAt" TIMESTAMP WITH TIME ZONE,
|
|
89
|
-
"createdAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
90
|
-
"updatedAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
91
|
-
UNIQUE ("projectId", "userId")
|
|
92
|
-
);
|
|
81
|
+
await pool.query(`
|
|
82
|
+
CREATE TABLE IF NOT EXISTS project_members (
|
|
83
|
+
id UUID PRIMARY KEY DEFAULT uuid_generate_v4(),
|
|
84
|
+
"projectId" UUID NOT NULL REFERENCES projects(id) ON DELETE CASCADE,
|
|
85
|
+
"userId" VARCHAR(255) NOT NULL,
|
|
86
|
+
archived BOOLEAN NOT NULL DEFAULT FALSE,
|
|
87
|
+
"archivedBy" VARCHAR(255),
|
|
88
|
+
"archivedAt" TIMESTAMP WITH TIME ZONE,
|
|
89
|
+
"createdAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
90
|
+
"updatedAt" TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
91
|
+
UNIQUE ("projectId", "userId")
|
|
92
|
+
);
|
|
93
93
|
`);
|
|
94
94
|
console.log('β
"project_members" table ensured to exist.');
|
|
95
95
|
}
|
|
@@ -54,12 +54,15 @@ class S3Adapter {
|
|
|
54
54
|
return await (0, s3_request_presigner_1.getSignedUrl)(this.s3, command, { expiresIn: 3600 });
|
|
55
55
|
}
|
|
56
56
|
async getPresignedProjectImageUrl(projectId) {
|
|
57
|
+
const key = `${projectId}/project-image`;
|
|
57
58
|
const command = new client_s3_1.PutObjectCommand({
|
|
58
59
|
Bucket: this.bucket,
|
|
59
|
-
Key:
|
|
60
|
+
Key: key,
|
|
60
61
|
ContentType: 'image/jpeg',
|
|
61
62
|
});
|
|
62
|
-
|
|
63
|
+
const url = await (0, s3_request_presigner_1.getSignedUrl)(this.s3, command, { expiresIn: 3600 });
|
|
64
|
+
const publicUrl = `https://${this.bucket}.s3.amazonaws.com/${key}`;
|
|
65
|
+
return { url, publicUrl };
|
|
63
66
|
}
|
|
64
67
|
}
|
|
65
68
|
exports.S3Adapter = S3Adapter;
|