@into-cps-association/libms 0.4.5 → 0.5.0

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 (127) hide show
  1. package/DEVELOPER.md +80 -0
  2. package/DOCKER.md +295 -0
  3. package/README.md +8 -0
  4. package/compose.lib.dev.yml +9 -0
  5. package/compose.lib.yml +8 -0
  6. package/dist/src/app.module.d.ts +2 -1
  7. package/dist/src/app.module.js +14 -16
  8. package/dist/src/app.module.js.map +1 -1
  9. package/dist/src/bootstrap.d.ts +3 -3
  10. package/dist/src/bootstrap.js +13 -13
  11. package/dist/src/bootstrap.js.map +1 -1
  12. package/dist/src/cloudcmd/cloudcmd.d.ts +1 -5
  13. package/dist/src/cloudcmd/cloudcmd.js +15 -9
  14. package/dist/src/cloudcmd/cloudcmd.js.map +1 -1
  15. package/dist/src/enums/config-mode.enum.d.ts +4 -0
  16. package/dist/src/enums/config-mode.enum.js +6 -0
  17. package/dist/src/enums/config-mode.enum.js.map +1 -0
  18. package/dist/src/files/files-service.factory.d.ts +5 -0
  19. package/dist/src/files/files-service.factory.js +22 -0
  20. package/dist/src/files/files-service.factory.js.map +1 -0
  21. package/dist/src/files/files.module.d.ts +2 -1
  22. package/dist/src/files/files.module.js +23 -9
  23. package/dist/src/files/files.module.js.map +1 -1
  24. package/dist/src/files/files.resolver.d.ts +8 -0
  25. package/dist/src/files/{resolvers/files.resolver.js → files.resolver.js} +14 -14
  26. package/dist/src/files/files.resolver.js.map +1 -0
  27. package/dist/src/files/git/git-files.module.d.ts +2 -0
  28. package/dist/src/files/git/git-files.module.js +19 -0
  29. package/dist/src/files/git/git-files.module.js.map +1 -0
  30. package/dist/src/files/git/git-files.service.d.ts +14 -0
  31. package/dist/src/files/git/git-files.service.js +67 -0
  32. package/dist/src/files/git/git-files.service.js.map +1 -0
  33. package/dist/src/files/interfaces/files.service.interface.d.ts +6 -3
  34. package/dist/src/files/interfaces/files.service.interface.js +1 -2
  35. package/dist/src/files/interfaces/files.service.interface.js.map +1 -1
  36. package/dist/src/files/local/local-files.module.d.ts +2 -0
  37. package/dist/src/files/local/local-files.module.js +18 -0
  38. package/dist/src/files/local/local-files.module.js.map +1 -0
  39. package/dist/src/files/local/local-files.service.d.ts +14 -0
  40. package/dist/src/files/{services → local}/local-files.service.js +17 -15
  41. package/dist/src/files/local/local-files.service.js.map +1 -0
  42. package/dist/src/main.js +4 -6
  43. package/dist/src/main.js.map +1 -1
  44. package/dist/src/types.d.ts +19 -19
  45. package/dist/src/types.js +56 -59
  46. package/dist/src/types.js.map +1 -1
  47. package/dist/test/cloudcmd/cloudcmd.spec.js +14 -16
  48. package/dist/test/cloudcmd/cloudcmd.spec.js.map +1 -1
  49. package/dist/test/e2e/app.e2e.spec.js +18 -18
  50. package/dist/test/e2e/app.e2e.spec.js.map +1 -1
  51. package/dist/test/integration/files.service.integration.spec.js +28 -19
  52. package/dist/test/integration/files.service.integration.spec.js.map +1 -1
  53. package/dist/test/testUtil.d.ts +66 -68
  54. package/dist/test/testUtil.js +21 -23
  55. package/dist/test/testUtil.js.map +1 -1
  56. package/dist/test/unit/files-service.factory.unit.spec.js +22 -16
  57. package/dist/test/unit/files-service.factory.unit.spec.js.map +1 -1
  58. package/dist/test/unit/files.resolver.unit.spec.js +26 -24
  59. package/dist/test/unit/files.resolver.unit.spec.js.map +1 -1
  60. package/dist/test/unit/git-files.service.unit.spec.d.ts +1 -0
  61. package/dist/test/unit/git-files.service.unit.spec.js +55 -0
  62. package/dist/test/unit/git-files.service.unit.spec.js.map +1 -0
  63. package/dist/test/unit/local-files.service.unit.spec.js +23 -24
  64. package/dist/test/unit/local-files.service.unit.spec.js.map +1 -1
  65. package/dist/tsconfig.tsbuildinfo +1 -1
  66. package/eslint.config.js +60 -0
  67. package/jest.config.ts +47 -0
  68. package/package.json +55 -48
  69. package/src/app.module.ts +1 -1
  70. package/src/bootstrap.ts +7 -3
  71. package/src/cloudcmd/cloudcmd.ts +11 -3
  72. package/src/enums/config-mode.enum.ts +4 -0
  73. package/src/files/files-service.factory.ts +19 -0
  74. package/src/files/files.module.ts +24 -4
  75. package/src/files/{resolvers/files.resolver.ts → files.resolver.ts} +9 -8
  76. package/src/files/git/git-files.module.ts +9 -0
  77. package/src/files/git/git-files.service.ts +58 -0
  78. package/src/files/interfaces/files.service.interface.ts +4 -1
  79. package/src/files/local/local-files.module.ts +8 -0
  80. package/src/files/{services → local}/local-files.service.ts +15 -10
  81. package/src/main.ts +1 -1
  82. package/test/cloudcmd/cloudcmd.spec.ts +4 -6
  83. package/test/e2e/app.e2e.spec.ts +4 -3
  84. package/test/integration/files.service.integration.spec.ts +19 -4
  85. package/test/testUtil.ts +3 -0
  86. package/test/unit/files-service.factory.unit.spec.ts +24 -10
  87. package/test/unit/files.resolver.unit.spec.ts +19 -12
  88. package/test/unit/git-files.service.unit.spec.ts +81 -0
  89. package/test/unit/local-files.service.unit.spec.ts +4 -2
  90. package/tsconfig.json +10 -7
  91. package/.env +0 -6
  92. package/.eslintignore +0 -6
  93. package/.eslintrc +0 -53
  94. package/coverage/clover.xml +0 -162
  95. package/coverage/cobertura-coverage.xml +0 -306
  96. package/coverage/coverage-final.json +0 -8
  97. package/coverage/lcov-report/base.css +0 -224
  98. package/coverage/lcov-report/block-navigation.js +0 -87
  99. package/coverage/lcov-report/favicon.png +0 -0
  100. package/coverage/lcov-report/index.html +0 -176
  101. package/coverage/lcov-report/prettify.css +0 -1
  102. package/coverage/lcov-report/prettify.js +0 -2
  103. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  104. package/coverage/lcov-report/sorter.js +0 -196
  105. package/coverage/lcov-report/src/bootstrap.ts.html +0 -196
  106. package/coverage/lcov-report/src/cloudcmd/cloudcmd.ts.html +0 -181
  107. package/coverage/lcov-report/src/cloudcmd/index.html +0 -116
  108. package/coverage/lcov-report/src/files/files.module.ts.html +0 -112
  109. package/coverage/lcov-report/src/files/index.html +0 -116
  110. package/coverage/lcov-report/src/files/resolvers/files.resolver.ts.html +0 -154
  111. package/coverage/lcov-report/src/files/resolvers/index.html +0 -116
  112. package/coverage/lcov-report/src/files/services/files-service.factory.ts.html +0 -151
  113. package/coverage/lcov-report/src/files/services/index.html +0 -131
  114. package/coverage/lcov-report/src/files/services/local-files.service.ts.html +0 -313
  115. package/coverage/lcov-report/src/index.html +0 -131
  116. package/coverage/lcov-report/src/types.ts.html +0 -361
  117. package/coverage/lcov.info +0 -237
  118. package/dist/src/files/resolvers/files.resolver.d.ts +0 -8
  119. package/dist/src/files/resolvers/files.resolver.js.map +0 -1
  120. package/dist/src/files/services/files-service.factory.d.ts +0 -12
  121. package/dist/src/files/services/files-service.factory.js +0 -40
  122. package/dist/src/files/services/files-service.factory.js.map +0 -1
  123. package/dist/src/files/services/local-files.service.d.ts +0 -11
  124. package/dist/src/files/services/local-files.service.js.map +0 -1
  125. package/jest.config.json +0 -30
  126. package/src/files/services/files-service.factory.ts +0 -22
  127. /package/{pm2.config.js → pm2.config.cjs} +0 -0
package/DEVELOPER.md CHANGED
@@ -37,12 +37,54 @@ APOLLO_PATH='/lib'
37
37
  GRAPHQL_PLAYGROUND='true'
38
38
  ```
39
39
 
40
+ Here is another with `git` mode.
41
+
42
+ ```ini
43
+ PORT='4001'
44
+ MODE='git'
45
+ LOCAL_PATH ='/Users/<Username>/DTaaS/files'
46
+ LOG_LEVEL='debug'
47
+ APOLLO_PATH='/lib'
48
+ GRAPHQL_PLAYGROUND='true'
49
+
50
+ GIT_USER1_REPO_URL='<git repo url>'
51
+ GIT_USER1_API_TOKEN='<TOKEN>'
52
+ ...
53
+ GIT_USERX_REPO_URL='<git repo url>'
54
+ GIT_USERX_API_TOKEN='<TOKEN>'
55
+ ```
56
+
57
+
40
58
  ## Service Endpoint
41
59
 
42
60
  The URL endpoint for this microservice is located at: `localhost:PORT/lib`
43
61
 
44
62
  The [API](./API.md) page shows sample queries and responses.
45
63
 
64
+ ## Manual testing
65
+
66
+ As of now, some features require manual testing or attention.
67
+
68
+ ### CloudCMD (a npm package dependency)
69
+
70
+ Due to how CloudCMD works,
71
+ it is required to manually run `yarn test:http` with `LOCAL_PATH` both as an
72
+ absolute path and local path. For example, the manual tests
73
+ need to be done with the following `LOCAL_PATH` values.
74
+
75
+ | OS | Absolute Path | Relative Path |
76
+ | ------- | ----------------------------- | ------------- |
77
+ | Windows | C:\DTaaS\files | ..\..\files |
78
+ | Linux | /Users/\<Username\>/DTaaS/files | ../../files |
79
+
80
+ ### PM2
81
+
82
+ the pm2 might not close spawned processes correctly,
83
+ therefore please use the following command to kill a process.
84
+ `pm2 del <id>`.
85
+
86
+ **NOTE:** to see the processes spawned by pm2 use `pm2 list`
87
+
46
88
  ## :package: :ship: Packages
47
89
 
48
90
  ### Docker images
@@ -86,6 +128,44 @@ with publishing **libms npm package** in local computer.
86
128
  Application of the advice given on that page for **libms** will require
87
129
  running the following commands.
88
130
 
131
+ ## Use in Docker Environment
132
+
133
+ ### Adjust Configuration (Optional)
134
+
135
+ The microservices require configuration and the docker version
136
+ of the microservices uses the configuration
137
+ file available in `config/.env.default`.
138
+
139
+ Please add a `.env` file with the environment variables for
140
+ the docker compose file to use.
141
+ e.g.
142
+
143
+ ```sh
144
+ PORT='4001'
145
+ MODE='local'
146
+ LOCAL_PATH='..\..\files'
147
+ ```
148
+
149
+ ### Use
150
+
151
+ The commands to start and stop the appliation are:
152
+
153
+ **NOTE**: the docker compose file is located in the `servers/lib` directory.
154
+
155
+ ```bash
156
+ docker compose -f compose.lib.dev.yml up -d
157
+ ```
158
+
159
+ This command brings up the lib docker container and makes
160
+ the website available at <http://localhost:4001>.
161
+ The `config/.env.default` file is used as the microservice configuration.
162
+ If the configuration values are changed, please restart the container.
163
+
164
+ ```bash
165
+ docker compose -f compose.lib.dev.yml down
166
+ docker compose -f compose.lib.dev.yml up -d
167
+ ```
168
+
89
169
  ### Publish
90
170
 
91
171
  ```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/README.md CHANGED
@@ -52,6 +52,14 @@ LOCAL_PATH ='/Users/<Username>/DTaaS/files'
52
52
  LOG_LEVEL='debug'
53
53
  APOLLO_PATH='/lib' or ''
54
54
  GRAPHQL_PLAYGROUND='false' or 'true'
55
+
56
+ #Only needed if git mode
57
+ GIT_USER1_REPO_URL='<git repo url>'
58
+ GIT_USER1_API_TOKEN='<TOKEN>'
59
+ ...
60
+ GIT_USERX_REPO_URL='<git repo url>'
61
+ GIT_USERX_API_TOKEN='<TOKEN>'
62
+
55
63
  ```
56
64
 
57
65
  The `LOCAL_PATH` variable is the absolute filepath to the
@@ -0,0 +1,9 @@
1
+ services:
2
+ libms:
3
+ build:
4
+ context: ../../
5
+ dockerfile: ./docker/libms.dockerfile
6
+ volumes:
7
+ - ${LOCAL_PATH}:/dtaas/libms/files
8
+ ports:
9
+ - ${PORT}:4001
@@ -0,0 +1,8 @@
1
+ services:
2
+ libms:
3
+ image: intocps/libms:latest
4
+ restart: unless-stopped
5
+ volumes:
6
+ - ./files:/dtaas/libms/files
7
+ ports:
8
+ - "4001:4001"
@@ -1 +1,2 @@
1
- export default class AppModule {}
1
+ export default class AppModule {
2
+ }
@@ -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
- Object.defineProperty(exports, "__esModule", { value: true });
9
- const config_1 = require("@nestjs/config");
10
- const common_1 = require("@nestjs/common");
11
- const graphql_1 = require("@nestjs/graphql");
12
- const apollo_1 = require("@nestjs/apollo");
13
- const path_1 = require("path");
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
- (0, common_1.Module)({
16
+ Module({
19
17
  imports: [
20
- config_1.ConfigModule.forRoot({
18
+ ConfigModule.forRoot({
21
19
  isGlobal: true,
22
20
  }),
23
- graphql_1.GraphQLModule.forRootAsync({
24
- driver: apollo_1.ApolloDriver,
21
+ GraphQLModule.forRootAsync({
22
+ driver: ApolloDriver,
25
23
  useFactory: (configService) => ({
26
- autoSchemaFile: (0, path_1.join)(process.cwd(), 'src/schema.gql'),
24
+ autoSchemaFile: join(process.cwd(), 'src/schema.gql'),
27
25
  path: configService.get('APOLLO_PATH'),
28
26
  }),
29
- inject: [config_1.ConfigService],
27
+ inject: [ConfigService],
30
28
  }),
31
- files_module_1.default,
29
+ FilesModule,
32
30
  ],
33
31
  })
34
32
  ], AppModule);
35
- exports.default = AppModule;
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":";;;;;;;;AAAA,2CAA6D;AAC7D,2CAAwC;AACxC,6CAAgD;AAChD,2CAA8C;AAC9C,+BAA4B;AAC5B,uDAA+C;AAkBhC,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,SAAS;IAhB7B,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,qBAAY,CAAC,OAAO,CAAC;gBACnB,QAAQ,EAAE,IAAI;aACf,CAAC;YACF,uBAAa,CAAC,YAAY,CAAC;gBACzB,MAAM,EAAE,qBAAY;gBACpB,UAAU,EAAE,CAAC,aAA4B,EAAE,EAAE,CAAC,CAAC;oBAC7C,cAAc,EAAE,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,gBAAgB,CAAC;oBACrD,IAAI,EAAE,aAAa,CAAC,GAAG,CAAS,aAAa,CAAC;iBAC/C,CAAC;gBACF,MAAM,EAAE,CAAC,sBAAa,CAAC;aACxB,CAAC;YACF,sBAAW;SACZ;KACF,CAAC;GACmB,SAAS,CAAG;kBAAZ,SAAS"}
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"}
@@ -1,7 +1,7 @@
1
1
  type BootstrapOptions = {
2
- config?: string;
3
- httpServer?: string;
4
- runHelp?: CallableFunction;
2
+ config?: string;
3
+ httpServer?: string;
4
+ runHelp?: CallableFunction;
5
5
  };
6
6
  export default function bootstrap(options?: BootstrapOptions): Promise<void>;
7
7
  export {};
@@ -1,16 +1,14 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const core_1 = require("@nestjs/core");
4
- const config_1 = require("@nestjs/config");
5
- const dotenv = require("dotenv");
6
- const app_module_1 = require("./app.module");
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,15 @@ async function bootstrap(options) {
19
17
  process.exit(1);
20
18
  }
21
19
  }
22
- const app = await core_1.NestFactory.create(app_module_1.default);
23
- const configService = app.get(config_1.ConfigService);
20
+ const app = await NestFactory.create(AppModule);
21
+ const configService = app.get(ConfigService);
24
22
  const port = configService.get('PORT');
23
+ const localPath = configService.get('LOCAL_PATH');
24
+ const mode = configService.get('MODE');
25
+ console.log(`\x1b[32mStarting libms in \x1b[33m${mode} \x1b[32mmode, serving files from \x1b[34m${localPath} \x1b[32mon port \x1b[35m${port}\x1b[0m`);
25
26
  if (options.httpServer) {
26
- (0, cloudcmd_1.default)(app, options.httpServer, configService.get('LOCAL_PATH'));
27
+ cloudCMD(app, options.httpServer, configService.get('LOCAL_PATH'));
27
28
  }
28
29
  await app.listen(port);
29
30
  }
30
- exports.default = bootstrap;
31
31
  //# sourceMappingURL=bootstrap.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../../src/bootstrap.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,2CAA+C;AAC/C,iCAAiC;AACjC,6CAAqC;AACrC,kDAA2C;AAQ5B,KAAK,UAAU,SAAS,CAAC,OAA0B;IAChE,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;QAC/B,IAAI,EAAE,OAAO,EAAE,MAAM,IAAI,MAAM;QAC/B,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;IACH,IAAI,UAAU,CAAC,KAAK,EAAE,CAAC;QAErB,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;YACpB,OAAO,CAAC,OAAO,EAAE,CAAC;QACpB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,MAAM,GAAG,GAAG,MAAM,kBAAW,CAAC,MAAM,CAAC,oBAAS,CAAC,CAAC;IAChD,MAAM,aAAa,GAAG,GAAG,CAAC,GAAG,CAAC,sBAAa,CAAC,CAAC;IAC7C,MAAM,IAAI,GAAG,aAAa,C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CAAC,CAAC;IAC7C,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAS,MAAM,CAAC,CAAC;IAC/C,MAAM,SAAS,GAAG,aAAa,CAAC,GAAG,CAAS,YAAY,CAAC,CAAC;IAC1D,MAAM,IAAI,GAAG,aAAa,CAAC,GAAG,CAAS,MAAM,CAAC,CAAC;IAE/C,OAAO,CAAC,GAAG,CAAC,qCAAqC,IAAI,6CAA6C,SAAS,4BAA4B,IAAI,SAAS,CAAC,CAAC;IAEtJ,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QACvB,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,CAAS,YAAY,CAAC,CAAC,CAAC;IAC7E,CAAC;IAED,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
@@ -1,7 +1,3 @@
1
1
  import { INestApplication } from '@nestjs/common';
2
- declare const runCloudCMD: (
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const socket_io_1 = require("socket.io");
4
- const cloudcmd = require("cloudcmd");
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: (0, path_1.join)(process.cwd(), optionsPath),
8
+ configPath: join(process.cwd(), optionsPath),
10
9
  });
11
- configManager('root', filesPath);
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 socket_io_1.Server(server, {
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
- exports.default = runCloudCMD;
27
+ export default runCloudCMD;
22
28
  //# sourceMappingURL=cloudcmd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cloudcmd.js","sourceRoot":"","sources":["../../../src/cloudcmd/cloudcmd.ts"],"names":[],"mappings":";;AACA,yCAAmC;AACnC,qCAAqC;AACrC,+BAA4B;AAE5B,MAAM,WAAW,GAAG,CAClB,GAAqB,EACrB,WAAmB,EACnB,SAAiB,EACjB,EAAE;IACF,MAAM,EAAE,mBAAmB,EAAE,GAAG,QAAQ,CAAC;IACzC,MAAM,aAAa,GAAG,mBAAmB,CAAC;QACxC,UAAU,EAAE,IAAA,WAAI,EAAC,OAAO,CAAC,GAAG,EAAE,EAAE,WAAW,CAAC;KAC7C,CAAC,CAAC;IAEH,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAEjC,MAAM,MAAM,GAAG,GAAG,CAAC,aAAa,EAAE,CAAC;IAEnC,MAAM,MAAM,GAAG,IAAI,kBAAM,CAAC,MAAM,EAAE;QAChC,IAAI,EAAE,GAAG,aAAa,CAAC,QAAQ,CAAC,YAAY;KAC7C,CAAC,CAAC;IACH,GAAG,CAAC,GAAG,CACL,aAAa,CAAC,QAAQ,CAAC,EACvB,QAAQ,CAAC;QACP,aAAa;QACb,MAAM;KACP,CAAC,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"cloudcmd.js","sourceRoot":"","sources":["../../../src/cloudcmd/cloudcmd.ts"],"names":[],"mappings":"AACA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@ -0,0 +1,6 @@
1
+ export var CONFIG_MODE;
2
+ (function (CONFIG_MODE) {
3
+ CONFIG_MODE["GIT"] = "git";
4
+ CONFIG_MODE["LOCAL"] = "local";
5
+ })(CONFIG_MODE || (CONFIG_MODE = {}));
6
+ //# sourceMappingURL=config-mode.enum.js.map
@@ -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,5 @@
1
+ import { ConfigService } from '@nestjs/config';
2
+ import { IFilesService } from './interfaces/files.service.interface.js';
3
+ export default class FilesServiceFactory {
4
+ static create(configService: ConfigService, fileServices: IFilesService[]): IFilesService;
5
+ }
@@ -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
+ }