adminforth 2.4.0-next.45 → 2.4.0-next.47
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/commands/callTsProxy.js
CHANGED
|
@@ -3,18 +3,28 @@ import { spawn } from "child_process";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import fs from "fs";
|
|
5
5
|
import chalk from "chalk";
|
|
6
|
+
import dotenv from "dotenv";
|
|
6
7
|
|
|
7
8
|
const currentFilePath = import.meta.url;
|
|
8
9
|
const currentFileFolder = path.dirname(currentFilePath).replace("file:", "");
|
|
9
10
|
|
|
10
11
|
export function callTsProxy(tsCode, silent=false) {
|
|
11
12
|
|
|
13
|
+
const currentDirectory = process.cwd();
|
|
14
|
+
const envPath = path.resolve(currentDirectory, ".env");
|
|
15
|
+
const envLocalPath = path.resolve(currentDirectory, ".env.local");
|
|
16
|
+
if (fs.existsSync(envLocalPath)) {
|
|
17
|
+
dotenv.config({ path: envLocalPath, override: true });
|
|
18
|
+
}
|
|
19
|
+
if (fs.existsSync(envPath)) {
|
|
20
|
+
dotenv.config({ path: envPath, override: true });
|
|
21
|
+
}
|
|
22
|
+
|
|
12
23
|
process.env.HEAVY_DEBUG && console.log("🌐 Calling tsproxy with code:", path.join(currentFileFolder, "proxy.ts"));
|
|
13
24
|
return new Promise((resolve, reject) => {
|
|
14
|
-
const child = spawn("tsx", [
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
25
|
+
const child = spawn("tsx", [path.join(currentFileFolder, "proxy.ts")], {
|
|
26
|
+
env: process.env,
|
|
27
|
+
});
|
|
18
28
|
let stdout = "";
|
|
19
29
|
let stderr = "";
|
|
20
30
|
|
|
@@ -5,15 +5,21 @@
|
|
|
5
5
|
:expandDepth="expandDepth"
|
|
6
6
|
copyable
|
|
7
7
|
sort
|
|
8
|
+
:theme="currentTheme"
|
|
8
9
|
/>
|
|
9
10
|
</template>
|
|
10
11
|
|
|
11
12
|
<script setup lang="ts">
|
|
13
|
+
import { computed } from 'vue'
|
|
12
14
|
import { JsonViewer } from 'vue3-json-viewer'
|
|
15
|
+
import { useCoreStore } from '@/stores/core'
|
|
13
16
|
|
|
14
17
|
defineProps<{
|
|
15
18
|
value: any
|
|
16
19
|
expandDepth?: number
|
|
17
20
|
}>()
|
|
18
21
|
|
|
22
|
+
const coreStore = useCoreStore()
|
|
23
|
+
|
|
24
|
+
const currentTheme = computed(() => (coreStore.theme === 'dark' ? 'dark' : 'light'))
|
|
19
25
|
</script>
|
|
@@ -92,16 +92,16 @@ export interface IExpressHttpServer extends IHttpServer {
|
|
|
92
92
|
* Adds adminUser to request object if user is authorized. Drops request with 401 status if user is not authorized.
|
|
93
93
|
* @param callable : Function which will be called if user is authorized.
|
|
94
94
|
*
|
|
95
|
-
* Example:
|
|
96
95
|
*
|
|
96
|
+
* @example
|
|
97
97
|
* ```ts
|
|
98
|
-
* expressApp.get('/myApi', authorize((req, res) =>
|
|
98
|
+
* expressApp.get('/myApi', authorize((req, res) => {
|
|
99
99
|
* console.log('User is authorized', req.adminUser);
|
|
100
|
-
* res.json(
|
|
101
|
-
*
|
|
100
|
+
* res.json({ message: 'Hello World' });
|
|
101
|
+
* }));
|
|
102
102
|
* ```
|
|
103
103
|
*
|
|
104
|
-
*/
|
|
104
|
+
*/
|
|
105
105
|
authorize(callable: Function): void;
|
|
106
106
|
}
|
|
107
107
|
|
package/dist/types/Back.d.ts
CHANGED
|
@@ -62,13 +62,13 @@ export interface IExpressHttpServer extends IHttpServer {
|
|
|
62
62
|
* Adds adminUser to request object if user is authorized. Drops request with 401 status if user is not authorized.
|
|
63
63
|
* @param callable : Function which will be called if user is authorized.
|
|
64
64
|
*
|
|
65
|
-
* Example:
|
|
66
65
|
*
|
|
66
|
+
* @example
|
|
67
67
|
* ```ts
|
|
68
|
-
* expressApp.get('/myApi', authorize((req, res) =>
|
|
68
|
+
* expressApp.get('/myApi', authorize((req, res) => {
|
|
69
69
|
* console.log('User is authorized', req.adminUser);
|
|
70
|
-
* res.json(
|
|
71
|
-
*
|
|
70
|
+
* res.json({ message: 'Hello World' });
|
|
71
|
+
* }));
|
|
72
72
|
* ```
|
|
73
73
|
*
|
|
74
74
|
*/
|