mirror of
				https://github.com/KevinMidboe/brewPi.git
				synced 2025-10-29 16:50:12 +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 IESTelemetry from './interfaces/IESTelemetry'; | ||||||
| import type IChartFrame from './interfaces/IChartFrame'; | import type IChartFrame from './interfaces/IChartFrame'; | ||||||
|  |  | ||||||
| const ES_ENDPOINT = `${env.ES_HOST}/${env.ES_INDEX}/_search`; | const ES_ENDPOINT = `${ES_HOST}/${ES_INDEX}/_search`; | ||||||
| const ES_APIKEY = env.ES_APIKEY; |  | ||||||
|  |  | ||||||
| function dateToESString(date: Date) { | function dateToESString(date: Date) { | ||||||
|   return date.toISOString(); |   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'; | import type { PageServerLoad } from './$types'; | ||||||
|  |  | ||||||
| const host = env.BREWLOGGER_HOST; | const sensorsUrl = `${BREWLOGGER_HOST}/api/sensors`; | ||||||
| const sensorsUrl = `${host}/api/sensors`; | const relaysUrl = `${BREWLOGGER_HOST}/api/relays`; | ||||||
| const relaysUrl = `${host}/api/relays`; |  | ||||||
|  |  | ||||||
| async function getSensors() { | async function getSensors() { | ||||||
|   return fetch(sensorsUrl) |   return fetch(sensorsUrl) | ||||||
|   | |||||||
| @@ -1,14 +1,12 @@ | |||||||
| import { json, RequestEvent } from '@sveltejs/kit'; | import { json, RequestEvent } from '@sveltejs/kit'; | ||||||
| import { env } from '$env/dynamic/private'; | import { BREWLOGGER_HOST } from '$env/static/private'; | ||||||
| import type { RequestHandler } from './$types'; | import type { RequestHandler } from './$types'; | ||||||
|  |  | ||||||
| const BREWPI_URL = env.BREWLOGGER_HOST; |  | ||||||
|  |  | ||||||
| export const POST = (async (event: RequestEvent) => { | export const POST = (async (event: RequestEvent) => { | ||||||
|   const { pathname } = new URL(event.request.url); |   const { pathname } = new URL(event.request.url); | ||||||
|  |  | ||||||
|   const options = { method: 'POST' }; |   const options = { method: 'POST' }; | ||||||
|   return fetch(BREWPI_URL + pathname, options) |   return fetch(BREWLOGGER_HOST + pathname, options) | ||||||
|     .then((resp) => resp.json()) |     .then((resp) => resp.json()) | ||||||
|     .then((response) => json(response)); |     .then((response) => json(response)); | ||||||
| }) satisfies RequestHandler; | }) satisfies RequestHandler; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user