5htp-core 0.2.7-9 → 0.2.8
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.
|
|
4
|
+
"version": "0.2.8",
|
|
5
5
|
"author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
|
|
6
6
|
"repository": "git://github.com/gaetanlegac/5htp-core.git",
|
|
7
7
|
"license": "MIT",
|
|
@@ -126,16 +126,18 @@ export default React.forwardRef<HTMLDivElement, Props>(({
|
|
|
126
126
|
return (
|
|
127
127
|
<li>
|
|
128
128
|
<Button size="s" onClick={() => {
|
|
129
|
-
|
|
130
129
|
onChange( current => {
|
|
130
|
+
|
|
131
|
+
console.log("click select", current, multiple, choice);
|
|
132
|
+
|
|
131
133
|
return multiple
|
|
132
134
|
? (isCurrent
|
|
133
135
|
? current.filter(c => c.value !== choice.value)
|
|
134
136
|
: [...(current || []), choice]
|
|
135
137
|
)
|
|
136
138
|
: (isCurrent
|
|
137
|
-
?
|
|
138
|
-
:
|
|
139
|
+
? undefined
|
|
140
|
+
: choice
|
|
139
141
|
)
|
|
140
142
|
});
|
|
141
143
|
|
package/src/server/app/index.ts
CHANGED
|
@@ -68,6 +68,7 @@ export default abstract class Application extends Service<Config, Hooks, /* TODO
|
|
|
68
68
|
public: process.cwd() + '/public',
|
|
69
69
|
|
|
70
70
|
// TODO: move to disk
|
|
71
|
+
var: process.cwd() + '/var',
|
|
71
72
|
typings: process.cwd() + '/var/typings',
|
|
72
73
|
cache: process.cwd() + '/var/cache',
|
|
73
74
|
data: process.cwd() + '/var/data',
|
|
@@ -39,6 +39,11 @@ export type TOutputFileOptions = {
|
|
|
39
39
|
encoding: string
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
export type TReadFileOptions = {
|
|
43
|
+
encoding?: 'string'|'buffer',
|
|
44
|
+
withMetas?: boolean
|
|
45
|
+
}
|
|
46
|
+
|
|
42
47
|
/*----------------------------------
|
|
43
48
|
- CLASS
|
|
44
49
|
----------------------------------*/
|
|
@@ -56,7 +61,11 @@ export default abstract class FsDriver<
|
|
|
56
61
|
|
|
57
62
|
public abstract readDir( bucketName: TBucketName, dirname?: string ): Promise<SourceFile[]>;
|
|
58
63
|
|
|
59
|
-
public abstract readFile(
|
|
64
|
+
public abstract readFile(
|
|
65
|
+
bucketName: TBucketName,
|
|
66
|
+
filename: string,
|
|
67
|
+
options: TReadFileOptions
|
|
68
|
+
): Promise<string>;
|
|
60
69
|
|
|
61
70
|
public abstract createReadStream( bucketName: TBucketName, filename: string );
|
|
62
71
|
|
|
@@ -21,6 +21,7 @@ import type { GlobImportedWithMetas } from 'babel-plugin-glob-import';
|
|
|
21
21
|
// Core
|
|
22
22
|
import Application, { Service } from '@server/app';
|
|
23
23
|
import context from '@server/context';
|
|
24
|
+
import type DiskDriver from '@server/services/disks/driver';
|
|
24
25
|
import { CoreError, NotFound } from '@common/errors';
|
|
25
26
|
import BaseRouter, {
|
|
26
27
|
TRoute, TErrorRoute, TRouteModule,
|
|
@@ -88,6 +89,8 @@ export type Config<
|
|
|
88
89
|
|
|
89
90
|
debug: boolean,
|
|
90
91
|
|
|
92
|
+
disk: DiskDriver,
|
|
93
|
+
|
|
91
94
|
http: HttpServiceConfig
|
|
92
95
|
|
|
93
96
|
// Set it as a function, so when we instanciate the services, we can callthis.router to pass the router instance in roiuter services
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
----------------------------------*/
|
|
9
9
|
|
|
10
10
|
// Npm
|
|
11
|
-
import fs from 'fs-extra';
|
|
12
11
|
import express from 'express';
|
|
13
12
|
|
|
14
13
|
// Core
|
|
@@ -241,28 +240,29 @@ export default class ServerResponse<
|
|
|
241
240
|
}
|
|
242
241
|
|
|
243
242
|
// TODO: https://github.com/adonisjs/http-server/blob/develop/src/Response/index.ts#L430
|
|
244
|
-
public file( fichier: string ) {
|
|
243
|
+
public async file( fichier: string ) {
|
|
245
244
|
|
|
246
245
|
// Securité
|
|
247
246
|
if (fichier.includes('..'))
|
|
248
247
|
throw new Forbidden("Disallowed");
|
|
249
248
|
|
|
250
|
-
// Force absolute path
|
|
251
|
-
if (!fichier.startsWith( this.app.path.root ))
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
249
|
+
// // Force absolute path
|
|
250
|
+
// if (!fichier.startsWith( this.app.path.root ))
|
|
251
|
+
// fichier = fichier[0] === '/'
|
|
252
|
+
// ? this.app.path.root + '/bin' + fichier
|
|
253
|
+
// : this.app.path.data + '/' + fichier;
|
|
255
254
|
|
|
256
|
-
|
|
255
|
+
const disk = this.router.config.disk;
|
|
257
256
|
|
|
258
257
|
// Verif existance
|
|
259
|
-
|
|
258
|
+
const fileExists = await disk.exists('data', fichier);
|
|
259
|
+
if (!fileExists) {
|
|
260
260
|
console.log("File " + fichier + " was not found.");
|
|
261
261
|
throw new NotFound();
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
// envoi fichier
|
|
265
|
-
this.data =
|
|
265
|
+
this.data = await disk.readFile('data', fichier);
|
|
266
266
|
return this.end();
|
|
267
267
|
}
|
|
268
268
|
|