@into-cps-association/libms 0.4.5 → 0.4.7
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/DEVELOPER.md +62 -0
- package/DOCKER.md +295 -0
- package/compose.lib.dev.yml +9 -0
- package/compose.lib.yml +8 -0
- package/dist/src/app.module.d.ts +2 -1
- package/dist/src/app.module.js +14 -16
- package/dist/src/app.module.js.map +1 -1
- package/dist/src/bootstrap.d.ts +3 -3
- package/dist/src/bootstrap.js +10 -13
- package/dist/src/bootstrap.js.map +1 -1
- package/dist/src/cloudcmd/cloudcmd.d.ts +1 -5
- package/dist/src/cloudcmd/cloudcmd.js +15 -9
- package/dist/src/cloudcmd/cloudcmd.js.map +1 -1
- package/dist/src/enums/config-mode.enum.d.ts +4 -0
- package/dist/src/enums/config-mode.enum.js +6 -0
- package/dist/src/enums/config-mode.enum.js.map +1 -0
- package/dist/src/files/files-service.factory.d.ts +5 -0
- package/dist/src/files/files-service.factory.js +22 -0
- package/dist/src/files/files-service.factory.js.map +1 -0
- package/dist/src/files/files.module.d.ts +2 -1
- package/dist/src/files/files.module.js +23 -9
- package/dist/src/files/files.module.js.map +1 -1
- package/dist/src/files/files.resolver.d.ts +8 -0
- package/dist/src/files/{resolvers/files.resolver.js → files.resolver.js} +14 -14
- package/dist/src/files/files.resolver.js.map +1 -0
- package/dist/src/files/git/git-files.module.d.ts +2 -0
- package/dist/src/files/git/git-files.module.js +18 -0
- package/dist/src/files/git/git-files.module.js.map +1 -0
- package/dist/src/files/git/git-files.service.d.ts +9 -0
- package/dist/src/files/git/git-files.service.js +29 -0
- package/dist/src/files/git/git-files.service.js.map +1 -0
- package/dist/src/files/interfaces/files.service.interface.d.ts +6 -3
- package/dist/src/files/interfaces/files.service.interface.js +1 -2
- package/dist/src/files/interfaces/files.service.interface.js.map +1 -1
- package/dist/src/files/local/local-files.module.d.ts +2 -0
- package/dist/src/files/local/local-files.module.js +18 -0
- package/dist/src/files/local/local-files.module.js.map +1 -0
- package/dist/src/files/local/local-files.service.d.ts +14 -0
- package/dist/src/files/{services → local}/local-files.service.js +17 -15
- package/dist/src/files/local/local-files.service.js.map +1 -0
- package/dist/src/main.js +4 -6
- package/dist/src/main.js.map +1 -1
- package/dist/src/types.d.ts +19 -19
- package/dist/src/types.js +56 -59
- package/dist/src/types.js.map +1 -1
- package/dist/test/cloudcmd/cloudcmd.spec.js +14 -16
- package/dist/test/cloudcmd/cloudcmd.spec.js.map +1 -1
- package/dist/test/e2e/app.e2e.spec.js +18 -18
- package/dist/test/e2e/app.e2e.spec.js.map +1 -1
- package/dist/test/integration/files.service.integration.spec.js +28 -19
- package/dist/test/integration/files.service.integration.spec.js.map +1 -1
- package/dist/test/testUtil.d.ts +66 -68
- package/dist/test/testUtil.js +18 -23
- package/dist/test/testUtil.js.map +1 -1
- package/dist/test/unit/files-service.factory.unit.spec.js +17 -16
- package/dist/test/unit/files-service.factory.unit.spec.js.map +1 -1
- package/dist/test/unit/files.resolver.unit.spec.js +26 -24
- package/dist/test/unit/files.resolver.unit.spec.js.map +1 -1
- package/dist/test/unit/local-files.service.unit.spec.js +23 -24
- package/dist/test/unit/local-files.service.unit.spec.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eslint.config.js +60 -0
- package/jest.config.ts +47 -0
- package/package.json +54 -48
- package/src/app.module.ts +1 -1
- package/src/bootstrap.ts +3 -3
- package/src/cloudcmd/cloudcmd.ts +11 -3
- package/src/enums/config-mode.enum.ts +4 -0
- package/src/files/files-service.factory.ts +19 -0
- package/src/files/files.module.ts +24 -4
- package/src/files/{resolvers/files.resolver.ts → files.resolver.ts} +9 -8
- package/src/files/git/git-files.module.ts +8 -0
- package/src/files/git/git-files.service.ts +20 -0
- package/src/files/interfaces/files.service.interface.ts +4 -1
- package/src/files/local/local-files.module.ts +8 -0
- package/src/files/{services → local}/local-files.service.ts +15 -10
- package/src/main.ts +1 -1
- package/test/cloudcmd/cloudcmd.spec.ts +4 -6
- package/test/e2e/app.e2e.spec.ts +4 -3
- package/test/integration/files.service.integration.spec.ts +19 -4
- package/test/unit/files-service.factory.unit.spec.ts +18 -11
- package/test/unit/files.resolver.unit.spec.ts +19 -12
- package/test/unit/local-files.service.unit.spec.ts +4 -2
- package/tsconfig.json +10 -7
- package/.env +0 -6
- package/.eslintignore +0 -6
- package/.eslintrc +0 -53
- package/coverage/clover.xml +0 -162
- package/coverage/cobertura-coverage.xml +0 -306
- package/coverage/coverage-final.json +0 -8
- package/coverage/lcov-report/base.css +0 -224
- package/coverage/lcov-report/block-navigation.js +0 -87
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +0 -176
- package/coverage/lcov-report/prettify.css +0 -1
- package/coverage/lcov-report/prettify.js +0 -2
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +0 -196
- package/coverage/lcov-report/src/bootstrap.ts.html +0 -196
- package/coverage/lcov-report/src/cloudcmd/cloudcmd.ts.html +0 -181
- package/coverage/lcov-report/src/cloudcmd/index.html +0 -116
- package/coverage/lcov-report/src/files/files.module.ts.html +0 -112
- package/coverage/lcov-report/src/files/index.html +0 -116
- package/coverage/lcov-report/src/files/resolvers/files.resolver.ts.html +0 -154
- package/coverage/lcov-report/src/files/resolvers/index.html +0 -116
- package/coverage/lcov-report/src/files/services/files-service.factory.ts.html +0 -151
- package/coverage/lcov-report/src/files/services/index.html +0 -131
- package/coverage/lcov-report/src/files/services/local-files.service.ts.html +0 -313
- package/coverage/lcov-report/src/index.html +0 -131
- package/coverage/lcov-report/src/types.ts.html +0 -361
- package/coverage/lcov.info +0 -237
- package/dist/src/files/resolvers/files.resolver.d.ts +0 -8
- package/dist/src/files/resolvers/files.resolver.js.map +0 -1
- package/dist/src/files/services/files-service.factory.d.ts +0 -12
- package/dist/src/files/services/files-service.factory.js +0 -40
- package/dist/src/files/services/files-service.factory.js.map +0 -1
- package/dist/src/files/services/local-files.service.d.ts +0 -11
- package/dist/src/files/services/local-files.service.js.map +0 -1
- package/jest.config.json +0 -30
- package/src/files/services/files-service.factory.ts +0 -22
- /package/{pm2.config.js → pm2.config.cjs} +0 -0
package/DEVELOPER.md
CHANGED
|
@@ -43,6 +43,30 @@ The URL endpoint for this microservice is located at: `localhost:PORT/lib`
|
|
|
43
43
|
|
|
44
44
|
The [API](./API.md) page shows sample queries and responses.
|
|
45
45
|
|
|
46
|
+
## Manual testing
|
|
47
|
+
|
|
48
|
+
As of now, some features require manual testing or attention.
|
|
49
|
+
|
|
50
|
+
### CloudCMD (a npm package dependency)
|
|
51
|
+
|
|
52
|
+
Due to how CloudCMD works,
|
|
53
|
+
it is required to manually run `yarn test:http` with `LOCAL_PATH` both as an
|
|
54
|
+
absolute path and local path. For example, the manual tests
|
|
55
|
+
need to be done with the following `LOCAL_PATH` values.
|
|
56
|
+
|
|
57
|
+
| OS | Absolute Path | Relative Path |
|
|
58
|
+
| ------- | ----------------------------- | ------------- |
|
|
59
|
+
| Windows | C:\DTaaS\files | ..\..\files |
|
|
60
|
+
| Linux | /Users/\<Username\>/DTaaS/files | ../../files |
|
|
61
|
+
|
|
62
|
+
### PM2
|
|
63
|
+
|
|
64
|
+
the pm2 might not close spawned processes correctly,
|
|
65
|
+
therefore please use the following command to kill a process.
|
|
66
|
+
`pm2 del <id>`.
|
|
67
|
+
|
|
68
|
+
**NOTE:** to see the processes spawned by pm2 use `pm2 list`
|
|
69
|
+
|
|
46
70
|
## :package: :ship: Packages
|
|
47
71
|
|
|
48
72
|
### Docker images
|
|
@@ -86,6 +110,44 @@ with publishing **libms npm package** in local computer.
|
|
|
86
110
|
Application of the advice given on that page for **libms** will require
|
|
87
111
|
running the following commands.
|
|
88
112
|
|
|
113
|
+
## Use in Docker Environment
|
|
114
|
+
|
|
115
|
+
### Adjust Configuration (Optional)
|
|
116
|
+
|
|
117
|
+
The microservices require configuration and the docker version
|
|
118
|
+
of the microservices uses the configuration
|
|
119
|
+
file available in `config/.env.default`.
|
|
120
|
+
|
|
121
|
+
Please add a `.env` file with the environment variables for
|
|
122
|
+
the docker compose file to use.
|
|
123
|
+
e.g.
|
|
124
|
+
|
|
125
|
+
```sh
|
|
126
|
+
PORT='4001'
|
|
127
|
+
MODE='local'
|
|
128
|
+
LOCAL_PATH='..\..\files'
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Use
|
|
132
|
+
|
|
133
|
+
The commands to start and stop the appliation are:
|
|
134
|
+
|
|
135
|
+
**NOTE**: the docker compose file is located in the `servers/lib` directory.
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
docker compose -f compose.lib.dev.yml up -d
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
This command brings up the lib docker container and makes
|
|
142
|
+
the website available at <http://localhost:4001>.
|
|
143
|
+
The `config/.env.default` file is used as the microservice configuration.
|
|
144
|
+
If the configuration values are changed, please restart the container.
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
docker compose -f compose.lib.dev.yml down
|
|
148
|
+
docker compose -f compose.lib.dev.yml up -d
|
|
149
|
+
```
|
|
150
|
+
|
|
89
151
|
### Publish
|
|
90
152
|
|
|
91
153
|
```bash
|
package/DOCKER.md
ADDED
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
# Overview
|
|
2
|
+
|
|
3
|
+
The **libms microservice** is a simplified file manager providing graphQL API.
|
|
4
|
+
It has two features:
|
|
5
|
+
|
|
6
|
+
* provide a listing of directory contents.
|
|
7
|
+
* transfer a file to user.
|
|
8
|
+
|
|
9
|
+
## Use in Docker Environment
|
|
10
|
+
|
|
11
|
+
### Create Docker Compose File
|
|
12
|
+
|
|
13
|
+
Create an empty file named `compose.lib.yml` and copy
|
|
14
|
+
the following into the file:
|
|
15
|
+
|
|
16
|
+
```yml
|
|
17
|
+
services:
|
|
18
|
+
libms:
|
|
19
|
+
image: intocps/libms:latest
|
|
20
|
+
restart: unless-stopped
|
|
21
|
+
volumes:
|
|
22
|
+
- ./files:/dtaas/libms/files
|
|
23
|
+
ports:
|
|
24
|
+
- "4001:4001"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Create Files Directory
|
|
28
|
+
|
|
29
|
+
The **libms microservice** serves files available from
|
|
30
|
+
`files` directory.
|
|
31
|
+
So, create a directory named `files` with the following structure:
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
files/
|
|
35
|
+
data/
|
|
36
|
+
digital_twins/
|
|
37
|
+
functions/
|
|
38
|
+
models/
|
|
39
|
+
tools/
|
|
40
|
+
common/
|
|
41
|
+
data/
|
|
42
|
+
functions/
|
|
43
|
+
models/
|
|
44
|
+
tools/
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Please create this `files` directory
|
|
48
|
+
in the same file system location as that of the `compose.lib.yml` file.
|
|
49
|
+
|
|
50
|
+
### Run
|
|
51
|
+
|
|
52
|
+
Use the following commands to start and stop the container respectively:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
docker compose -f compose.lib.yml up -d
|
|
56
|
+
docker compose -f compose.lib.yml down
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
The lib microservice website will become available at <http://localhost:4001>.
|
|
60
|
+
|
|
61
|
+
## Application Programming Interface (API)
|
|
62
|
+
|
|
63
|
+
The lib microservice application provides services at
|
|
64
|
+
two end points:
|
|
65
|
+
|
|
66
|
+
### HTTP protocol
|
|
67
|
+
|
|
68
|
+
**URL:** `localhost:4001/lib/files`
|
|
69
|
+
|
|
70
|
+
The regular file upload and download options become available
|
|
71
|
+
via web browser.
|
|
72
|
+
|
|
73
|
+
### GraphQL protocol
|
|
74
|
+
|
|
75
|
+
**URL:** `localhost:4001/lib`
|
|
76
|
+
|
|
77
|
+
<details>
|
|
78
|
+
<summary>GraphQL API details</summary>
|
|
79
|
+
The lib microservice takes two distinct GraphQL queries.
|
|
80
|
+
|
|
81
|
+
#### Directory Listing
|
|
82
|
+
|
|
83
|
+
This query receives directory path and provides list of files
|
|
84
|
+
in that directory. A sample query and response are given here.
|
|
85
|
+
|
|
86
|
+
``` graphql
|
|
87
|
+
query {
|
|
88
|
+
listDirectory(path: ".") {
|
|
89
|
+
repository {
|
|
90
|
+
tree {
|
|
91
|
+
blobs {
|
|
92
|
+
edges {
|
|
93
|
+
node {
|
|
94
|
+
name
|
|
95
|
+
type
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
trees {
|
|
100
|
+
edges {
|
|
101
|
+
node {
|
|
102
|
+
name
|
|
103
|
+
type
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
``` graphql
|
|
114
|
+
{
|
|
115
|
+
"data": {
|
|
116
|
+
"listDirectory": {
|
|
117
|
+
"repository": {
|
|
118
|
+
"tree": {
|
|
119
|
+
"blobs": {
|
|
120
|
+
"edges": []
|
|
121
|
+
},
|
|
122
|
+
"trees": {
|
|
123
|
+
"edges": [
|
|
124
|
+
{
|
|
125
|
+
"node": {
|
|
126
|
+
"name": "common",
|
|
127
|
+
"type": "tree"
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"node": {
|
|
132
|
+
"name": "data",
|
|
133
|
+
"type": "tree"
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"node": {
|
|
138
|
+
"name": "digital twins",
|
|
139
|
+
"type": "tree"
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"node": {
|
|
144
|
+
"name": "functions",
|
|
145
|
+
"type": "tree"
|
|
146
|
+
}
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"node": {
|
|
150
|
+
"name": "models",
|
|
151
|
+
"type": "tree"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
"node": {
|
|
156
|
+
"name": "tools",
|
|
157
|
+
"type": "tree"
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
]
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
#### Fetch a File
|
|
170
|
+
|
|
171
|
+
This query receives directory path and send the file contents to user in response.
|
|
172
|
+
|
|
173
|
+
To check this query, create a file `files/data/welcome.txt`
|
|
174
|
+
with content of `hello world`.
|
|
175
|
+
|
|
176
|
+
A sample query and response are given here.
|
|
177
|
+
|
|
178
|
+
```graphql
|
|
179
|
+
query {
|
|
180
|
+
readFile(path: "data/welcome.txt") {
|
|
181
|
+
repository {
|
|
182
|
+
blobs {
|
|
183
|
+
nodes {
|
|
184
|
+
name
|
|
185
|
+
rawBlob
|
|
186
|
+
rawTextBlob
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
```graphql
|
|
195
|
+
{
|
|
196
|
+
"data": {
|
|
197
|
+
"readFile": {
|
|
198
|
+
"repository": {
|
|
199
|
+
"blobs": {
|
|
200
|
+
"nodes": [
|
|
201
|
+
{
|
|
202
|
+
"name": "welcome.txt",
|
|
203
|
+
"rawBlob": "hello world",
|
|
204
|
+
"rawTextBlob": "hello world"
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Direct HTTP API Calls in lieu of GraphQL API Calls
|
|
215
|
+
|
|
216
|
+
The lib microservice also supports making API calls using HTTP POST requests.
|
|
217
|
+
Simply send a POST request to the URL endpoint with the GraphQL query in
|
|
218
|
+
the request body. Make sure to set the Content-Type header to
|
|
219
|
+
"application/json".
|
|
220
|
+
|
|
221
|
+
The easiest way to perform HTTP requests is to use
|
|
222
|
+
[HTTPie](https://github.com/httpie/desktop/releases)
|
|
223
|
+
desktop application.
|
|
224
|
+
You can download the Ubuntu AppImage and run it. Select the following options:
|
|
225
|
+
|
|
226
|
+
```txt
|
|
227
|
+
Method: POST
|
|
228
|
+
URL: localhost:4001
|
|
229
|
+
Body: <<copy the json code from examples below>>
|
|
230
|
+
Content Type: text/json
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
Here are examples of the HTTP requests and responses for the HTTP API calls.
|
|
234
|
+
|
|
235
|
+
#### Directory listing
|
|
236
|
+
|
|
237
|
+
<!-- markdownlint-disable MD013 -->
|
|
238
|
+
|
|
239
|
+
```http
|
|
240
|
+
POST /lib HTTP/1.1
|
|
241
|
+
Host: localhost:4001
|
|
242
|
+
Content-Type: application/json
|
|
243
|
+
Content-Length: 388
|
|
244
|
+
|
|
245
|
+
{
|
|
246
|
+
"query":"query {\n listDirectory(path: \".\") {\n repository {\n tree {\n blobs {\n edges {\n node {\n name\n type\n }\n }\n }\n trees {\n edges {\n node {\n name\n type\n }\n }\n }\n }\n }\n }\n}"
|
|
247
|
+
}
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
This HTTP POST request will generate the following HTTP response message.
|
|
251
|
+
|
|
252
|
+
```http
|
|
253
|
+
HTTP/1.1 200 OK
|
|
254
|
+
Access-Control-Allow-Origin: *
|
|
255
|
+
Connection: close
|
|
256
|
+
Content-Length: 306
|
|
257
|
+
Content-Type: application/json; charset=utf-8
|
|
258
|
+
Date: Tue, 26 Sep 2023 20:26:49 GMT
|
|
259
|
+
X-Powered-By: Express
|
|
260
|
+
|
|
261
|
+
{"data":{"listDirectory":{"repository":{"tree":{"blobs":{"edges":[]},"trees":{"edges":[{"node":{"name":"data","type":"tree"}},{"node":{"name":"digital twins","type":"tree"}},{"node":{"name":"functions","type":"tree"}},{"node":{"name":"models","type":"tree"}},{"node":{"name":"tools","type":"tree"}}]}}}}}}
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
#### Fetch a file
|
|
265
|
+
|
|
266
|
+
This query receives directory path and send the file contents to user in response.
|
|
267
|
+
|
|
268
|
+
To check this query, create a file `files/data/welcome.txt`
|
|
269
|
+
with content of `hello world`.
|
|
270
|
+
|
|
271
|
+
```http
|
|
272
|
+
POST /lib HTTP/1.1
|
|
273
|
+
Host: localhost:4001
|
|
274
|
+
Content-Type: application/json
|
|
275
|
+
Content-Length: 217
|
|
276
|
+
|
|
277
|
+
{
|
|
278
|
+
"query":"query {\n readFile(path: \"data/welcome.txt\") {\n repository {\n blobs {\n nodes {\n name\n rawBlob\n rawTextBlob\n }\n }\n }\n }\n}"
|
|
279
|
+
}
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
```http
|
|
283
|
+
HTTP/1.1 200 OK
|
|
284
|
+
Access-Control-Allow-Origin: *
|
|
285
|
+
Connection: close
|
|
286
|
+
Content-Length: 134
|
|
287
|
+
Content-Type: application/json; charset=utf-8
|
|
288
|
+
Date: Wed, 27 Sep 2023 09:17:18 GMT
|
|
289
|
+
X-Powered-By: Express
|
|
290
|
+
|
|
291
|
+
{"data":{"readFile":{"repository":{"blobs":{"nodes":[{"name":"welcome.txt","rawBlob":"hello world","rawTextBlob":"hello world"}]}}}}}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
<!-- markdownlint-enable MD013 -->
|
|
295
|
+
</details>
|
package/compose.lib.yml
ADDED
package/dist/src/app.module.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export default class AppModule {
|
|
1
|
+
export default class AppModule {
|
|
2
|
+
}
|
package/dist/src/app.module.js
CHANGED
|
@@ -1,36 +1,34 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
6
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const files_module_1 = require("./files/files.module");
|
|
7
|
+
import { ConfigModule, ConfigService } from '@nestjs/config';
|
|
8
|
+
import { Module } from '@nestjs/common';
|
|
9
|
+
import { GraphQLModule } from '@nestjs/graphql';
|
|
10
|
+
import { ApolloDriver } from '@nestjs/apollo';
|
|
11
|
+
import { join } from 'path';
|
|
12
|
+
import FilesModule from './files/files.module.js';
|
|
15
13
|
let AppModule = class AppModule {
|
|
16
14
|
};
|
|
17
15
|
AppModule = __decorate([
|
|
18
|
-
|
|
16
|
+
Module({
|
|
19
17
|
imports: [
|
|
20
|
-
|
|
18
|
+
ConfigModule.forRoot({
|
|
21
19
|
isGlobal: true,
|
|
22
20
|
}),
|
|
23
|
-
|
|
24
|
-
driver:
|
|
21
|
+
GraphQLModule.forRootAsync({
|
|
22
|
+
driver: ApolloDriver,
|
|
25
23
|
useFactory: (configService) => ({
|
|
26
|
-
autoSchemaFile:
|
|
24
|
+
autoSchemaFile: join(process.cwd(), 'src/schema.gql'),
|
|
27
25
|
path: configService.get('APOLLO_PATH'),
|
|
28
26
|
}),
|
|
29
|
-
inject: [
|
|
27
|
+
inject: [ConfigService],
|
|
30
28
|
}),
|
|
31
|
-
|
|
29
|
+
FilesModule,
|
|
32
30
|
],
|
|
33
31
|
})
|
|
34
32
|
], AppModule);
|
|
35
|
-
|
|
33
|
+
export default AppModule;
|
|
36
34
|
//# sourceMappingURL=app.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../../src/app.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../../src/app.module.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,WAAW,MAAM,yBAAyB,CAAC;AAkBnC,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,SAAS;IAhB7B,MAAM,CAAC;QACN,OAAO,EAAE;YACP,YAAY,CAAC,OAAO,CAAC;gBACnB,QAAQ,EAAE,IAAI;aACf,CAAC;YACF,aAAa,CAAC,YAAY,CAAC;gBACzB,MAAM,EAAE,YAAY;gBACpB,UAAU,EAAE,CAAC,aAA4B,EAAE,EAAE,CAAC,CAAC;oBAC7C,cAAc,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC;oBACrD,IAAI,EAAE,aAAa,CAAC,GAAG,CAAS,aAAa,CAAC;iBAC/C,CAAC;gBACF,MAAM,EAAE,CAAC,aAAa,CAAC;aACxB,CAAC;YACF,WAAW;SACZ;KACF,CAAC;GACmB,SAAS,CAAG;eAAZ,SAAS"}
|
package/dist/src/bootstrap.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
type BootstrapOptions = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
config?: string;
|
|
3
|
+
httpServer?: string;
|
|
4
|
+
runHelp?: CallableFunction;
|
|
5
5
|
};
|
|
6
6
|
export default function bootstrap(options?: BootstrapOptions): Promise<void>;
|
|
7
7
|
export {};
|
package/dist/src/bootstrap.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const cloudcmd_1 = require("./cloudcmd/cloudcmd");
|
|
8
|
-
async function bootstrap(options) {
|
|
1
|
+
import { NestFactory } from '@nestjs/core';
|
|
2
|
+
import { ConfigService } from '@nestjs/config';
|
|
3
|
+
import * as dotenv from 'dotenv';
|
|
4
|
+
import AppModule from './app.module.js';
|
|
5
|
+
import cloudCMD from './cloudcmd/cloudcmd.js';
|
|
6
|
+
export default async function bootstrap(options) {
|
|
9
7
|
const configFile = dotenv.config({
|
|
10
8
|
path: options?.config ?? '.env',
|
|
11
9
|
override: true,
|
|
12
10
|
});
|
|
13
|
-
if (configFile.error) {
|
|
11
|
+
if (configFile.error && process.env.LOCAL_PATH === undefined) {
|
|
14
12
|
console.error(configFile.error);
|
|
15
13
|
if (options.runHelp) {
|
|
16
14
|
options.runHelp();
|
|
@@ -19,13 +17,12 @@ async function bootstrap(options) {
|
|
|
19
17
|
process.exit(1);
|
|
20
18
|
}
|
|
21
19
|
}
|
|
22
|
-
const app = await
|
|
23
|
-
const configService = app.get(
|
|
20
|
+
const app = await NestFactory.create(AppModule);
|
|
21
|
+
const configService = app.get(ConfigService);
|
|
24
22
|
const port = configService.get('PORT');
|
|
25
23
|
if (options.httpServer) {
|
|
26
|
-
(
|
|
24
|
+
cloudCMD(app, options.httpServer, configService.get('LOCAL_PATH'));
|
|
27
25
|
}
|
|
28
26
|
await app.listen(port);
|
|
29
27
|
}
|
|
30
|
-
exports.default = bootstrap;
|
|
31
28
|
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/bootstrap.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAA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CloudCMD: (
|
|
3
|
-
app: INestApplication,
|
|
4
|
-
optionsPath: string,
|
|
5
|
-
filesPath: string,
|
|
6
|
-
) => void;
|
|
2
|
+
declare const runCloudCMD: (app: INestApplication, optionsPath: string, filesPath: string) => void;
|
|
7
3
|
export default runCloudCMD;
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const path_1 = require("path");
|
|
1
|
+
import { Server } from 'socket.io';
|
|
2
|
+
import cloudcmd from 'cloudcmd';
|
|
3
|
+
import { join, relative } from 'path';
|
|
4
|
+
const isWindowsAbsolutePath = (filesPath) => filesPath.includes(':');
|
|
6
5
|
const runCloudCMD = (app, optionsPath, filesPath) => {
|
|
7
6
|
const { createConfigManager } = cloudcmd;
|
|
8
7
|
const configManager = createConfigManager({
|
|
9
|
-
configPath:
|
|
8
|
+
configPath: join(process.cwd(), optionsPath),
|
|
10
9
|
});
|
|
11
|
-
|
|
10
|
+
if (isWindowsAbsolutePath(filesPath)) {
|
|
11
|
+
const workDir = process.cwd();
|
|
12
|
+
const relativePath = relative(workDir, filesPath);
|
|
13
|
+
configManager('root', relativePath);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
configManager('root', filesPath);
|
|
17
|
+
}
|
|
12
18
|
const server = app.getHttpServer();
|
|
13
|
-
const socket = new
|
|
19
|
+
const socket = new Server(server, {
|
|
14
20
|
path: `${configManager('prefix')}/socket.io`,
|
|
15
21
|
});
|
|
16
22
|
app.use(configManager('prefix'), cloudcmd({
|
|
@@ -18,5 +24,5 @@ const runCloudCMD = (app, optionsPath, filesPath) => {
|
|
|
18
24
|
socket,
|
|
19
25
|
}));
|
|
20
26
|
};
|
|
21
|
-
|
|
27
|
+
export default runCloudCMD;
|
|
22
28
|
//# sourceMappingURL=cloudcmd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudcmd.js","sourceRoot":"","sources":["../../../src/cloud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AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-mode.enum.js","sourceRoot":"","sources":["../../../src/enums/config-mode.enum.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,0BAAW,CAAA;IACX,8BAAe,CAAA;AACjB,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Injectable } from '@nestjs/common';
|
|
8
|
+
let FilesServiceFactory = class FilesServiceFactory {
|
|
9
|
+
static create(configService, fileServices) {
|
|
10
|
+
const mode = configService.get('MODE');
|
|
11
|
+
const service = fileServices.find((s) => s.getMode() == mode);
|
|
12
|
+
if (service == undefined) {
|
|
13
|
+
throw new Error(`Invalid MODE: ${mode}`);
|
|
14
|
+
}
|
|
15
|
+
return service;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
FilesServiceFactory = __decorate([
|
|
19
|
+
Injectable()
|
|
20
|
+
], FilesServiceFactory);
|
|
21
|
+
export default FilesServiceFactory;
|
|
22
|
+
//# sourceMappingURL=files-service.factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files-service.factory.js","sourceRoot":"","sources":["../../../src/files/files-service.factory.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAK7B,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IACtC,MAAM,CAAC,MAAM,CACX,aAA4B,EAC5B,YAA6B;QAE7B,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAS,MAAM,CAAC,CAAC;QAC/C,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,CAAC;QAE9D,IAAI,OAAO,IAAI,SAAS,EAAE,CAAC;YACzB,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;QAC3C,CAAC;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAA;AAboB,mBAAmB;IADvC,UAAU,EAAE;GACQ,mBAAmB,CAavC;eAboB,mBAAmB"}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export default class FilesModule {
|
|
1
|
+
export default class FilesModule {
|
|
2
|
+
}
|