All env variables imported during build time

This commit is contained in:
2023-05-30 18:28:22 +02:00
parent d155637e5f
commit 2edb253ead
3 changed files with 7 additions and 11 deletions

View File

@@ -1,9 +1,8 @@
import { env } from '$env/dynamic/private';
import { ES_HOST, ES_INDEX, ES_APIKEY } from '$env/static/private';
import type IESTelemetry from './interfaces/IESTelemetry';
import type IChartFrame from './interfaces/IChartFrame';
const ES_ENDPOINT = `${env.ES_HOST}/${env.ES_INDEX}/_search`;
const ES_APIKEY = env.ES_APIKEY;
const ES_ENDPOINT = `${ES_HOST}/${ES_INDEX}/_search`;
function dateToESString(date: Date) {
return date.toISOString();

View File

@@ -1,9 +1,8 @@
import { env } from '$env/dynamic/private';
import { BREWLOGGER_HOST } from '$env/static/private';
import type { PageServerLoad } from './$types';
const host = env.BREWLOGGER_HOST;
const sensorsUrl = `${host}/api/sensors`;
const relaysUrl = `${host}/api/relays`;
const sensorsUrl = `${BREWLOGGER_HOST}/api/sensors`;
const relaysUrl = `${BREWLOGGER_HOST}/api/relays`;
async function getSensors() {
return fetch(sensorsUrl)

View File

@@ -1,14 +1,12 @@
import { json, RequestEvent } from '@sveltejs/kit';
import { env } from '$env/dynamic/private';
import { BREWLOGGER_HOST } from '$env/static/private';
import type { RequestHandler } from './$types';
const BREWPI_URL = env.BREWLOGGER_HOST;
export const POST = (async (event: RequestEvent) => {
const { pathname } = new URL(event.request.url);
const options = { method: 'POST' };
return fetch(BREWPI_URL + pathname, options)
return fetch(BREWLOGGER_HOST + pathname, options)
.then((resp) => resp.json())
.then((response) => json(response));
}) satisfies RequestHandler;