5htp-core 0.2.9-1 → 0.2.9-3

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "5htp-core",
3
3
  "description": "Convenient TypeScript framework designed for Performance and Productivity.",
4
- "version": "0.2.9-1",
4
+ "version": "0.2.9-3",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp-core.git",
7
7
  "license": "MIT",
@@ -13,7 +13,7 @@
13
13
  "framework"
14
14
  ],
15
15
  "dependencies": {
16
- "@wojtekmaj/react-daterange-picker": "^4.2.0",
16
+ "@wojtekmaj/react-daterange-picker": "^5.0.2",
17
17
  "accepts": "^1.3.7",
18
18
  "activity-detector": "^3.0.0",
19
19
  "ansi-to-html": "^0.7.1",
@@ -64,6 +64,7 @@
64
64
  "picomatch": "^2.3.1",
65
65
  "preact": "^10.5.15",
66
66
  "preact-render-to-string": "^5.1.19",
67
+ "react-datetime-picker": "^5.0.3",
67
68
  "react-scrollbars-custom": "^4.0.27",
68
69
  "react-slider": "^2.0.1",
69
70
  "react-textarea-autosize": "^8.3.3",
@@ -12,6 +12,9 @@ import ConfigParser, { TEnvConfig } from './config';
12
12
  import { default as Service, AnyService } from './service';
13
13
  import CommandsManager from './commands';
14
14
 
15
+ // Crore servoces
16
+ import type DisksManager from '@server/services/disks';
17
+
15
18
  // Built-in
16
19
  import type { default as Router, Request as ServerRequest } from '@server/services/router';
17
20
 
@@ -85,6 +88,12 @@ export default abstract class Application extends Service<Config, Hooks, /* TODO
85
88
 
86
89
  private servicesList: AnyService[] = []
87
90
 
91
+ /*----------------------------------
92
+ - MANDATORY SERVICES
93
+ ----------------------------------*/
94
+
95
+ public abstract disk: DisksManager;
96
+
88
97
  /*----------------------------------
89
98
  - INIT
90
99
  ----------------------------------*/
@@ -38,7 +38,8 @@ type ConnectionConfig = {
38
38
 
39
39
  export type DatabaseServiceConfig = {
40
40
  debug: boolean,
41
- connections: ConnectionConfig[]
41
+ connections: ConnectionConfig[],
42
+ connectionsLimit: number
42
43
  }
43
44
 
44
45
  export type THooks = {
@@ -136,7 +137,7 @@ export default class DatabaseManager extends Service<DatabaseServiceConfig, THoo
136
137
 
137
138
  // Pool
138
139
  waitForConnections: true,
139
- connectionLimit: 100,
140
+ connectionLimit: this.config.connectionsLimit,
140
141
  queueLimit: 0,
141
142
 
142
143
  // Dates & timezone
@@ -73,7 +73,12 @@ export default abstract class FsDriver<
73
73
 
74
74
  public abstract move( bucketName: TBucketName, source: string, destination: string, options: { overwrite?: boolean }): Promise<void>;
75
75
 
76
- public abstract outputFile( bucketName: TBucketName, filename: string, content: string, encoding: TOutputFileOptions ): Promise<{
76
+ public abstract outputFile(
77
+ bucketName: TBucketName,
78
+ filename: string,
79
+ content: string | Buffer,
80
+ options?: TOutputFileOptions
81
+ ): Promise<{
77
82
  path: string
78
83
  }>;
79
84
 
@@ -15,6 +15,7 @@ import type Driver from './driver';
15
15
  type TMountpointList = { [name: string]: Driver }
16
16
 
17
17
  type Config<MountpointList extends TMountpointList> = {
18
+ debug: boolean,
18
19
  default: keyof MountpointList,
19
20
  }
20
21
 
@@ -36,7 +37,7 @@ export default class DisksManager<
36
37
  public constructor(
37
38
  public app: TApplication,
38
39
  public config: TConfig,
39
- public mounted: MountpointList
40
+ public mounted: MountpointList
40
41
  ) {
41
42
 
42
43
  super(app, config);
@@ -12,6 +12,7 @@ import request from 'request';
12
12
  // Core: general
13
13
  import type Application from '@server/app';
14
14
  import Service from '@server/app/service';
15
+ import type FsDriver from '../disks/driver';
15
16
 
16
17
  /*----------------------------------
17
18
  - SERVICE TYPES
@@ -74,7 +75,9 @@ export default class FetchService extends Service<Config, Hooks, Application> {
74
75
  public async image(
75
76
  imageFileUrl: string,
76
77
  { width, height, fit, quality }: TImageConfig,
77
- saveToPath?: string
78
+ saveToBucket: string,
79
+ saveToPath?: string,
80
+ disk?: FsDriver
78
81
  ): Promise<Buffer | null> {
79
82
 
80
83
  // Download
@@ -97,10 +100,14 @@ export default class FetchService extends Service<Config, Hooks, Application> {
97
100
  return null;
98
101
  })
99
102
 
103
+ // Define target disk
104
+ if (disk === undefined)
105
+ disk = this.app.disk.default;
106
+
100
107
  // Save file
101
108
  if (saveToPath !== undefined && processedBuffer !== null) {
102
109
  console.log(LogPrefix, `Saving ${imageFileUrl} logo to ${saveToPath}`);
103
- fs.outputFileSync(saveToPath, processedBuffer);
110
+ await disk.outputFile(saveToBucket, saveToPath, processedBuffer);
104
111
  }
105
112
 
106
113
  // We return the original, because Vibrant.js doesn't support webp
@@ -262,7 +262,7 @@ export default class ServerResponse<
262
262
  }
263
263
 
264
264
  // envoi fichier
265
- this.data = await disk.readFile('data', fichier);
265
+ this.data = await disk.readFile('data', fichier, {});
266
266
  return this.end();
267
267
  }
268
268