@into-cps-association/libms 0.4.3 → 0.4.5
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/.env +6 -0
- package/DEVELOPER.md +34 -9
- package/HTTP.md +12 -0
- package/README.md +288 -10
- package/config/.env.default +1 -1
- package/coverage/clover.xml +162 -0
- package/coverage/cobertura-coverage.xml +306 -0
- package/coverage/coverage-final.json +8 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +176 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov-report/src/bootstrap.ts.html +196 -0
- package/coverage/lcov-report/src/cloudcmd/cloudcmd.ts.html +181 -0
- package/coverage/lcov-report/src/cloudcmd/index.html +116 -0
- package/coverage/lcov-report/src/files/files.module.ts.html +112 -0
- package/coverage/lcov-report/src/files/index.html +116 -0
- package/coverage/lcov-report/src/files/resolvers/files.resolver.ts.html +154 -0
- package/coverage/lcov-report/src/files/resolvers/index.html +116 -0
- package/coverage/lcov-report/src/files/services/files-service.factory.ts.html +151 -0
- package/coverage/lcov-report/src/files/services/index.html +131 -0
- package/coverage/lcov-report/src/files/services/local-files.service.ts.html +313 -0
- package/coverage/lcov-report/src/index.html +131 -0
- package/coverage/lcov-report/src/types.ts.html +361 -0
- package/coverage/lcov.info +237 -0
- package/dist/src/app.module.d.ts +1 -0
- package/dist/src/app.module.js +36 -0
- package/dist/src/app.module.js.map +1 -0
- package/dist/src/bootstrap.d.ts +7 -0
- package/dist/src/bootstrap.js +31 -0
- package/dist/src/bootstrap.js.map +1 -0
- package/dist/src/cloudcmd/cloudcmd.d.ts +7 -0
- package/dist/src/cloudcmd/cloudcmd.js +22 -0
- package/dist/src/cloudcmd/cloudcmd.js.map +1 -0
- package/dist/src/files/files.module.d.ts +1 -0
- package/dist/src/files/files.module.js +21 -0
- package/dist/src/files/files.module.js.map +1 -0
- package/dist/src/files/interfaces/files.service.interface.d.ts +5 -0
- package/dist/src/files/interfaces/files.service.interface.js +3 -0
- package/dist/src/files/interfaces/files.service.interface.js.map +1 -0
- package/dist/src/files/resolvers/files.resolver.d.ts +8 -0
- package/dist/src/files/resolvers/files.resolver.js +49 -0
- package/dist/src/files/resolvers/files.resolver.js.map +1 -0
- package/dist/src/files/services/files-service.factory.d.ts +12 -0
- package/dist/src/files/services/files-service.factory.js +40 -0
- package/dist/src/files/services/files-service.factory.js.map +1 -0
- package/dist/src/files/services/local-files.service.d.ts +11 -0
- package/dist/src/files/services/local-files.service.js +77 -0
- package/dist/src/files/services/local-files.service.js.map +1 -0
- package/dist/src/main.d.ts +2 -0
- package/dist/src/main.js +20 -0
- package/dist/src/main.js.map +1 -0
- package/dist/src/types.d.ts +43 -0
- package/dist/src/types.js +181 -0
- package/dist/src/types.js.map +1 -0
- package/dist/test/cloudcmd/cloudcmd.spec.d.ts +1 -0
- package/dist/test/cloudcmd/cloudcmd.spec.js +35 -0
- package/dist/test/cloudcmd/cloudcmd.spec.js.map +1 -0
- package/dist/test/e2e/app.e2e.spec.d.ts +1 -0
- package/dist/test/e2e/app.e2e.spec.js +53 -0
- package/dist/test/e2e/app.e2e.spec.js.map +1 -0
- package/dist/test/integration/files.service.integration.spec.d.ts +1 -0
- package/dist/test/integration/files.service.integration.spec.js +51 -0
- package/dist/test/integration/files.service.integration.spec.js.map +1 -0
- package/dist/test/testUtil.d.ts +90 -0
- package/dist/test/testUtil.js +173 -0
- package/dist/test/testUtil.js.map +1 -0
- package/dist/test/unit/files-service.factory.unit.spec.d.ts +1 -0
- package/dist/test/unit/files-service.factory.unit.spec.js +32 -0
- package/dist/test/unit/files-service.factory.unit.spec.js.map +1 -0
- package/dist/test/unit/files.resolver.unit.spec.d.ts +1 -0
- package/dist/test/unit/files.resolver.unit.spec.js +56 -0
- package/dist/test/unit/files.resolver.unit.spec.js.map +1 -0
- package/dist/test/unit/local-files.service.unit.spec.d.ts +1 -0
- package/dist/test/unit/local-files.service.unit.spec.js +84 -0
- package/dist/test/unit/local-files.service.unit.spec.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/inside.png +0 -0
- package/package.json +1 -1
- package/top-level.png +0 -0
|
@@ -0,0 +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");
|
|
6
|
+
const runCloudCMD = (app, optionsPath, filesPath) => {
|
|
7
|
+
const { createConfigManager } = cloudcmd;
|
|
8
|
+
const configManager = createConfigManager({
|
|
9
|
+
configPath: (0, path_1.join)(process.cwd(), optionsPath),
|
|
10
|
+
});
|
|
11
|
+
configManager('root', filesPath);
|
|
12
|
+
const server = app.getHttpServer();
|
|
13
|
+
const socket = new socket_io_1.Server(server, {
|
|
14
|
+
path: `${configManager('prefix')}/socket.io`,
|
|
15
|
+
});
|
|
16
|
+
app.use(configManager('prefix'), cloudcmd({
|
|
17
|
+
configManager,
|
|
18
|
+
socket,
|
|
19
|
+
}));
|
|
20
|
+
};
|
|
21
|
+
exports.default = runCloudCMD;
|
|
22
|
+
//# sourceMappingURL=cloudcmd.js.map
|
|
@@ -0,0 +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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default class FilesModule {}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
const common_1 = require("@nestjs/common");
|
|
10
|
+
const files_resolver_1 = require("./resolvers/files.resolver");
|
|
11
|
+
const files_service_factory_1 = require("./services/files-service.factory");
|
|
12
|
+
const local_files_service_1 = require("./services/local-files.service");
|
|
13
|
+
let FilesModule = class FilesModule {
|
|
14
|
+
};
|
|
15
|
+
FilesModule = __decorate([
|
|
16
|
+
(0, common_1.Module)({
|
|
17
|
+
providers: [files_resolver_1.default, local_files_service_1.default, files_service_factory_1.default],
|
|
18
|
+
})
|
|
19
|
+
], FilesModule);
|
|
20
|
+
exports.default = FilesModule;
|
|
21
|
+
//# sourceMappingURL=files.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.module.js","sourceRoot":"","sources":["../../../src/files/files.module.ts"],"names":[],"mappings":";;;;;;;;AAAA,2CAAwC;AACxC,+DAAuD;AACvD,4EAAmE;AACnE,wEAA+D;AAKhD,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,WAAW;IAH/B,IAAA,eAAM,EAAC;QACN,SAAS,EAAE,CAAC,wBAAa,EAAE,6BAAiB,EAAE,+BAAmB,CAAC;KACnE,CAAC;GACmB,WAAW,CAAG;kBAAd,WAAW"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.service.interface.js","sourceRoot":"","sources":["../../../../src/files/interfaces/files.service.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import FilesServiceFactory from '../services/files-service.factory';
|
|
2
|
+
import { Project } from '../../types';
|
|
3
|
+
export default class FilesResolver {
|
|
4
|
+
private readonly filesService;
|
|
5
|
+
constructor(filesServiceFactory: FilesServiceFactory);
|
|
6
|
+
listDirectory(path: string): Promise<Project>;
|
|
7
|
+
readFile(path: string): Promise<Project>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
16
|
+
const files_service_factory_1 = require("../services/files-service.factory");
|
|
17
|
+
const types_1 = require("../../types");
|
|
18
|
+
let FilesResolver = class FilesResolver {
|
|
19
|
+
filesService;
|
|
20
|
+
constructor(filesServiceFactory) {
|
|
21
|
+
this.filesService = filesServiceFactory.create();
|
|
22
|
+
}
|
|
23
|
+
async listDirectory(path) {
|
|
24
|
+
return this.filesService.listDirectory(path);
|
|
25
|
+
}
|
|
26
|
+
async readFile(path) {
|
|
27
|
+
return this.filesService.readFile(path);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
__decorate([
|
|
31
|
+
(0, graphql_1.Query)(() => types_1.Project),
|
|
32
|
+
__param(0, (0, graphql_1.Args)('path')),
|
|
33
|
+
__metadata("design:type", Function),
|
|
34
|
+
__metadata("design:paramtypes", [String]),
|
|
35
|
+
__metadata("design:returntype", Promise)
|
|
36
|
+
], FilesResolver.prototype, "listDirectory", null);
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, graphql_1.Query)(() => types_1.Project),
|
|
39
|
+
__param(0, (0, graphql_1.Args)('path')),
|
|
40
|
+
__metadata("design:type", Function),
|
|
41
|
+
__metadata("design:paramtypes", [String]),
|
|
42
|
+
__metadata("design:returntype", Promise)
|
|
43
|
+
], FilesResolver.prototype, "readFile", null);
|
|
44
|
+
FilesResolver = __decorate([
|
|
45
|
+
(0, graphql_1.Resolver)(),
|
|
46
|
+
__metadata("design:paramtypes", [files_service_factory_1.default])
|
|
47
|
+
], FilesResolver);
|
|
48
|
+
exports.default = FilesResolver;
|
|
49
|
+
//# sourceMappingURL=files.resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.resolver.js","sourceRoot":"","sources":["../../../../src/files/resolvers/files.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,6CAAwD;AAExD,6EAAoE;AACpE,uCAAsC;AAGvB,IAAM,aAAa,GAAnB,MAAM,aAAa;IACf,YAAY,CAAgB;IAE7C,YAAY,mBAAwC;QAClD,IAAI,CAAC,YAAY,GAAG,mBAAmB,CAAC,MAAM,EAAE,CAAC;IACnD,CAAC;IAGK,AAAN,KAAK,CAAC,aAAa,CAAe,IAAY;QAC5C,OAAO,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IAC/C,CAAC;IAGK,AAAN,KAAK,CAAC,QAAQ,CAAe,IAAY;QACvC,OAAO,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF,CAAA;AARO;IADL,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,eAAO,CAAC;IACA,WAAA,IAAA,cAAI,EAAC,MAAM,CAAC,CAAA;;;;kDAEhC;AAGK;IADL,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,eAAO,CAAC;IACL,WAAA,IAAA,cAAI,EAAC,MAAM,CAAC,CAAA;;;;6CAE3B;AAfkB,aAAa;IADjC,IAAA,kBAAQ,GAAE;qCAIwB,+BAAmB;GAHjC,aAAa,CAgBjC;kBAhBoB,aAAa"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ConfigService } from '@nestjs/config';
|
|
2
|
+
import { IFilesService } from '../interfaces/files.service.interface';
|
|
3
|
+
import LocalFilesService from './local-files.service';
|
|
4
|
+
export default class FilesServiceFactory {
|
|
5
|
+
private configService;
|
|
6
|
+
private localFilesService;
|
|
7
|
+
constructor(
|
|
8
|
+
configService: ConfigService,
|
|
9
|
+
localFilesService: LocalFilesService,
|
|
10
|
+
);
|
|
11
|
+
create(): IFilesService;
|
|
12
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const common_1 = require("@nestjs/common");
|
|
16
|
+
const config_1 = require("@nestjs/config");
|
|
17
|
+
const local_files_service_1 = require("./local-files.service");
|
|
18
|
+
let FilesServiceFactory = class FilesServiceFactory {
|
|
19
|
+
configService;
|
|
20
|
+
localFilesService;
|
|
21
|
+
constructor(configService, localFilesService) {
|
|
22
|
+
this.configService = configService;
|
|
23
|
+
this.localFilesService = localFilesService;
|
|
24
|
+
}
|
|
25
|
+
create() {
|
|
26
|
+
const mode = this.configService.get('MODE');
|
|
27
|
+
if (mode === 'local') {
|
|
28
|
+
return this.localFilesService;
|
|
29
|
+
}
|
|
30
|
+
throw new Error(`Invalid MODE: ${mode}`);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
FilesServiceFactory = __decorate([
|
|
34
|
+
(0, common_1.Injectable)(),
|
|
35
|
+
__param(1, (0, common_1.Inject)(local_files_service_1.default)),
|
|
36
|
+
__metadata("design:paramtypes", [config_1.ConfigService,
|
|
37
|
+
local_files_service_1.default])
|
|
38
|
+
], FilesServiceFactory);
|
|
39
|
+
exports.default = FilesServiceFactory;
|
|
40
|
+
//# sourceMappingURL=files-service.factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files-service.factory.js","sourceRoot":"","sources":["../../../../src/files/services/files-service.factory.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,2CAA+C;AAE/C,+DAAsD;AAGvC,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAG5B;IAC2B;IAFrC,YACU,aAA4B,EACD,iBAAoC;QAD/D,kBAAa,GAAb,aAAa,CAAe;QACD,sBAAiB,GAAjB,iBAAiB,CAAmB;IACtE,CAAC;IAGJ,MAAM;QACJ,MAAM,IAAI,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAS,MAAM,CAAC,CAAC;QACpD,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC,iBAAiB,CAAC;QAChC,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC,CAAC;IAC3C,CAAC;CACF,CAAA;AAfoB,mBAAmB;IADvC,IAAA,mBAAU,GAAE;IAKR,WAAA,IAAA,eAAM,EAAC,6BAAiB,CAAC,CAAA;qCADH,sBAAa;QACkB,6BAAiB;GAJtD,mBAAmB,CAevC;kBAfoB,mBAAmB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ConfigService } from '@nestjs/config';
|
|
2
|
+
import { Project } from 'src/types';
|
|
3
|
+
import { IFilesService } from '../interfaces/files.service.interface';
|
|
4
|
+
export default class LocalFilesService implements IFilesService {
|
|
5
|
+
private configService;
|
|
6
|
+
constructor(configService: ConfigService);
|
|
7
|
+
listDirectory(path: string): Promise<Project>;
|
|
8
|
+
readFile(path: string): Promise<Project>;
|
|
9
|
+
private static getFileStats;
|
|
10
|
+
private static formatResponse;
|
|
11
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var LocalFilesService_1;
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const fs = require("fs");
|
|
15
|
+
const path_1 = require("path");
|
|
16
|
+
const config_1 = require("@nestjs/config");
|
|
17
|
+
let LocalFilesService = LocalFilesService_1 = class LocalFilesService {
|
|
18
|
+
configService;
|
|
19
|
+
constructor(configService) {
|
|
20
|
+
this.configService = configService;
|
|
21
|
+
}
|
|
22
|
+
async listDirectory(path) {
|
|
23
|
+
const dataPath = this.configService.get('LOCAL_PATH');
|
|
24
|
+
const fullPath = (0, path_1.join)(dataPath, path);
|
|
25
|
+
const files = await fs.promises.readdir(fullPath);
|
|
26
|
+
const edges = await Promise.all(files.map((file) => LocalFilesService_1.getFileStats(fullPath, file)));
|
|
27
|
+
const tree = {
|
|
28
|
+
trees: {
|
|
29
|
+
edges: edges.filter((edge) => edge.node.type === 'tree'),
|
|
30
|
+
},
|
|
31
|
+
blobs: {
|
|
32
|
+
edges: edges.filter((edge) => edge.node.type === 'blob'),
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
return { repository: { tree } };
|
|
36
|
+
}
|
|
37
|
+
async readFile(path) {
|
|
38
|
+
const dataPath = this.configService.get('LOCAL_PATH');
|
|
39
|
+
const fullPath = (0, path_1.join)(dataPath, path);
|
|
40
|
+
try {
|
|
41
|
+
const content = await (await fs.promises.readFile(fullPath, 'utf8')).trim();
|
|
42
|
+
const name = path.split('/').pop();
|
|
43
|
+
return LocalFilesService_1.formatResponse(name, content);
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
throw new common_1.InternalServerErrorException('Error reading file');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
static async getFileStats(fullPath, file) {
|
|
50
|
+
const stats = await fs.promises.lstat((0, path_1.join)(fullPath, file));
|
|
51
|
+
if (stats.isDirectory()) {
|
|
52
|
+
return { node: { name: file, type: 'tree' } };
|
|
53
|
+
}
|
|
54
|
+
return { node: { name: file, type: 'blob' } };
|
|
55
|
+
}
|
|
56
|
+
static formatResponse(name, content) {
|
|
57
|
+
return {
|
|
58
|
+
repository: {
|
|
59
|
+
blobs: {
|
|
60
|
+
nodes: [
|
|
61
|
+
{
|
|
62
|
+
name,
|
|
63
|
+
rawBlob: content,
|
|
64
|
+
rawTextBlob: content,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
LocalFilesService = LocalFilesService_1 = __decorate([
|
|
73
|
+
(0, common_1.Injectable)(),
|
|
74
|
+
__metadata("design:paramtypes", [config_1.ConfigService])
|
|
75
|
+
], LocalFilesService);
|
|
76
|
+
exports.default = LocalFilesService;
|
|
77
|
+
//# sourceMappingURL=local-files.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"local-files.service.js","sourceRoot":"","sources":["../../../../src/files/services/local-files.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA0E;AAC1E,yBAAyB;AACzB,+BAA4B;AAC5B,2CAA+C;AAKhC,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAEhB;IAApB,YAAoB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAEpD,KAAK,CAAC,aAAa,CAAC,IAAY;QAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QACtD,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QAEtC,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAElD,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,CAC7B,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,mBAAiB,CAAC,YAAY,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CACpE,CAAC;QAEF,MAAM,IAAI,GAAG;YACX,KAAK,EAAE;gBACL,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC;aACzD;YACD,KAAK,EAAE;gBACL,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC;aACzD;SACF,CAAC;QAEF,OAAO,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC;IAClC,C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ChB,WAAW,EAAE,OAAO;yBACrB;qBACF;iBACF;aACF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAnEoB,iBAAiB;IADrC,IAAA,mBAAU,GAAE;qCAGwB,sBAAa;GAF7B,iBAAiB,CAmErC;kBAnEoB,iBAAiB"}
|
package/dist/src/main.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const bootstrap_1 = require("./bootstrap");
|
|
6
|
+
const program = new commander_1.Command();
|
|
7
|
+
program
|
|
8
|
+
.description('The lib microservice is a file server. It supports file transfer over GraphQL and HTTP protocols.')
|
|
9
|
+
.option('-c, --config <file>', 'provide the config file (default .env)')
|
|
10
|
+
.option('-H, --http <file>', 'enable the HTTP server with the specified config')
|
|
11
|
+
.helpOption('-h, --help', 'display help for libms')
|
|
12
|
+
.showHelpAfterError();
|
|
13
|
+
program.parse(process.argv);
|
|
14
|
+
const options = program.opts();
|
|
15
|
+
(0, bootstrap_1.default)({
|
|
16
|
+
config: options.config,
|
|
17
|
+
httpServer: options.http,
|
|
18
|
+
runHelp: () => program.help(),
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":";;;AACA,yCAAoC;AACpC,2CAAoC;AAOpC,MAAM,OAAO,GAAG,IAAI,mBAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,WAAW,CACV,mGAAmG,CACpG;KACA,MAAM,CAAC,qBAAqB,EAAE,wCAAwC,CAAC;KACvE,MAAM,CACL,mBAAmB,EACnB,kDAAkD,CACnD;KACA,UAAU,CAAC,YAAY,EAAE,wBAAwB,CAAC;KAClD,kBAAkB,EAAE,CAAC;AAExB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAE5B,MAAM,OAAO,GAAmB,OAAO,CAAC,IAAI,EAAE,CAAC;AAE/C,IAAA,mBAAS,EAAC;IACR,MAAM,EAAE,OAAO,CAAC,MAAM;IACtB,UAAU,EAAE,OAAO,CAAC,IAAI;IACxB,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE;CAC9B,CAAC,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare class Blob {
|
|
2
|
+
name: string;
|
|
3
|
+
type: string;
|
|
4
|
+
}
|
|
5
|
+
export declare class BlobEdge {
|
|
6
|
+
node: Blob;
|
|
7
|
+
}
|
|
8
|
+
export declare class BlobConnection {
|
|
9
|
+
edges: BlobEdge[];
|
|
10
|
+
}
|
|
11
|
+
export declare class TreeEntry {
|
|
12
|
+
name: string;
|
|
13
|
+
type: string;
|
|
14
|
+
}
|
|
15
|
+
export declare class TreeEdge {
|
|
16
|
+
node: TreeEntry;
|
|
17
|
+
}
|
|
18
|
+
export declare class TreeConnection {
|
|
19
|
+
edges: TreeEdge[];
|
|
20
|
+
}
|
|
21
|
+
export declare class Tree {
|
|
22
|
+
blobs: BlobConnection;
|
|
23
|
+
trees: TreeConnection;
|
|
24
|
+
}
|
|
25
|
+
export declare class RepositoryBlob {
|
|
26
|
+
name: string;
|
|
27
|
+
rawBlob: string;
|
|
28
|
+
rawTextBlob: string;
|
|
29
|
+
}
|
|
30
|
+
export declare class RepositoryBlobConnection {
|
|
31
|
+
nodes: RepositoryBlob[];
|
|
32
|
+
}
|
|
33
|
+
export declare class Repository {
|
|
34
|
+
tree?: Tree;
|
|
35
|
+
blobs?: RepositoryBlobConnection;
|
|
36
|
+
}
|
|
37
|
+
export declare class Project {
|
|
38
|
+
repository: Repository;
|
|
39
|
+
}
|
|
40
|
+
export declare class Query {
|
|
41
|
+
listDirectory: Project;
|
|
42
|
+
readFile: Project;
|
|
43
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Query = exports.Project = exports.Repository = exports.RepositoryBlobConnection = exports.RepositoryBlob = exports.Tree = exports.TreeConnection = exports.TreeEdge = exports.TreeEntry = exports.BlobConnection = exports.BlobEdge = exports.Blob = void 0;
|
|
13
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
14
|
+
let Blob = class Blob {
|
|
15
|
+
name;
|
|
16
|
+
type;
|
|
17
|
+
};
|
|
18
|
+
exports.Blob = Blob;
|
|
19
|
+
__decorate([
|
|
20
|
+
(0, graphql_1.Field)(),
|
|
21
|
+
__metadata("design:type", String)
|
|
22
|
+
], Blob.prototype, "name", void 0);
|
|
23
|
+
__decorate([
|
|
24
|
+
(0, graphql_1.Field)(),
|
|
25
|
+
__metadata("design:type", String)
|
|
26
|
+
], Blob.prototype, "type", void 0);
|
|
27
|
+
exports.Blob = Blob = __decorate([
|
|
28
|
+
(0, graphql_1.ObjectType)()
|
|
29
|
+
], Blob);
|
|
30
|
+
let BlobEdge = class BlobEdge {
|
|
31
|
+
node;
|
|
32
|
+
};
|
|
33
|
+
exports.BlobEdge = BlobEdge;
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, graphql_1.Field)(() => Blob),
|
|
36
|
+
__metadata("design:type", Blob)
|
|
37
|
+
], BlobEdge.prototype, "node", void 0);
|
|
38
|
+
exports.BlobEdge = BlobEdge = __decorate([
|
|
39
|
+
(0, graphql_1.ObjectType)()
|
|
40
|
+
], BlobEdge);
|
|
41
|
+
let BlobConnection = class BlobConnection {
|
|
42
|
+
edges;
|
|
43
|
+
};
|
|
44
|
+
exports.BlobConnection = BlobConnection;
|
|
45
|
+
__decorate([
|
|
46
|
+
(0, graphql_1.Field)(() => [BlobEdge]),
|
|
47
|
+
__metadata("design:type", Array)
|
|
48
|
+
], BlobConnection.prototype, "edges", void 0);
|
|
49
|
+
exports.BlobConnection = BlobConnection = __decorate([
|
|
50
|
+
(0, graphql_1.ObjectType)()
|
|
51
|
+
], BlobConnection);
|
|
52
|
+
let TreeEntry = class TreeEntry {
|
|
53
|
+
name;
|
|
54
|
+
type;
|
|
55
|
+
};
|
|
56
|
+
exports.TreeEntry = TreeEntry;
|
|
57
|
+
__decorate([
|
|
58
|
+
(0, graphql_1.Field)(),
|
|
59
|
+
__metadata("design:type", String)
|
|
60
|
+
], TreeEntry.prototype, "name", void 0);
|
|
61
|
+
__decorate([
|
|
62
|
+
(0, graphql_1.Field)(),
|
|
63
|
+
__metadata("design:type", String)
|
|
64
|
+
], TreeEntry.prototype, "type", void 0);
|
|
65
|
+
exports.TreeEntry = TreeEntry = __decorate([
|
|
66
|
+
(0, graphql_1.ObjectType)()
|
|
67
|
+
], TreeEntry);
|
|
68
|
+
let TreeEdge = class TreeEdge {
|
|
69
|
+
node;
|
|
70
|
+
};
|
|
71
|
+
exports.TreeEdge = TreeEdge;
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, graphql_1.Field)(() => TreeEntry),
|
|
74
|
+
__metadata("design:type", TreeEntry)
|
|
75
|
+
], TreeEdge.prototype, "node", void 0);
|
|
76
|
+
exports.TreeEdge = TreeEdge = __decorate([
|
|
77
|
+
(0, graphql_1.ObjectType)()
|
|
78
|
+
], TreeEdge);
|
|
79
|
+
let TreeConnection = class TreeConnection {
|
|
80
|
+
edges;
|
|
81
|
+
};
|
|
82
|
+
exports.TreeConnection = TreeConnection;
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, graphql_1.Field)(() => [TreeEdge]),
|
|
85
|
+
__metadata("design:type", Array)
|
|
86
|
+
], TreeConnection.prototype, "edges", void 0);
|
|
87
|
+
exports.TreeConnection = TreeConnection = __decorate([
|
|
88
|
+
(0, graphql_1.ObjectType)()
|
|
89
|
+
], TreeConnection);
|
|
90
|
+
let Tree = class Tree {
|
|
91
|
+
blobs;
|
|
92
|
+
trees;
|
|
93
|
+
};
|
|
94
|
+
exports.Tree = Tree;
|
|
95
|
+
__decorate([
|
|
96
|
+
(0, graphql_1.Field)(),
|
|
97
|
+
__metadata("design:type", BlobConnection)
|
|
98
|
+
], Tree.prototype, "blobs", void 0);
|
|
99
|
+
__decorate([
|
|
100
|
+
(0, graphql_1.Field)(),
|
|
101
|
+
__metadata("design:type", TreeConnection)
|
|
102
|
+
], Tree.prototype, "trees", void 0);
|
|
103
|
+
exports.Tree = Tree = __decorate([
|
|
104
|
+
(0, graphql_1.ObjectType)()
|
|
105
|
+
], Tree);
|
|
106
|
+
let RepositoryBlob = class RepositoryBlob {
|
|
107
|
+
name;
|
|
108
|
+
rawBlob;
|
|
109
|
+
rawTextBlob;
|
|
110
|
+
};
|
|
111
|
+
exports.RepositoryBlob = RepositoryBlob;
|
|
112
|
+
__decorate([
|
|
113
|
+
(0, graphql_1.Field)(),
|
|
114
|
+
__metadata("design:type", String)
|
|
115
|
+
], RepositoryBlob.prototype, "name", void 0);
|
|
116
|
+
__decorate([
|
|
117
|
+
(0, graphql_1.Field)(),
|
|
118
|
+
__metadata("design:type", String)
|
|
119
|
+
], RepositoryBlob.prototype, "rawBlob", void 0);
|
|
120
|
+
__decorate([
|
|
121
|
+
(0, graphql_1.Field)(),
|
|
122
|
+
__metadata("design:type", String)
|
|
123
|
+
], RepositoryBlob.prototype, "rawTextBlob", void 0);
|
|
124
|
+
exports.RepositoryBlob = RepositoryBlob = __decorate([
|
|
125
|
+
(0, graphql_1.ObjectType)()
|
|
126
|
+
], RepositoryBlob);
|
|
127
|
+
let RepositoryBlobConnection = class RepositoryBlobConnection {
|
|
128
|
+
nodes;
|
|
129
|
+
};
|
|
130
|
+
exports.RepositoryBlobConnection = RepositoryBlobConnection;
|
|
131
|
+
__decorate([
|
|
132
|
+
(0, graphql_1.Field)(() => [RepositoryBlob]),
|
|
133
|
+
__metadata("design:type", Array)
|
|
134
|
+
], RepositoryBlobConnection.prototype, "nodes", void 0);
|
|
135
|
+
exports.RepositoryBlobConnection = RepositoryBlobConnection = __decorate([
|
|
136
|
+
(0, graphql_1.ObjectType)()
|
|
137
|
+
], RepositoryBlobConnection);
|
|
138
|
+
let Repository = class Repository {
|
|
139
|
+
tree;
|
|
140
|
+
blobs;
|
|
141
|
+
};
|
|
142
|
+
exports.Repository = Repository;
|
|
143
|
+
__decorate([
|
|
144
|
+
(0, graphql_1.Field)(),
|
|
145
|
+
__metadata("design:type", Tree)
|
|
146
|
+
], Repository.prototype, "tree", void 0);
|
|
147
|
+
__decorate([
|
|
148
|
+
(0, graphql_1.Field)(),
|
|
149
|
+
__metadata("design:type", RepositoryBlobConnection)
|
|
150
|
+
], Repository.prototype, "blobs", void 0);
|
|
151
|
+
exports.Repository = Repository = __decorate([
|
|
152
|
+
(0, graphql_1.ObjectType)()
|
|
153
|
+
], Repository);
|
|
154
|
+
let Project = class Project {
|
|
155
|
+
repository;
|
|
156
|
+
};
|
|
157
|
+
exports.Project = Project;
|
|
158
|
+
__decorate([
|
|
159
|
+
(0, graphql_1.Field)(() => Repository),
|
|
160
|
+
__metadata("design:type", Repository)
|
|
161
|
+
], Project.prototype, "repository", void 0);
|
|
162
|
+
exports.Project = Project = __decorate([
|
|
163
|
+
(0, graphql_1.ObjectType)()
|
|
164
|
+
], Project);
|
|
165
|
+
let Query = class Query {
|
|
166
|
+
listDirectory;
|
|
167
|
+
readFile;
|
|
168
|
+
};
|
|
169
|
+
exports.Query = Query;
|
|
170
|
+
__decorate([
|
|
171
|
+
(0, graphql_1.Field)(),
|
|
172
|
+
__metadata("design:type", Project)
|
|
173
|
+
], Query.prototype, "listDirectory", void 0);
|
|
174
|
+
__decorate([
|
|
175
|
+
(0, graphql_1.Field)(),
|
|
176
|
+
__metadata("design:type", Project)
|
|
177
|
+
], Query.prototype, "readFile", void 0);
|
|
178
|
+
exports.Query = Query = __decorate([
|
|
179
|
+
(0, graphql_1.ObjectType)()
|
|
180
|
+
], Query);
|
|
181
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAoD;AAG7C,IAAM,IAAI,GAAV,MAAM,IAAI;IAEf,IAAI,CAAS;IAGb,IAAI,CAAS;CACd,CAAA;AANY,oBAAI;AAEf;IADC,IAAA,eAAK,GAAE;;kCACK;AAGb;IADC,IAAA,eAAK,GAAE;;kCACK;eALF,IAAI;IADhB,IAAA,oBAAU,GAAE;GACA,IAAI,CAMhB;AAGM,IAAM,QAAQ,GAAd,MAAM,QAAQ;IAEnB,IAAI,CAAO;CACZ,CAAA;AAHY,4BAAQ;AAEnB;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,IAAI,CAAC;8BACZ,IAAI;sCAAC;mBAFA,QAAQ;IADpB,IAAA,oBAAU,GAAE;GACA,QAAQ,CAGpB;AAGM,IAAM,cAAc,GAApB,MAAM,cAAc;IAEzB,KAAK,CAAa;CACnB,CAAA;AAHY,wCAAc;AAEzB;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC;;6CACN;yBAFP,cAAc;IAD1B,IAAA,oBAAU,GAAE;GACA,cAAc,CAG1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,MAAM,wBAAwB;IAEnC,KAAK,CAAmB;CACzB,CAAA;AAHY,4DAAwB;AAEnC;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,CAAC,cAAc,CAAC,CAAC;;uDACN;mCAFb,wBAAwB;IADpC,IAAA,oBAAU,GAAE;GACA,wBAAwB,CAGpC;AAGM,IAAM,UAAU,GAAhB,MAAM,UAAU;IAErB,IAAI,CAAQ;IAGZ,KAAK,CAA4B;CAClC,CAAA;AANY,gCAAU;AAErB;IADC,IAAA,eAAK,GAAE;8BACD,IAAI;wCAAC;AAGZ;IADC,IAAA,eAAK,GAAE;8BACA,wBAAwB;yCAAC;qBALtB,UAAU;IADtB,IAAA,oBAAU,GAAE;GACA,UAAU,CAMtB;AAEM,IAAM,OAAO,GAAb,MAAM,OAAO;IAElB,UAAU,CAAa;CACxB,CAAA;AAHY,0BAAO;AAElB;IADC,IAAA,eAAK,EAAC,GAAG,EAAE,CAAC,UAAU,CAAC;8BACZ,UAAU;2CAAC;kBAFZ,OAAO;IADnB,IAAA,oBAAU,GAAE;GACA,OAAO,CAGnB;AAGM,IAAM,KAAK,GAAX,MAAM,KAAK;IAEhB,aAAa,CAAU;IAGvB,QAAQ,CAAU;CACnB,CAAA;AANY,sBAAK;AAEhB;IADC,IAAA,eAAK,GAAE;8BACO,OAAO;4CAAC;AAGvB;IADC,IAAA,eAAK,GAAE;8BACE,OAAO;uCAAC;gBALP,KAAK;IADjB,IAAA,oBAAU,GAAE;GACA,KAAK,CAMjB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const axios_1 = require("axios");
|
|
4
|
+
const promises_1 = require("fs/promises");
|
|
5
|
+
const dotenv_1 = require("dotenv");
|
|
6
|
+
describe('cloudcmd test for the application', () => {
|
|
7
|
+
beforeAll(async () => {
|
|
8
|
+
(0, dotenv_1.config)();
|
|
9
|
+
await (0, promises_1.writeFile)(`${process.env.LOCAL_PATH}/test.txt`, 'content12345');
|
|
10
|
+
await new Promise((resolve) => setTimeout(resolve, 8000));
|
|
11
|
+
}, 10000);
|
|
12
|
+
afterAll(async () => {
|
|
13
|
+
await (0, promises_1.unlink)(`${process.env.LOCAL_PATH}/test.txt`);
|
|
14
|
+
await (0, promises_1.unlink)(`${process.env.LOCAL_PATH}/uploadTest.txt`);
|
|
15
|
+
}, 10000);
|
|
16
|
+
it('should return the correct directory that is set as root', async () => {
|
|
17
|
+
const response = await axios_1.default.get(`http://localhost:${process.env.PORT}${process.env.APOLLO_PATH}/files/api/v1/fs`, {
|
|
18
|
+
responseType: 'json',
|
|
19
|
+
});
|
|
20
|
+
console.log(response.data);
|
|
21
|
+
expect(response.data.path).toEqual('/');
|
|
22
|
+
expect(response.data.files[0].name).toEqual('common');
|
|
23
|
+
expect(response.data.files[1].name).toEqual('user1');
|
|
24
|
+
expect(response.data.files[2].name).toEqual('user2');
|
|
25
|
+
}, 10000);
|
|
26
|
+
it('should return the content of a file that is uplaoded to cloudcmd ', async () => {
|
|
27
|
+
const response = await axios_1.default.get(`http://localhost:${process.env.PORT}${process.env.APOLLO_PATH}/files/api/v1/fs/test.txt`);
|
|
28
|
+
expect(response.data).toEqual('content12345');
|
|
29
|
+
}, 10000);
|
|
30
|
+
it('should upload a file to cloudcmd', async () => {
|
|
31
|
+
const response = await axios_1.default.put(`http://localhost:${process.env.PORT}${process.env.APOLLO_PATH}/files/api/v1/fs/uploadTest.txt`, 'some content', { responseType: 'text' });
|
|
32
|
+
expect(response.data).toEqual('save: ok("uploadTest.txt")');
|
|
33
|
+
}, 10000);
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=cloudcmd.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloudcmd.spec.js","sourceRoot":"","sources":["../../../test/cloudcmd/cloudcmd.spec.ts"],"names":[],"mappings":";;AAA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