underpost 2.8.877 → 2.8.881

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.
Files changed (54) hide show
  1. package/.env.development +35 -3
  2. package/.env.production +40 -3
  3. package/.env.test +35 -3
  4. package/.github/workflows/release.cd.yml +3 -3
  5. package/README.md +48 -36
  6. package/bin/deploy.js +40 -0
  7. package/cli.md +89 -86
  8. package/conf.js +28 -3
  9. package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
  10. package/manifests/deployment/dd-test-development/deployment.yaml +2 -2
  11. package/package.json +1 -2
  12. package/src/api/document/document.controller.js +66 -0
  13. package/src/api/document/document.model.js +51 -0
  14. package/src/api/document/document.router.js +24 -0
  15. package/src/api/document/document.service.js +125 -0
  16. package/src/api/file/file.controller.js +15 -1
  17. package/src/api/user/user.router.js +4 -3
  18. package/src/cli/deploy.js +1 -1
  19. package/src/cli/index.js +3 -0
  20. package/src/cli/repository.js +2 -2
  21. package/src/cli/run.js +29 -1
  22. package/src/client/Default.index.js +42 -1
  23. package/src/client/components/core/Account.js +8 -1
  24. package/src/client/components/core/AgGrid.js +18 -9
  25. package/src/client/components/core/BtnIcon.js +3 -2
  26. package/src/client/components/core/Content.js +13 -11
  27. package/src/client/components/core/CssCore.js +4 -0
  28. package/src/client/components/core/Docs.js +0 -3
  29. package/src/client/components/core/Input.js +34 -19
  30. package/src/client/components/core/Modal.js +29 -7
  31. package/src/client/components/core/ObjectLayerEngine.js +370 -0
  32. package/src/client/components/core/ObjectLayerEngineModal.js +1 -0
  33. package/src/client/components/core/Panel.js +7 -2
  34. package/src/client/components/core/PanelForm.js +187 -63
  35. package/src/client/components/core/VanillaJs.js +3 -0
  36. package/src/client/components/default/MenuDefault.js +94 -41
  37. package/src/client/components/default/RoutesDefault.js +2 -0
  38. package/src/client/services/default/default.management.js +1 -0
  39. package/src/client/services/document/document.service.js +97 -0
  40. package/src/client/services/file/file.service.js +2 -0
  41. package/src/client/services/user/user.service.js +1 -0
  42. package/src/client/ssr/Render.js +1 -1
  43. package/src/client/ssr/head/DefaultScripts.js +2 -0
  44. package/src/client/ssr/head/Seo.js +1 -0
  45. package/src/index.js +1 -1
  46. package/src/mailer/EmailRender.js +1 -1
  47. package/src/server/auth.js +4 -3
  48. package/src/server/client-build.js +2 -3
  49. package/src/server/client-formatted.js +40 -12
  50. package/src/server/conf.js +42 -3
  51. package/src/server/object-layer.js +196 -0
  52. package/src/server/runtime.js +18 -21
  53. package/src/server/ssr.js +52 -10
  54. package/src/server/valkey.js +89 -1
package/cli.md CHANGED
@@ -1,46 +1,47 @@
1
- ## underpost ci/cd cli v2.8.877
1
+ ## underpost ci/cd cli v2.8.881
2
2
 
3
3
  ### Usage: `underpost [options] [command]`
4
- ```
5
- Options:
6
- -V, --version output the version number
7
- -h, --help display help for command
4
+
5
+ ```
6
+ Options:
7
+ -V, --version output the version number
8
+ -h, --help display help for command
8
9
 
9
10
  Commands:
10
- new [options] <app-name> Initializes a new Underpost project with a predefined structure.
11
- start [options] <deploy-id> [env] Initiates application servers, build pipelines, or other defined services based on the deployment ID.
12
- clone [options] <uri> Clones a specified GitHub repository into the current directory.
13
- pull [options] <path> <uri> Pulls the latest changes from a specified GitHub repository.
14
- cmt [options] <path> <commit-type> [module-tag] [message] Manages commits to a GitHub repository, supporting various commit types and options.
15
- push [options] <path> <uri> Pushes committed changes from a local repository to a remote GitHub repository.
16
- env <deploy-id> [env] Sets environment variables and configurations related to a specific deployment ID.
17
- config [options] <operator> [key] [value] Manages Underpost configurations using various operators.
18
- root Displays the root path of the npm installation.
19
- cluster [options] [pod-name] Manages Kubernetes clusters, defaulting to Kind cluster initialization.
20
- deploy [options] [deploy-list] [env] Manages application deployments, defaulting to deploying development pods.
21
- secret [options] <platform> Manages secrets for various platforms.
22
- dockerfile-image-build [options] Builds a Docker image from a specified Dockerfile with various options for naming, saving, and loading.
23
- dockerfile-pull-base-images [options] Pulls required Underpost Dockerfile base images and optionally loads them into clusters.
24
- install Quickly imports Underpost npm dependencies by copying them.
25
- db [options] <deploy-list> Manages database operations, including import, export, and collection management.
26
- metadata [options] [deploy-id] [host] [path] Manages cluster metadata operations, including import and export.
27
- script [options] <operator> <script-name> [script-value] Supports a variety of built-in Underpost global scripts, their preset lifecycle events, and arbitrary custom scripts.
28
- cron [options] [deploy-list] [job-list] Manages cron jobs, including initialization, execution, and configuration updates.
29
- fs [options] [path] Manages file storage, defaulting to file upload operations.
30
- test [options] [deploy-list] Manages and runs tests, defaulting to the current Underpost default test suite.
31
- monitor [options] <deploy-id> [env] Manages health server monitoring for specified deployments.
32
- ssh [options] Import and start ssh server and client based on current default deployment ID.
33
- run [options] <runner-id> [path] Runs a script from the specified path.
34
- lxd [options] Manages LXD containers and virtual machines.
35
- baremetal [options] [workflow-id] [hostname] [ip-address] Manages baremetal server operations, including installation, database setup, commissioning, and user management.
36
- help [command] display help for command
37
-
11
+ new [options] <app-name> Initializes a new Underpost project with a predefined structure.
12
+ start [options] <deploy-id> [env] Initiates application servers, build pipelines, or other defined services based on the deployment ID.
13
+ clone [options] <uri> Clones a specified GitHub repository into the current directory.
14
+ pull [options] <path> <uri> Pulls the latest changes from a specified GitHub repository.
15
+ cmt [options] <path> <commit-type> [module-tag] [message] Manages commits to a GitHub repository, supporting various commit types and options.
16
+ push [options] <path> <uri> Pushes committed changes from a local repository to a remote GitHub repository.
17
+ env <deploy-id> [env] Sets environment variables and configurations related to a specific deployment ID.
18
+ config [options] <operator> [key] [value] Manages Underpost configurations using various operators.
19
+ root Displays the root path of the npm installation.
20
+ cluster [options] [pod-name] Manages Kubernetes clusters, defaulting to Kind cluster initialization.
21
+ deploy [options] [deploy-list] [env] Manages application deployments, defaulting to deploying development pods.
22
+ secret [options] <platform> Manages secrets for various platforms.
23
+ dockerfile-image-build [options] Builds a Docker image from a specified Dockerfile with various options for naming, saving, and loading.
24
+ dockerfile-pull-base-images [options] Pulls required Underpost Dockerfile base images and optionally loads them into clusters.
25
+ install Quickly imports Underpost npm dependencies by copying them.
26
+ db [options] <deploy-list> Manages database operations, including import, export, and collection management.
27
+ metadata [options] [deploy-id] [host] [path] Manages cluster metadata operations, including import and export.
28
+ script [options] <operator> <script-name> [script-value] Supports a variety of built-in Underpost global scripts, their preset lifecycle events, and arbitrary custom scripts.
29
+ cron [options] [deploy-list] [job-list] Manages cron jobs, including initialization, execution, and configuration updates.
30
+ fs [options] [path] Manages file storage, defaulting to file upload operations.
31
+ test [options] [deploy-list] Manages and runs tests, defaulting to the current Underpost default test suite.
32
+ monitor [options] <deploy-id> [env] Manages health server monitoring for specified deployments.
33
+ ssh [options] Import and start ssh server and client based on current default deployment ID.
34
+ run [options] <runner-id> [path] Runs a script from the specified path.
35
+ lxd [options] Manages LXD containers and virtual machines.
36
+ baremetal [options] [workflow-id] [hostname] [ip-address] Manages baremetal server operations, including installation, database setup, commissioning, and user management.
37
+ help [command] display help for command
38
+
38
39
  ```
39
40
 
40
41
  ## Commands:
41
-
42
42
 
43
43
  ### `new` :
44
+
44
45
  ```
45
46
  Usage: underpost new [options] <app-name>
46
47
 
@@ -51,13 +52,14 @@ Arguments:
51
52
 
52
53
  Options:
53
54
  --deploy-id Crete deploy ID conf env files
55
+ --cluster Create deploy ID cluster files and sync to current cluster
54
56
  --dev Sets the development cli context
55
57
  -h, --help display help for command
56
-
58
+
57
59
  ```
58
-
59
60
 
60
61
  ### `start` :
62
+
61
63
  ```
62
64
  Usage: underpost start [options] <deploy-id> [env]
63
65
 
@@ -73,11 +75,11 @@ Options:
73
75
  --run Starts application servers and monitors their health.
74
76
  --build Triggers the client-side application build process.
75
77
  -h, --help display help for command
76
-
78
+
77
79
  ```
78
-
79
80
 
80
81
  ### `clone` :
82
+
81
83
  ```
82
84
  Usage: underpost clone [options] <uri>
83
85
 
@@ -90,11 +92,11 @@ Options:
90
92
  --bare Performs a bare clone, downloading only the .git files.
91
93
  -g8 Uses the g8 repository extension for cloning.
92
94
  -h, --help display help for command
93
-
95
+
94
96
  ```
95
-
96
97
 
97
98
  ### `pull` :
99
+
98
100
  ```
99
101
  Usage: underpost pull [options] <path> <uri>
100
102
 
@@ -108,11 +110,11 @@ Arguments:
108
110
  Options:
109
111
  -g8 Uses the g8 repository extension for pulling.
110
112
  -h, --help display help for command
111
-
113
+
112
114
  ```
113
-
114
115
 
115
116
  ### `cmt` :
117
+
116
118
  ```
117
119
  Usage: underpost cmt [options] <path> <commit-type> [module-tag] [message]
118
120
 
@@ -132,11 +134,11 @@ Options:
132
134
  --copy Copies the generated commit message to the clipboard.
133
135
  --info Displays information about available commit types.
134
136
  -h, --help display help for command
135
-
137
+
136
138
  ```
137
-
138
139
 
139
140
  ### `push` :
141
+
140
142
  ```
141
143
  Usage: underpost push [options] <path> <uri>
142
144
 
@@ -150,11 +152,11 @@ Options:
150
152
  -f Forces the push, overwriting the remote repository history.
151
153
  -g8 Uses the g8 repository extension for pushing.
152
154
  -h, --help display help for command
153
-
155
+
154
156
  ```
155
-
156
157
 
157
158
  ### `env` :
159
+
158
160
  ```
159
161
  Usage: underpost env [options] <deploy-id> [env]
160
162
 
@@ -169,11 +171,11 @@ Arguments:
169
171
 
170
172
  Options:
171
173
  -h, --help display help for command
172
-
174
+
173
175
  ```
174
-
175
176
 
176
177
  ### `config` :
178
+
177
179
  ```
178
180
  Usage: underpost config [options] <operator> [key] [value]
179
181
 
@@ -188,11 +190,11 @@ Arguments:
188
190
  Options:
189
191
  --plain Prints the configuration value in plain text.
190
192
  -h, --help display help for command
191
-
193
+
192
194
  ```
193
-
194
195
 
195
196
  ### `root` :
197
+
196
198
  ```
197
199
  Usage: underpost root [options]
198
200
 
@@ -200,11 +202,11 @@ Displays the root path of the npm installation.
200
202
 
201
203
  Options:
202
204
  -h, --help display help for command
203
-
205
+
204
206
  ```
205
-
206
207
 
207
208
  ### `cluster` :
209
+
208
210
  ```
209
211
  Usage: underpost cluster [options] [pod-name]
210
212
 
@@ -261,11 +263,11 @@ Options:
261
263
  --k3s Initializes the cluster using K3s (Lightweight
262
264
  Kubernetes).
263
265
  -h, --help display help for command
264
-
266
+
265
267
  ```
266
-
267
268
 
268
269
  ### `deploy` :
270
+
269
271
  ```
270
272
  Usage: underpost deploy [options] [deploy-list] [env]
271
273
 
@@ -314,11 +316,11 @@ Options:
314
316
  deployment operations.
315
317
  --restore-hosts Restores default `/etc/hosts` entries.
316
318
  -h, --help display help for command
317
-
319
+
318
320
  ```
319
-
320
321
 
321
322
  ### `secret` :
323
+
322
324
  ```
323
325
  Usage: underpost secret [options] <platform>
324
326
 
@@ -336,11 +338,11 @@ Options:
336
338
  --list Lists all available secrets for the
337
339
  platform.
338
340
  -h, --help display help for command
339
-
341
+
340
342
  ```
341
-
342
343
 
343
344
  ### `dockerfile-image-build` :
345
+
344
346
  ```
345
347
  Usage: underpost dockerfile-image-build [options]
346
348
 
@@ -367,11 +369,11 @@ Options:
367
369
  cache.
368
370
  --k3s-load Loads the image into a K3s cluster.
369
371
  -h, --help display help for command
370
-
372
+
371
373
  ```
372
-
373
374
 
374
375
  ### `dockerfile-pull-base-images` :
376
+
375
377
  ```
376
378
  Usage: underpost dockerfile-pull-base-images [options]
377
379
 
@@ -385,11 +387,11 @@ Options:
385
387
  --version Sets a custom version for the base images.
386
388
  --k3s-load Loads the image into a K3s cluster.
387
389
  -h, --help display help for command
388
-
390
+
389
391
  ```
390
-
391
392
 
392
393
  ### `install` :
394
+
393
395
  ```
394
396
  Usage: underpost install [options]
395
397
 
@@ -397,11 +399,11 @@ Quickly imports Underpost npm dependencies by copying them.
397
399
 
398
400
  Options:
399
401
  -h, --help display help for command
400
-
402
+
401
403
  ```
402
-
403
404
 
404
405
  ### `db` :
406
+
405
407
  ```
406
408
  Usage: underpost db [options] <deploy-list>
407
409
 
@@ -431,11 +433,11 @@ Options:
431
433
  --ns <ns-name> Optional: Specifies the namespace context for
432
434
  database operations.
433
435
  -h, --help display help for command
434
-
436
+
435
437
  ```
436
-
437
438
 
438
439
  ### `metadata` :
440
+
439
441
  ```
440
442
  Usage: underpost metadata [options] [deploy-id] [host] [path]
441
443
 
@@ -454,11 +456,11 @@ Options:
454
456
  --generate Generate cluster metadata
455
457
  --itc Apply under container execution context
456
458
  -h, --help display help for command
457
-
459
+
458
460
  ```
459
-
460
461
 
461
462
  ### `script` :
463
+
462
464
  ```
463
465
  Usage: underpost script [options] <operator> <script-name> [script-value]
464
466
 
@@ -480,11 +482,11 @@ Options:
480
482
  execution.
481
483
  --pod-name <pod-name> Optional: Specifies the pod name for script execution.
482
484
  -h, --help display help for command
483
-
485
+
484
486
  ```
485
-
486
487
 
487
488
  ### `cron` :
489
+
488
490
  ```
489
491
  Usage: underpost cron [options] [deploy-list] [job-list]
490
492
 
@@ -502,11 +504,11 @@ Options:
502
504
  --init Initializes cron jobs for the default deployment ID.
503
505
  --git Uploads cron job configurations to GitHub.
504
506
  -h, --help display help for command
505
-
507
+
506
508
  ```
507
-
508
509
 
509
510
  ### `fs` :
511
+
510
512
  ```
511
513
  Usage: underpost fs [options] [path]
512
514
 
@@ -524,11 +526,11 @@ Options:
524
526
  --force Forces the action, overriding any warnings or conflicts.
525
527
  --storage-file-path <storage-file-path> Specifies a custom file storage path.
526
528
  -h, --help display help for command
527
-
529
+
528
530
  ```
529
-
530
531
 
531
532
  ### `test` :
533
+
532
534
  ```
533
535
  Usage: underpost test [options] [deploy-list]
534
536
 
@@ -550,11 +552,11 @@ Options:
550
552
  --kind-type <kind-type> Optional: Specifies the Kind cluster type for
551
553
  tests.
552
554
  -h, --help display help for command
553
-
555
+
554
556
  ```
555
-
556
557
 
557
558
  ### `monitor` :
559
+
558
560
  ```
559
561
  Usage: underpost monitor [options] <deploy-id> [env]
560
562
 
@@ -577,11 +579,11 @@ Options:
577
579
  --sync Synchronizes with current proxy deployments and
578
580
  traffic configurations.
579
581
  -h, --help display help for command
580
-
582
+
581
583
  ```
582
-
583
584
 
584
585
  ### `ssh` :
586
+
585
587
  ```
586
588
  Usage: underpost ssh [options]
587
589
 
@@ -591,11 +593,11 @@ Options:
591
593
  --generate Generates new ssh credential and stores it in current private
592
594
  keys file storage.
593
595
  -h, --help display help for command
594
-
596
+
595
597
  ```
596
-
597
598
 
598
599
  ### `run` :
600
+
599
601
  ```
600
602
  Usage: underpost run [options] <runner-id> [path]
601
603
 
@@ -618,12 +620,14 @@ Options:
618
620
  --image-name <image-name> Optional: Specifies the image name for test execution.
619
621
  --container-name <container-name> Optional: Specifies the container name for test execution.
620
622
  --namespace <namespace> Optional: Specifies the namespace for test execution.
623
+ --kubeadm Flag to indicate Kubeadm cluster type context
624
+ --k3s Flag to indicate K3s cluster type context
621
625
  -h, --help display help for command
622
-
626
+
623
627
  ```
624
-
625
628
 
626
629
  ### `lxd` :
630
+
627
631
  ```
628
632
  Usage: underpost lxd [options]
629
633
 
@@ -664,11 +668,11 @@ Options:
664
668
  --auto-expose-k8s-ports <vm-id> Automatically exposes common Kubernetes
665
669
  ports for the specified VM.
666
670
  -h, --help display help for command
667
-
671
+
668
672
  ```
669
-
670
673
 
671
674
  ### `baremetal` :
675
+
672
676
  ```
673
677
  Usage: underpost baremetal [options] [workflow-id] [hostname] [ip-address]
674
678
 
@@ -702,6 +706,5 @@ Options:
702
706
  baremetal operations.
703
707
  --ls Lists available boot resources and machines.
704
708
  -h, --help display help for command
705
-
709
+
706
710
  ```
707
-
package/conf.js CHANGED
@@ -92,6 +92,16 @@ const DefaultConf = /**/ {
92
92
  { path: '/default-management', client: 'Default', ssr: 'Default' },
93
93
  { client: 'Default', ssr: 'Default', path: '/404', title: '404 Not Found' },
94
94
  { client: 'Default', ssr: 'Default', path: '/500', title: '500 Server Error' },
95
+ {
96
+ path: '/blog',
97
+ client: 'Default',
98
+ ssr: 'Default',
99
+ },
100
+ {
101
+ path: '/chat',
102
+ client: 'Default',
103
+ ssr: 'Default',
104
+ },
95
105
  ],
96
106
  dists: [
97
107
  {
@@ -108,7 +118,22 @@ const DefaultConf = /**/ {
108
118
  import_name_build: '/dist/sortablejs/sortable.complete.esm.js',
109
119
  },
110
120
  { folder: './node_modules/validator', public_folder: '/dist/validator' },
111
- { folder: './node_modules/@loadingio/css-spinner/entries', public_folder: '/dist/loadingio' },
121
+ {
122
+ folder: './node_modules/easymde/dist',
123
+ public_folder: '/dist/easymde',
124
+ },
125
+ {
126
+ folder: './node_modules/marked/lib',
127
+ public_folder: '/dist/marked',
128
+ import_name: 'marked',
129
+ import_name_build: '/dist/marked/marked.esm.js',
130
+ },
131
+ {
132
+ folder: './node_modules/vanilla-jsoneditor/standalone.js',
133
+ public_folder: '/dist/vanilla-jsoneditor/standalone.js',
134
+ import_name: 'vanilla-jsoneditor',
135
+ import_name_build: '/dist/vanilla-jsoneditor/standalone.js',
136
+ },
112
137
  {
113
138
  import_name: 'ag-grid-community',
114
139
  import_name_build: '/dist/ag-grid-community/ag-grid-community.min.js',
@@ -125,7 +150,7 @@ const DefaultConf = /**/ {
125
150
  },
126
151
  { folder: './node_modules/peerjs/dist', public_folder: '/dist/peerjs' },
127
152
  ],
128
- services: ['default', 'core', 'user', 'test', 'file'],
153
+ services: ['default', 'core', 'user', 'test', 'file', 'document'],
129
154
  },
130
155
  },
131
156
  ssr: {
@@ -145,7 +170,7 @@ const DefaultConf = /**/ {
145
170
  '/': {
146
171
  client: 'default',
147
172
  runtime: 'nodejs',
148
- apis: ['default', 'core', 'user', 'test', 'file'],
173
+ apis: ['default', 'core', 'user', 'test', 'file', 'document'],
149
174
  origins: [],
150
175
  minifyBuild: false,
151
176
  iconsBuild: false,
@@ -17,7 +17,7 @@ spec:
17
17
  spec:
18
18
  containers:
19
19
  - name: dd-default-development-blue
20
- image: localhost/rockylinux9-underpost:v2.8.877
20
+ image: localhost/rockylinux9-underpost:v2.8.881
21
21
  # resources:
22
22
  # requests:
23
23
  # memory: "124Ki"
@@ -100,7 +100,7 @@ spec:
100
100
  spec:
101
101
  containers:
102
102
  - name: dd-default-development-green
103
- image: localhost/rockylinux9-underpost:v2.8.877
103
+ image: localhost/rockylinux9-underpost:v2.8.881
104
104
  # resources:
105
105
  # requests:
106
106
  # memory: "124Ki"
@@ -17,7 +17,7 @@ spec:
17
17
  spec:
18
18
  containers:
19
19
  - name: dd-test-development-blue
20
- image: localhost/rockylinux9-underpost:v2.8.877
20
+ image: localhost/rockylinux9-underpost:v2.8.881
21
21
  # resources:
22
22
  # requests:
23
23
  # memory: "94Ki"
@@ -104,7 +104,7 @@ spec:
104
104
  spec:
105
105
  containers:
106
106
  - name: dd-test-development-green
107
- image: localhost/rockylinux9-underpost:v2.8.877
107
+ image: localhost/rockylinux9-underpost:v2.8.881
108
108
  # resources:
109
109
  # requests:
110
110
  # memory: "94Ki"
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "type": "module",
3
3
  "main": "src/index.js",
4
4
  "name": "underpost",
5
- "version": "2.8.877",
5
+ "version": "2.8.881",
6
6
  "description": "pwa api rest template",
7
7
  "scripts": {
8
8
  "start": "env-cmd -f .env.production node --max-old-space-size=8192 src/server",
@@ -51,7 +51,6 @@
51
51
  "dependencies": {
52
52
  "@fortawesome/fontawesome-free": "^6.4.2",
53
53
  "@fullcalendar/rrule": "^6.1.15",
54
- "@loadingio/css-spinner": "^2.0.2",
55
54
  "@neodrag/vanilla": "^2.0.3",
56
55
  "adm-zip": "^0.5.10",
57
56
  "ag-grid-community": "^31.3.4",
@@ -0,0 +1,66 @@
1
+ import { loggerFactory } from '../../server/logger.js';
2
+ import { DocumentService } from './document.service.js';
3
+ const logger = loggerFactory(import.meta);
4
+
5
+ const DocumentController = {
6
+ post: async (req, res, options) => {
7
+ try {
8
+ return res.status(200).json({
9
+ status: 'success',
10
+ data: await DocumentService.post(req, res, options),
11
+ });
12
+ } catch (error) {
13
+ logger.error(error, error.stack);
14
+ return res.status(400).json({
15
+ status: 'error',
16
+ message: error.message,
17
+ });
18
+ }
19
+ },
20
+ get: async (req, res, options) => {
21
+ try {
22
+ return res.status(200).json({
23
+ status: 'success',
24
+ data: await DocumentService.get(req, res, options),
25
+ });
26
+ } catch (error) {
27
+ logger.error(error, error.stack);
28
+ return res.status(400).json({
29
+ status: 'error',
30
+ message: error.message,
31
+ });
32
+ }
33
+ },
34
+ delete: async (req, res, options) => {
35
+ try {
36
+ const result = await DocumentService.delete(req, res, options);
37
+ return res.status(200).json({
38
+ status: 'success',
39
+ data: result,
40
+ });
41
+ } catch (error) {
42
+ logger.error(error, error.stack);
43
+ return res.status(400).json({
44
+ status: 'error',
45
+ message: error.message,
46
+ });
47
+ }
48
+ },
49
+ put: async (req, res, options) => {
50
+ try {
51
+ const result = await DocumentService.put(req, res, options);
52
+ return res.status(200).json({
53
+ status: 'success',
54
+ data: result,
55
+ });
56
+ } catch (error) {
57
+ logger.error(error, error.stack);
58
+ return res.status(400).json({
59
+ status: 'error',
60
+ message: error.message,
61
+ });
62
+ }
63
+ },
64
+ };
65
+
66
+ export { DocumentController };
@@ -0,0 +1,51 @@
1
+ import { Schema, model, Types } from 'mongoose';
2
+
3
+ // https://mongoosejs.com/docs/2.7.x/docs/schematypes.html
4
+
5
+ const DocumentSchema = new Schema(
6
+ {
7
+ userId: {
8
+ type: Schema.Types.ObjectId,
9
+ ref: 'User',
10
+ },
11
+ location: { type: String },
12
+ title: { type: String },
13
+ tags: [{ type: String }],
14
+ fileId: {
15
+ type: Schema.Types.ObjectId,
16
+ ref: 'File',
17
+ },
18
+ mdFileId: {
19
+ type: Schema.Types.ObjectId,
20
+ ref: 'File',
21
+ },
22
+ },
23
+ {
24
+ timestamps: true,
25
+ },
26
+ );
27
+
28
+ const DocumentModel = model('Document', DocumentSchema);
29
+
30
+ const ProviderSchema = DocumentSchema;
31
+
32
+ const DocumentDto = {
33
+ populate: {
34
+ file: () => {
35
+ return {
36
+ path: 'fileId',
37
+ model: 'File',
38
+ select: '_id name mimetype',
39
+ };
40
+ },
41
+ user: () => {
42
+ return {
43
+ path: 'userId',
44
+ model: 'User',
45
+ select: '_id email username',
46
+ };
47
+ },
48
+ },
49
+ };
50
+
51
+ export { DocumentSchema, DocumentModel, ProviderSchema, DocumentDto };