add twilio config

use app version in config
This commit is contained in:
Benjamin Palko 2024-12-16 10:53:37 -05:00
parent ae9231d816
commit 728ea32c16
4 changed files with 39 additions and 4 deletions

8
.env
View file

@ -1,2 +1,6 @@
VITE_APP_VERSION=1.0.0-alpha # TWILIO
DATABASE_URL="postgres://hestia:test123@localhost:5432/hestia" VITE_TWILIO_ACCOUNT_SID=
VITE_TWILIO_AUTH_TOKEN=
# PRISMA
DATABASE_URL="file:./dev.db"

View file

@ -1,3 +1,4 @@
import { version } from '$app/environment';
import { builder } from '../builder'; import { builder } from '../builder';
builder.queryType({}); builder.queryType({});
@ -5,7 +6,7 @@ builder.queryType({});
builder.queryField('version', (t) => builder.queryField('version', (t) =>
t.string({ t.string({
description: 'Application version', description: 'Application version',
resolve: (parent, args, context) => context.config.app_version, resolve: () => version
}) })
); );

View file

@ -0,0 +1,27 @@
import { logger } from '$lib/server/logger';
import { z } from 'zod';
export interface TwilioConfiguration {
twilio_account_sid: string;
twilio_auth_token: string;
}
const LoadConfig = (): TwilioConfiguration => {
const { success, data, error } = z
.object({
VITE_TWILIO_ACCOUNT_SID: z.string(),
VITE_TWILIO_AUTH_TOKEN: z.string()
})
.safeParse(import.meta.env);
if (!success) {
logger.error(error.message);
}
return {
twilio_account_sid: data!.VITE_TWILIO_ACCOUNT_SID,
twilio_auth_token: data!.VITE_TWILIO_AUTH_TOKEN
};
};
export const TwilioConfig = LoadConfig();

View file

@ -8,6 +8,9 @@ const config = {
preprocess: vitePreprocess(), preprocess: vitePreprocess(),
kit: { kit: {
version: {
name: '1.0.0-alpha'
},
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list. // adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
// If your environment is not supported, or you settled on a specific environment, switch out the adapter. // If your environment is not supported, or you settled on a specific environment, switch out the adapter.
// See https://svelte.dev/docs/kit/adapters for more information about adapters. // See https://svelte.dev/docs/kit/adapters for more information about adapters.