@into-cps-association/libms 0.5.0 → 0.5.1

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 (80) hide show
  1. package/README.md +1 -0
  2. package/config/http.json +1 -0
  3. package/dist/src/app.module.js +5 -6
  4. package/dist/src/app.module.js.map +1 -1
  5. package/dist/src/bootstrap.js +11 -21
  6. package/dist/src/bootstrap.js.map +1 -1
  7. package/dist/src/config/config.interface.d.ts +14 -0
  8. package/dist/src/config/config.interface.js +2 -0
  9. package/dist/src/config/config.interface.js.map +1 -0
  10. package/dist/src/config/config.model.d.ts +14 -0
  11. package/dist/src/config/config.model.js +2 -0
  12. package/dist/src/config/config.model.js.map +1 -0
  13. package/dist/src/config/config.module.d.ts +2 -0
  14. package/dist/src/config/config.module.js +33 -0
  15. package/dist/src/config/config.module.js.map +1 -0
  16. package/dist/src/config/config.service.d.ts +17 -0
  17. package/dist/src/config/config.service.js +61 -0
  18. package/dist/src/config/config.service.js.map +1 -0
  19. package/dist/src/config/util.d.ts +1 -0
  20. package/dist/src/config/util.js +5 -0
  21. package/dist/src/config/util.js.map +1 -0
  22. package/dist/src/files/files-service.factory.d.ts +2 -2
  23. package/dist/src/files/files-service.factory.js +4 -1
  24. package/dist/src/files/files-service.factory.js.map +1 -1
  25. package/dist/src/files/files.module.js +2 -2
  26. package/dist/src/files/files.module.js.map +1 -1
  27. package/dist/src/files/git/git-files.service.d.ts +4 -2
  28. package/dist/src/files/git/git-files.service.js +31 -20
  29. package/dist/src/files/git/git-files.service.js.map +1 -1
  30. package/dist/src/files/interfaces/files.service.interface.d.ts +1 -0
  31. package/dist/src/files/local/local-files.service.d.ts +3 -2
  32. package/dist/src/files/local/local-files.service.js +12 -4
  33. package/dist/src/files/local/local-files.service.js.map +1 -1
  34. package/dist/src/main.d.ts +4 -1
  35. package/dist/test/cloudcmd/cloudcmd.spec.js +3 -3
  36. package/dist/test/cloudcmd/cloudcmd.spec.js.map +1 -1
  37. package/dist/test/e2e/app.e2e.spec.js +18 -12
  38. package/dist/test/e2e/app.e2e.spec.js.map +1 -1
  39. package/dist/test/integration/files.service.integration.spec.js +6 -6
  40. package/dist/test/integration/files.service.integration.spec.js.map +1 -1
  41. package/dist/test/testUtil.d.ts +7 -1
  42. package/dist/test/testUtil.js +20 -17
  43. package/dist/test/testUtil.js.map +1 -1
  44. package/dist/test/unit/files-service.factory.unit.spec.js +20 -8
  45. package/dist/test/unit/files-service.factory.unit.spec.js.map +1 -1
  46. package/dist/test/unit/files.resolver.unit.spec.js +1 -0
  47. package/dist/test/unit/files.resolver.unit.spec.js.map +1 -1
  48. package/dist/test/unit/git-files.service.unit.spec.js +6 -5
  49. package/dist/test/unit/git-files.service.unit.spec.js.map +1 -1
  50. package/dist/test/unit/local-files.service.unit.spec.js +36 -21
  51. package/dist/test/unit/local-files.service.unit.spec.js.map +1 -1
  52. package/dist/tsconfig.tsbuildinfo +1 -1
  53. package/eslint.config.js +5 -0
  54. package/libms.yaml.sample +12 -0
  55. package/package.json +9 -7
  56. package/src/app.module.ts +6 -7
  57. package/src/bootstrap.ts +14 -21
  58. package/src/config/config.interface.ts +14 -0
  59. package/src/config/config.model.ts +13 -0
  60. package/src/config/config.module.ts +23 -0
  61. package/src/config/config.service.ts +54 -0
  62. package/src/config/util.ts +5 -0
  63. package/src/files/files-service.factory.ts +5 -3
  64. package/src/files/files.module.ts +3 -3
  65. package/src/files/git/git-files.service.ts +28 -21
  66. package/src/files/interfaces/files.service.interface.ts +1 -0
  67. package/src/files/local/local-files.service.ts +13 -4
  68. package/src/main.ts +1 -1
  69. package/test/cloudcmd/cloudcmd.spec.ts +4 -4
  70. package/test/data/user2/tools/large_file.md +1 -0
  71. package/test/e2e/app.e2e.spec.ts +23 -13
  72. package/test/integration/files.service.integration.spec.ts +9 -10
  73. package/test/jest-e2e.json +3 -0
  74. package/test/libms.test.yaml +6 -0
  75. package/test/testUtil.ts +23 -19
  76. package/test/unit/files-service.factory.unit.spec.ts +22 -11
  77. package/test/unit/files.resolver.unit.spec.ts +1 -0
  78. package/test/unit/git-files.service.unit.spec.ts +6 -5
  79. package/test/unit/local-files.service.unit.spec.ts +41 -25
  80. package/test/update-config.js +25 -0
package/eslint.config.js CHANGED
@@ -20,6 +20,11 @@ export default [
20
20
  files: ['src/**', 'test/**'],
21
21
  },
22
22
  prettier,
23
+ {
24
+ ignores: [
25
+ 'test/update-config.js', // Add the file you want to ignore
26
+ ],
27
+ },
23
28
  {
24
29
  languageOptions: {
25
30
  globals: {
@@ -0,0 +1,12 @@
1
+ port: '4001'
2
+ mode: 'git'
3
+ local-path: '..\..\files'
4
+ log-level: 'debug'
5
+ apollo-path: '/lib'
6
+ graphql-playground: 'true'
7
+
8
+ git-repos:
9
+ - user-1:
10
+ repo-url: 'https://github.com/isomorphic-git/lightning-fs'
11
+ - user-2:
12
+ repo-url: 'https://github.com/isomorphic-git/lightning-fs'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@into-cps-association/libms",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "description": "microservices that handles request by fetching and returning the file-names and folders of given directory",
5
5
  "author": "phillip.boe.jensen@gmail.com",
6
6
  "contributors": [
@@ -24,14 +24,14 @@
24
24
  "syntax": "eslint . --fix",
25
25
  "pretest": "npx shx cp test/data/user2/tools/README.md ../../files/user2/tools/README.md",
26
26
  "posttest": "npx rimraf ../../files/user2/tools/README.md",
27
- "test:all": "npx cross-env NODE_OPTIONS=--experimental-vm-modules LOCAL_PATH=test/data jest --testPathIgnorePatterns=cloudcmd --coverage",
28
- "test:e2e": "npx cross-env NODE_OPTIONS=--experimental-vm-modules LOCAL_PATH=test/data jest --config ./test/jest-e2e.json --coverage",
27
+ "test:all": "npx cross-env NODE_OPTIONS=--experimental-vm-modules LIBMS_CONFIG_PATH=test/libms.test.yaml jest --testPathIgnorePatterns=cloudcmd --coverage",
28
+ "test:e2e": "npx cross-env NODE_OPTIONS=--experimental-vm-modules LIBMS_CONFIG_PATH=test/libms.test.yaml jest --config ./test/jest-e2e.json --coverage",
29
29
  "test:http": "yarn build && pm2 start -f --name libms-test dist/src/main.js -- -c .env -H ./config/http.json && jest test/cloudcmd --coverage --coverageThreshold=\"{}\" && pm2 delete libms-test",
30
30
  "test:http-nocov": "yarn build && pm2 start -f --name libms-test dist/src/main.js -- -c .env -H ./config/http.json && jest test/cloudcmd --coverage=false && pm2 delete libms-test",
31
31
  "test:http-github": "jest test/cloudcmd --coverage --coverageThreshold=\"{}\"",
32
- "test:int": "npx cross-env NODE_OPTIONS=--experimental-vm-modules LOCAL_PATH=test/data jest ../test/integration --coverage",
33
- "test:nocov": "yarn test:http-nocov && npx cross-env LOCAL_PATH=test/data jest --testPathIgnorePatterns=cloudcmd --coverage=false",
34
- "test:unit": "npx cross-env NODE_OPTIONS=--experimental-vm-modules LOCAL_PATH=test/data jest ../test/unit --coverage"
32
+ "test:int": "npx cross-env NODE_OPTIONS=--experimental-vm-modules LIBMS_CONFIG_PATH=test/libms.test.yaml jest ../test/integration --coverage",
33
+ "test:nocov": "yarn test:http-nocov && npx cross-env LIBMS_CONFIG_PATH=test/libms.test.yaml jest --testPathIgnorePatterns=cloudcmd --coverage=false",
34
+ "test:unit": "npx cross-env NODE_OPTIONS=--experimental-vm-modules LIBMS_CONFIG_PATH=test/libms.test.yaml jest ../test/unit --coverage"
35
35
  },
36
36
  "bin": "./dist/src/main.js",
37
37
  "dependencies": {
@@ -50,6 +50,7 @@
50
50
  "globals": "^15.11.0",
51
51
  "graphql": "^16.9.0",
52
52
  "isomorphic-git": "^1.27.1",
53
+ "js-yaml": "^4.1.0",
53
54
  "mock-fs": "^5.3.0",
54
55
  "reflect-metadata": "^0.2.2",
55
56
  "rxjs": "^7.8.1",
@@ -83,6 +84,7 @@
83
84
  "ts-jest": "^29.2.5",
84
85
  "ts-node": "^10.9.2",
85
86
  "tsconfig-paths": "4.2.0",
86
- "typescript": "^5.6.3"
87
+ "typescript": "^5.6.3",
88
+ "@types/js-yaml": "^4.0.9"
87
89
  }
88
90
  }
package/src/app.module.ts CHANGED
@@ -1,22 +1,21 @@
1
- import { ConfigModule, ConfigService } from '@nestjs/config';
2
1
  import { Module } from '@nestjs/common';
3
2
  import { GraphQLModule } from '@nestjs/graphql';
4
3
  import { ApolloDriver } from '@nestjs/apollo';
5
4
  import { join } from 'path';
6
5
  import FilesModule from './files/files.module.js';
6
+ import { ConfigModule } from './config/config.module.js';
7
+ import { CONFIG_SERVICE, IConfig } from './config/config.interface.js';
7
8
 
8
9
  @Module({
9
10
  imports: [
10
- ConfigModule.forRoot({
11
- isGlobal: true,
12
- }),
11
+ ConfigModule,
13
12
  GraphQLModule.forRootAsync({
14
13
  driver: ApolloDriver,
15
- useFactory: (configService: ConfigService) => ({
14
+ useFactory: (configService: IConfig) => ({
16
15
  autoSchemaFile: join(process.cwd(), 'src/schema.gql'),
17
- path: configService.get<string>('APOLLO_PATH'),
16
+ path: configService.getApolloPath(),
18
17
  }),
19
- inject: [ConfigService],
18
+ inject: [CONFIG_SERVICE],
20
19
  }),
21
20
  FilesModule,
22
21
  ],
package/src/bootstrap.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { NestFactory } from '@nestjs/core';
2
- import { ConfigService } from '@nestjs/config';
3
- import * as dotenv from 'dotenv';
4
2
  import AppModule from './app.module.js';
5
3
  import cloudCMD from './cloudcmd/cloudcmd.js';
4
+ import { Logger } from '@nestjs/common';
5
+ import { CONFIG_SERVICE, IConfig } from './config/config.interface.js';
6
6
 
7
7
  type BootstrapOptions = {
8
8
  config?: string;
@@ -11,30 +11,23 @@ type BootstrapOptions = {
11
11
  };
12
12
 
13
13
  export default async function bootstrap(options?: BootstrapOptions) {
14
- const configFile = dotenv.config({
15
- path: options?.config ?? '.env',
16
- override: true,
17
- });
18
- if (configFile.error && process.env.LOCAL_PATH === undefined) {
19
- // eslint-disable-next-line no-console
20
- console.error(configFile.error);
21
- if (options.runHelp) {
22
- options.runHelp();
23
- } else {
24
- process.exit(1);
25
- }
26
- }
14
+ const logger = new Logger(bootstrap.name);
15
+
16
+ if (process.env.LIBMS_CONFIG_PATH == null)
17
+ process.env.LIBMS_CONFIG_PATH = options.config ?? 'libms.yaml';
27
18
 
28
19
  const app = await NestFactory.create(AppModule);
29
- const configService = app.get(ConfigService);
30
- const port = configService.get<number>('PORT');
31
- const localPath = configService.get<string>('LOCAL_PATH');
32
- const mode = configService.get<string>('MODE');
20
+ const configService = app.get(CONFIG_SERVICE) as IConfig;
21
+ const port = configService.getPort();
22
+ const localPath = configService.getLocalPath();
23
+ const mode = configService.getMode();
33
24
 
34
- 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
+ logger.log(
26
+ `\x1b[32mStarting libms in \x1b[33m${mode} \x1b[32mmode, serving files from \x1b[34m${localPath} \x1b[32mon port \x1b[35m${port}\x1b[0m`,
27
+ );
35
28
 
36
29
  if (options.httpServer) {
37
- cloudCMD(app, options.httpServer, configService.get<string>('LOCAL_PATH'));
30
+ cloudCMD(app, options.httpServer, configService.getLocalPath());
38
31
  }
39
32
 
40
33
  await app.listen(port);
@@ -0,0 +1,14 @@
1
+ import { GitRepo } from './config.model';
2
+
3
+ export const CONFIG_SERVICE = 'CONFIG_SERVICE';
4
+
5
+ export interface IConfig {
6
+ loadConfig(configPath: string): Promise<void>;
7
+ getLocalPath(): string;
8
+ getApolloPath(): string;
9
+ getMode(): string;
10
+ getPort(): number;
11
+ getLogLevel(): string;
12
+ getGraphqlPlayground(): string;
13
+ getGitRepos(): { [key: string]: GitRepo }[];
14
+ }
@@ -0,0 +1,13 @@
1
+ export type ConfigValues = {
2
+ port: number;
3
+ 'local-path': string;
4
+ mode: string;
5
+ 'log-level': string;
6
+ 'apollo-path': string;
7
+ 'graphql-playground': string;
8
+ 'git-repos': { [key: string]: GitRepo }[];
9
+ };
10
+
11
+ export type GitRepo = {
12
+ 'repo-url': string;
13
+ };
@@ -0,0 +1,23 @@
1
+ import { Global, Module } from '@nestjs/common';
2
+ import * as nestConfig from '@nestjs/config';
3
+ import Config from './config.service.js';
4
+ import { CONFIG_SERVICE } from './config.interface.js';
5
+
6
+ @Global()
7
+ @Module({
8
+ imports: [nestConfig.ConfigModule.forRoot({ isGlobal: true })],
9
+ providers: [
10
+ {
11
+ provide: CONFIG_SERVICE,
12
+ useFactory: async (envConfigservice: nestConfig.ConfigService) => {
13
+ const confPath = envConfigservice.get<string>('LIBMS_CONFIG_PATH');
14
+ const config = new Config();
15
+ await config.loadConfig(confPath);
16
+ return config;
17
+ },
18
+ inject: [nestConfig.ConfigService],
19
+ },
20
+ ],
21
+ exports: [CONFIG_SERVICE],
22
+ })
23
+ export class ConfigModule {}
@@ -0,0 +1,54 @@
1
+ import { readFileSync } from 'fs';
2
+ import * as yaml from 'js-yaml';
3
+ import { Injectable, Logger } from '@nestjs/common';
4
+ import { ConfigValues, GitRepo } from './config.model.js';
5
+ import resolveFile from './util.js';
6
+ import { IConfig } from './config.interface.js';
7
+
8
+ @Injectable()
9
+ export default class Config implements IConfig {
10
+ private configValues: ConfigValues;
11
+ private logger: Logger;
12
+
13
+ constructor() {
14
+ this.logger = new Logger(Config.name);
15
+ }
16
+
17
+ async loadConfig(configPath: string): Promise<void> {
18
+ if (configPath !== undefined) {
19
+ try {
20
+ const configFile = readFileSync(resolveFile(configPath), 'utf8');
21
+ this.configValues = yaml.load(configFile) as ConfigValues;
22
+ } catch (e) {
23
+ this.logger.error('Error loading config file', e);
24
+ process.exit(1);
25
+ }
26
+ }
27
+ this.logger.log('Config loaded', this.configValues);
28
+ }
29
+
30
+ getLocalPath(): string {
31
+ return this.configValues['local-path'];
32
+ }
33
+
34
+ getApolloPath(): string {
35
+ return this.configValues['apollo-path'];
36
+ }
37
+
38
+ getMode(): string {
39
+ return this.configValues['mode'];
40
+ }
41
+
42
+ getPort(): number {
43
+ return this.configValues['port'];
44
+ }
45
+ getLogLevel(): string {
46
+ return this.configValues['log-level'];
47
+ }
48
+ getGraphqlPlayground(): string {
49
+ return this.configValues['graphql-playground'];
50
+ }
51
+ getGitRepos(): { [key: string]: GitRepo }[] {
52
+ return this.configValues['git-repos'];
53
+ }
54
+ }
@@ -0,0 +1,5 @@
1
+ import path from 'node:path';
2
+
3
+ export default function resolveFile(name: string): string {
4
+ return path.resolve(name);
5
+ }
@@ -1,18 +1,20 @@
1
1
  import { Injectable } from '@nestjs/common';
2
- import { ConfigService } from '@nestjs/config';
3
2
  import { IFilesService } from './interfaces/files.service.interface.js';
3
+ import { IConfig } from 'src/config/config.interface.js';
4
4
 
5
5
  @Injectable()
6
6
  export default class FilesServiceFactory {
7
7
  static create(
8
- configService: ConfigService,
8
+ configService: IConfig,
9
9
  fileServices: IFilesService[],
10
10
  ): IFilesService {
11
- const mode = configService.get<string>('MODE');
11
+ const mode = configService.getMode();
12
12
  const service = fileServices.find((s) => s.getMode() == mode);
13
13
 
14
14
  if (service == undefined) {
15
15
  throw new Error(`Invalid MODE: ${mode}`);
16
+ } else {
17
+ service.init();
16
18
  }
17
19
  return service;
18
20
  }
@@ -6,7 +6,7 @@ import LocalFilesService from './local/local-files.service.js';
6
6
  import GitFilesService from './git/git-files.service.js';
7
7
  import { FILE_SERVICE } from './interfaces/files.service.interface.js';
8
8
  import FilesServiceFactory from './files-service.factory.js';
9
- import { ConfigService } from '@nestjs/config';
9
+ import { CONFIG_SERVICE, IConfig } from '../config/config.interface.js';
10
10
 
11
11
  @Module({
12
12
  imports: [LocalFilesModule, GitFilesModule],
@@ -15,14 +15,14 @@ import { ConfigService } from '@nestjs/config';
15
15
  {
16
16
  provide: FILE_SERVICE,
17
17
  useFactory: (
18
- configService: ConfigService,
18
+ configService: IConfig,
19
19
  localFilesService: LocalFilesService,
20
20
  gitFilesService: GitFilesService,
21
21
  ) => {
22
22
  const fileServices = [localFilesService, gitFilesService];
23
23
  return FilesServiceFactory.create(configService, fileServices);
24
24
  },
25
- inject: [ConfigService, LocalFilesService, GitFilesService],
25
+ inject: [CONFIG_SERVICE, LocalFilesService, GitFilesService],
26
26
  },
27
27
  ],
28
28
  })
@@ -1,46 +1,54 @@
1
- import { Inject, Injectable } from '@nestjs/common';
1
+ import { Inject, Injectable, Logger } from '@nestjs/common';
2
2
  import { Project } from 'src/types.js';
3
3
  import { IFilesService } from '../interfaces/files.service.interface.js';
4
4
  import { CONFIG_MODE } from '../../enums/config-mode.enum.js';
5
- import { ConfigService } from '@nestjs/config';
6
5
  import * as git from 'isomorphic-git';
7
6
  import * as fs from 'fs';
8
7
  import * as http from 'isomorphic-git/http/node/index.cjs';
9
8
  import LocalFilesService from '../local/local-files.service.js';
9
+ import Config from '../../config/config.service.js';
10
+ import { CONFIG_SERVICE } from '../../config/config.interface.js';
11
+ import path from 'path';
10
12
 
11
13
  @Injectable()
12
14
  export default class GitFilesService implements IFilesService {
13
15
  private readonly dataPath: string;
16
+ private readonly logger: Logger;
14
17
  @Inject(LocalFilesService) private localFilesService: LocalFilesService;
15
18
 
16
- constructor(private configService: ConfigService) {
17
- this.dataPath = this.configService.get('LOCAL_PATH');
18
- this.cloneRepositories();
19
+ constructor(@Inject(CONFIG_SERVICE) private configService: Config) {
20
+ this.dataPath = this.configService.getLocalPath();
21
+ this.logger = new Logger(GitFilesService.name);
19
22
  }
20
23
 
21
- private cloneRepositories() {
22
- let userRepoUrl = '';
23
- let userRepoUrls = [];
24
- let userCounter = 1;
25
- while ((userRepoUrl = this.configService.get(
26
- `GIT_USER${userCounter}_REPO_URL`
27
- )) !== undefined) {
28
- userRepoUrls.push(userRepoUrl);
29
- ++userCounter;
24
+ init(): Promise<any> {
25
+ return this.cloneRepositories();
26
+ }
27
+
28
+ private cloneRepositories(): Promise<void[]> {
29
+ const userRepoConfigs = this.configService.getGitRepos();
30
+
31
+ if (!userRepoConfigs || userRepoConfigs.length === 0) {
32
+ throw new Error('No git repos found in config');
30
33
  }
31
34
 
32
- userRepoUrls.forEach((userRepoUrl, i) => {
33
- git
35
+ const clonePromises = userRepoConfigs.map((repoConf) => {
36
+ const user = Object.keys(repoConf)[0];
37
+ const repoUrl = repoConf[user]['repo-url'];
38
+
39
+ return git
34
40
  .clone({
35
41
  fs,
36
42
  http,
37
- dir: this.dataPath + `/user${i + 1}`,
38
- url: userRepoUrl,
39
- ref: 'main',
43
+ dir: this.dataPath + `/${user}`,
44
+ gitdir: path.join(this.dataPath, 'gitdir', user, '.git'),
45
+ url: repoUrl.includes('.git') ? repoUrl : repoUrl + '.git',
40
46
  singleBranch: true,
47
+ depth: 1,
41
48
  })
42
- .then(() => console.log('done cloning ' + userRepoUrl));
49
+ .then(() => this.logger.log('done cloning ' + repoUrl));
43
50
  });
51
+ return Promise.all(clonePromises);
44
52
  }
45
53
 
46
54
  getMode(): CONFIG_MODE {
@@ -48,7 +56,6 @@ export default class GitFilesService implements IFilesService {
48
56
  }
49
57
 
50
58
  listDirectory(path: string): Promise<Project> {
51
- console.log('listDirectory', path);
52
59
  return this.localFilesService.listDirectory(path);
53
60
  }
54
61
 
@@ -7,4 +7,5 @@ export interface IFilesService {
7
7
  listDirectory(path: string): Promise<Project>;
8
8
  readFile(path: string): Promise<Project>;
9
9
  getMode(): CONFIG_MODE;
10
+ init(): Promise<any>;
10
11
  }
@@ -1,19 +1,28 @@
1
- import { Injectable, InternalServerErrorException } from '@nestjs/common';
1
+ import {
2
+ Inject,
3
+ Injectable,
4
+ InternalServerErrorException,
5
+ } from '@nestjs/common';
2
6
  import * as fs from 'fs';
3
7
  import { join } from 'path';
4
- import { ConfigService } from '@nestjs/config';
5
8
  import { Project } from 'src/types.js';
6
9
  import { IFilesService } from '../interfaces/files.service.interface.js';
7
10
  import { CONFIG_MODE } from '../../enums/config-mode.enum.js';
11
+ import Config from '../../config/config.service.js';
12
+ import { CONFIG_SERVICE } from '../../config/config.interface.js';
8
13
 
9
14
  @Injectable()
10
15
  export default class LocalFilesService implements IFilesService {
11
16
  private readonly dataPath: string;
12
17
 
13
- constructor(private configService: ConfigService) {
14
- this.dataPath = this.configService.get('LOCAL_PATH');
18
+ constructor(@Inject(CONFIG_SERVICE) private configService: Config) {
19
+ this.dataPath = this.configService.getLocalPath();
20
+ }
15
21
 
22
+ init(): Promise<any> {
23
+ return Promise.resolve();
16
24
  }
25
+
17
26
  getMode(): CONFIG_MODE {
18
27
  return CONFIG_MODE.LOCAL;
19
28
  }
package/src/main.ts CHANGED
@@ -2,7 +2,7 @@
2
2
  import { Command } from 'commander';
3
3
  import bootstrap from './bootstrap.js';
4
4
 
5
- type ProgramOptions = {
5
+ export type ProgramOptions = {
6
6
  config?: string;
7
7
  http?: string;
8
8
  };
@@ -7,9 +7,9 @@ describe('cloudcmd test for the application', () => {
7
7
  config();
8
8
 
9
9
  await writeFile(`${process.env.LOCAL_PATH}/test.txt`, 'content12345');
10
- // eslint-disable-next-line no-promise-executor-return
11
- await new Promise((resolve) => setTimeout(resolve, 8000));
12
- }, 10000);
10
+
11
+ await new Promise((resolve) => setTimeout(resolve, 50000)); // This is problematic.
12
+ }, 55000);
13
13
 
14
14
  afterAll(async () => {
15
15
  await unlink(`${process.env.LOCAL_PATH}/test.txt`);
@@ -30,7 +30,7 @@ describe('cloudcmd test for the application', () => {
30
30
  expect(fileNames).toContain('user2');
31
31
  }, 10000);
32
32
 
33
- it('should return the content of a file that is uplaoded to cloudcmd ', async () => {
33
+ it('should return the content of a file that is uplaoded to cloudcmd', async () => {
34
34
  const response = await axios.get(
35
35
  `http://localhost:${process.env.PORT}${process.env.APOLLO_PATH}/files/api/v1/fs/test.txt`,
36
36
  );