Reading conf file
This commit is contained in:
parent
8731b6f8a5
commit
5d9f494a41
|
@ -24,4 +24,4 @@ gitignore
|
|||
Thumbs.db
|
||||
|
||||
# Conf
|
||||
./conf/
|
||||
conf/
|
||||
|
|
|
@ -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' });
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
};
|
Loading…
Reference in New Issue