File tree 3 files changed +16
-5
lines changed
3 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -39,4 +39,12 @@ export default defineNuxtConfig({
39
39
colorMode : {
40
40
classSuffix : '' ,
41
41
} ,
42
+ nitro : {
43
+ storage : {
44
+ data : {
45
+ driver : 'fs' ,
46
+ base : './data'
47
+ }
48
+ }
49
+ }
42
50
} )
Original file line number Diff line number Diff line change 1
1
export default defineNitroPlugin ( async ( nitroApp ) => {
2
- const localConfig = getLocalConfig ( )
2
+ const localConfig = await getLocalConfig ( )
3
3
4
4
if ( ! localConfig ) {
5
5
console . error ( 'Config not loaded!' )
Original file line number Diff line number Diff line change 1
- import fs from 'node:fs'
2
1
import crypto from 'node:crypto'
3
2
import yaml from 'yaml'
4
3
import type { BaseService , Config } from '~/types'
@@ -12,13 +11,17 @@ function determineServiceId(items: draftService[]): BaseService[] {
12
11
} ) )
13
12
}
14
13
15
- export function getLocalConfig ( ) : Config | null {
14
+ export async function getLocalConfig ( ) : Promise < Config | null > {
15
+ const storage = useStorage ( 'data' )
16
+ const file = 'config.yml'
17
+
16
18
try {
17
- if ( ! fs . existsSync ( 'assets/config.yaml' ) ) {
19
+ if ( ! await storage . hasItem ( file ) ) {
18
20
return null
19
21
}
20
22
21
- const config = yaml . parse ( fs . readFileSync ( 'assets/config.yaml' , 'utf8' ) ) || { }
23
+ const raw = await storage . getItem < string > ( file )
24
+ const config = yaml . parse ( raw || '' ) || { }
22
25
const services : Config [ 'services' ] = [ ]
23
26
24
27
if ( Array . isArray ( config . services ) ) {
You can’t perform that action at this time.
0 commit comments