File tree Expand file tree Collapse file tree 3 files changed +16
-5
lines changed
Expand file tree Collapse file tree 3 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -39,4 +39,12 @@ export default defineNuxtConfig({
3939 colorMode : {
4040 classSuffix : '' ,
4141 } ,
42+ nitro : {
43+ storage : {
44+ data : {
45+ driver : 'fs' ,
46+ base : './data'
47+ }
48+ }
49+ }
4250} )
Original file line number Diff line number Diff line change 11export default defineNitroPlugin ( async ( nitroApp ) => {
2- const localConfig = getLocalConfig ( )
2+ const localConfig = await getLocalConfig ( )
33
44 if ( ! localConfig ) {
55 console . error ( 'Config not loaded!' )
Original file line number Diff line number Diff line change 1- import fs from 'node:fs'
21import crypto from 'node:crypto'
32import yaml from 'yaml'
43import type { BaseService , Config } from '~/types'
@@ -12,13 +11,17 @@ function determineServiceId(items: draftService[]): BaseService[] {
1211 } ) )
1312}
1413
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+
1618 try {
17- if ( ! fs . existsSync ( 'assets/config.yaml' ) ) {
19+ if ( ! await storage . hasItem ( file ) ) {
1820 return null
1921 }
2022
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 || '' ) || { }
2225 const services : Config [ 'services' ] = [ ]
2326
2427 if ( Array . isArray ( config . services ) ) {
You can’t perform that action at this time.
0 commit comments