mirror of
https://github.com/KevinMidboe/brewPi.git
synced 2025-10-29 08:40:13 +00:00
All env variables imported during build time
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user