Reading conf file

This commit is contained in:
Eric van der Vlist 2023-03-03 10:18:21 +01:00
parent 8731b6f8a5
commit 5d9f494a41
3 changed files with 11 additions and 2 deletions

2
.gitignore vendored
View File

@ -24,4 +24,4 @@ gitignore
Thumbs.db
# Conf
./conf/
conf/

View File

@ -1,6 +1,8 @@
import { APIEvent, json } from 'solid-start/api';
import { readConfig } from '~/server-only-lib/read-config';
export async function GET({ params, env }: APIEvent) {
console.log({ caller: 'api/conf GET', params });
const {credentials} = readConfig();
console.log({ caller: 'api/conf GET', params, credentials });
return json({ params, env, response: 'OK' });
}

View File

@ -0,0 +1,7 @@
import { readFileSync } from 'node:fs';
export const readConfig = () => {
const filePath = 'conf/config.json';
const fileContent = readFileSync(filePath, { encoding: 'utf-8' });
return JSON.parse(fileContent);
};