-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscaffold.ts
382 lines (376 loc) · 10.8 KB
/
scaffold.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
const userModel = {
socketId: "String",
username: "String",
};
const fileModel = {
_id: "Mongoose.Types.ObjectId",
filename: "String",
size: "String",
mimetype: "String",
parentId: "Mongoose.Types.ObjectId",
expires: "String",
deleteAfterDownload: "Boolean",
location: "String",
s3Key: "String",
};
const historyModel = {
action: "String",
author: "String",
timestamp: "Number",
};
const spaceModel = {
code: "String",
files: [fileModel],
expires: "String",
history: [historyModel],
users: [userModel],
};
const response500 = { status: 500, description: "Internal server error." };
export const apis = [
{
method: "GET",
summary: "Retrieve the space for a given code.",
endpoint: "/api/v4/space/{code}",
request: {
pathParameters: [
{
name: "code",
description: "Code of the space to retrieve.",
required: true,
},
],
queryParameters: [],
body: null,
},
responses: [
{
status: 200,
description: "Space was found.",
body: {
space: spaceModel,
},
},
{
status: 400,
description: "Invalid request. No code supplied.",
body: {
message: "Invalid request.",
},
},
{
status: 404,
description: "No space was found for the supplied code.",
body: {
message: "Space does not exist.",
},
},
response500,
],
},
{
method: "POST",
summary: "Create a new space.",
endpoint: "/api/v4/space",
request: {
pathParameters: [],
queryParameters: [],
body: null,
},
responses: [
{
status: 200,
description: "Successfully created a new space.",
body: {
space: spaceModel,
},
},
response500,
],
},
{
method: "DELETE",
summary:
"Deletes a space. Subscribed clients will receive a 'SPACE_DELETED' event.",
endpoint: "/api/v4/space/{code}",
request: {
pathParameters: [
{ name: "code", description: "Code of the space to delete." },
],
queryParameters: [],
body: null,
},
responses: [
{
status: 200,
description: "Successfully delete the space and all of its files.",
},
{ status: 404, description: "Space to be delete does not exist." },
response500,
],
},
{
method: "DELETE",
summary:
"Removes a file from a space. Subscribed clients will receive a 'FILES_UPDATED' event.",
endpoint: "/api/v4/space/{code}/files/{key}",
request: {
pathParameters: [
{
name: "code",
description: "Code of the space to remove files from.",
},
{
name: "key",
description:
"Key of the file to be deleted and removed from the space.",
},
],
queryParameters: [],
body: null,
},
responses: [
{
status: 200,
description: "Successfuly deleted and removed files from the space.",
},
{ status: 404, description: "Space does not exist." },
response500,
],
},
{
method: "DELETE",
summary:
"Removes files from a space. Subscribed clients will receive a 'FILES_UPDATED' event.",
endpoint: "/api/v4/space/{code}/files",
request: {
pathParameters: [
{
name: "code",
description: "Code of the space to remove files from.",
},
],
queryParameters: [
{
name: "toRemove",
description:
"Array of file keys to be deleted and removed from the space.",
},
],
body: null,
},
responses: [
{
status: 200,
description: "Successfuly deleted and removed files from the space.",
},
{ status: 404, description: "Space does not exist." },
response500,
],
},
{
method: "PATCH",
summary:
"Associates an uploaded file with the space. This endpoint is called after the client has successfully uploaded the file to S3. Subscribed clients will receive a 'FILES_UPDATED' event.",
endpoint: "/api/v4/space/{code}/file",
request: {
pathParameters: [
{ name: "code", description: "Code of the space to upload files to." },
],
queryParameters: [],
body: {
key: "String",
size: "String",
name: "String",
type: "String",
ext: "String",
},
},
responses: [
{ status: 200, description: "Successfuly uploaded files to the space." },
{ status: 404, description: "Space does not exist." },
{ status: 422, description: "Invalid request. Missing code." },
response500,
],
},
{
method: "GET",
summary: "Retrieve the list of files uploaded to a space.",
endpoint: "/api/v4/space/{code}/files",
request: {
pathParameters: [
{ name: "code", description: "Code of the space to fetch files for." },
],
queryParameters: [],
body: null,
},
responses: [
{
status: 200,
description: "Successfully retrieved list of files for the space.",
body: { files: [{ ...fileModel, signedUrl: "String" }] },
},
response500,
],
},
{
method: "GET",
summary: "ZIP and download files.",
endpoint: "/api/v4/space/{code}/files/zip",
request: {
pathParameters: [
{
name: "code",
description: "Code of the space that the files are uploaded to.",
},
],
queryParameters: [
{
name: "keys",
description: "Array of file keys to be zipped and downloaded.",
},
],
body: null,
},
responses: [
{
status: 200,
description: "Successful operation. Streaming zipped content.",
},
response500,
],
},
{
method: "DELETE",
summary:
"Deletes a zipped foler from the server. This API should be invoked after a successful download of zipped files.",
endpoint: "/api/v4/space/{code}/files/zip",
request: {
pathParameters: [],
queryParameters: [
{ name: "folder", description: "Name of the zipped folder." },
],
body: null,
},
responses: [
{ status: 200, description: "Successfully removed folder from server" },
],
},
{
method: "PATCH",
summary: "Update the history for a space.",
endpoint: "/api/v4/space/{code}/history",
request: {
pathParameters: [
{
name: "code",
description: "Code of the space to retrieve the history for.",
},
],
queryParameters: [],
body: { action: "String", payload: "String" },
},
responses: [
{
status: 200,
description: "Successfully updated space history.",
body: {
history: [historyModel],
},
},
response500,
],
},
{
method: "GET",
summary: "Retrieve the history for a space.",
endpoint: "/api/v4/space/{code}/history",
request: {
pathParameters: [
{
name: "code",
description: "Code of the space to retrieve the history for.",
},
],
queryParameters: [],
body: null,
},
responses: [
{
status: 200,
description: "Successfully retrieved space history.",
body: {
history: [historyModel],
},
},
response500,
],
},
{
method: "GET",
summary: "Retrieve a list of users connected to a given space.",
endpoint: "/api/v4/space/{code}/users",
request: {
pathParameters: [
{
name: "code",
description: "Code of the space to retrieve users for.",
},
],
queryParameters: [],
body: null,
},
responses: [
{
status: 200,
description: "Successfully retrieved users.",
body: {
users: [userModel],
},
},
response500,
],
},
];
export const faqs = [
{
q: "Why should I use floatingfile?",
a: "You should use floatingfile if you need a fast way to transfer files between two devices!",
},
{
q: "Is it secure?",
a: "When you upload a file to floatingfile, your file gets uploaded to Amazon's cloud (floatingfile uses AWS S3). While the URL of your file is hashed, it still exists and is accessible on the public web. Furthermore, please remember that anyone with the space's 6-digit code can view and download all files associated with that space! <br/> With these in mind, I would <b>strongly recommend against using floatingfile</b> to transfer sensitive documents such as bank statements, personal identification, and passport information to name a few. To minimize the risk of files being compromised, ensure that you manually remove the file or destroy the space to reduce the time which your files are on the public web.",
},
{
q: "What are the storage constraints?",
a: "Each space can store 5 GB.",
},
{
q: "How long do spaces and files last?",
a: "Spaces and files are automatically deleted after 24 hours. If you do not need the files, it is recommend to manually destroy the space to remove all your data.",
},
{
q: "How was my username generated?",
a: "Your username is a randomly generated color-animal pair. The username is saved to your browser storage and is refreshed after a few hours of inactivity. The username is just a mechanism to identify differnet users in a space.",
},
{
q: "Why did you build floatingfile?",
a: "I (Gareth) built floatingfile to improve my workflow of moving files from university workstations to my personal computer. Common solutions such as Gmail, Google Drive and OneDrive all required that I sign in on the university computer which added extra minutes to the process (even moreso because I use a password manager and don't know these passwords from memory). Dedicated file transfer solutions like Wetransfer and FireFox send on the other hand didn't allow me to edit the files I am sending. As well, there were occasions in which I needed to send files both ways.",
},
{
q: "What was used to build floatingfile?",
a: "The web application was built using the MERN (Mongo, Express, React, and Node) stack. The web application is hosted on Digital Ocean and uses Amazon S3 as the storage solution.",
},
{
q: "Who built floatingfile?",
a: `floatingfile is collaboration between <a href="https://garethlau.me">Gareth Lau</a> and <a href="https://alayan.ca">Alan Yan</a>! The landing page, web application, and backend services were built and are managed by Gareth. The iOS application was built entirely by Alan Yan. `,
},
{ q: "Is there an Android app?", a: "No." },
{
q: "How is floatingfile monetized?",
a: "The iOS application displays ads. The web application is not monetized at all.",
},
];
export default {
faqs,
apis,
};