Skip to content

Commit

Permalink
chore(app): change env vars to dynamic resolving
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcnk committed Feb 12, 2024
1 parent b2240da commit 91c30a5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 12 deletions.
8 changes: 4 additions & 4 deletions src/routes/(auth)/signin/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type { Actions } from './$types';
import { adjectives, animals, colors, uniqueNamesGenerator } from 'unique-names-generator';
import { error, redirect } from '@sveltejs/kit';
import type { PageServerLoad } from './$types';
import { SECRET_PLUNK_API_KEY } from '$env/static/private';
import { PUBLIC_APP_URL } from '$env/static/public';
import { env as envPrivate } from '$env/dynamic/private';
import { env as envPublic } from '$env/dynamic/public';

const ensureUser = async ({ email }: { email: string }) => {
const existingUser = await db.query.user.findFirst({ where: eq(user.email, email) });
Expand Down Expand Up @@ -49,12 +49,12 @@ export const actions: Actions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${SECRET_PLUNK_API_KEY}`
Authorization: `Bearer ${envPrivate.SECRET_PLUNK_API_KEY}`
},
body: JSON.stringify({
to: email,
subject: 'Sign in to Supso',
body: `Sign in: ${PUBLIC_APP_URL}/verify?token=${code.id}`
body: `Sign in: ${envPublic.PUBLIC_APP_URL}/verify?token=${code.id}`
})
});
console.log(emailRequest);
Expand Down
4 changes: 2 additions & 2 deletions src/routes/(dashboard)/playground/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import { codeToHtml } from 'shiki';
import dedent from 'dedent';
import { derived, writable } from 'svelte/store';
import { PUBLIC_APP_URL } from '$env/static/public';
import { env as envPublic } from '$env/dynamic/public';
import { CopyIcon, InfoIcon, ArrowUpRightIcon } from 'lucide-svelte';
export let data;
Expand Down Expand Up @@ -50,7 +50,7 @@
);
export const execute = async () => {
await fetch(PUBLIC_APP_URL + '/api/log', {
await fetch(envPublic.PUBLICA_APP_URL + '/api/log', {
method: 'POST',
body: JSON.stringify({
projectId: $projectId,
Expand Down
11 changes: 7 additions & 4 deletions src/routes/api/log/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { insertEventSchema, usersToProjects, event as eventScheme } from '$lib/d
import { error } from '@sveltejs/kit';
import { UAParser } from 'ua-parser-js';
import { z } from 'zod';
import { PUBLIC_APP_URL } from '$env/static/public';
import { env as envPublic } from '$env/dynamic/public';
import { formatDate } from '$lib/format/date';

/**
Expand Down Expand Up @@ -57,17 +57,20 @@ export const POST: RequestHandler = async ({ request, locals }) => {
embeds: [
{
title: `${result.emoji ? result.emoji + ' ' : ''}${result.event}`,
url: PUBLIC_APP_URL + `/events/${result.id}`,
url: envPublic.PUBLIC_APP_URL + `/events/${result.id}`,
color: null,
fields: [
{
name: 'Project',
value: `[${project.name}](${PUBLIC_APP_URL + `/projects/${project.id}`})`
value: `[${project.name}](${
envPublic.PUBLIC_APP_URL + `/projects/${project.id}`
})`
},
{
name: 'Channel',
value: `[#${result.channel}](${
PUBLIC_APP_URL + `/projects/${project.id}/events?channel=${result.channel}`
envPublic.PUBLIC_APP_URL +
`/projects/${project.id}/events?channel=${result.channel}`
})`
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/routes/api/projects/[projectId]/rss/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { db } from '$lib/db';
import { and, eq } from 'drizzle-orm';
import { usersToProjects } from '$lib/db/schema';
import { Feed } from 'feed';
import { PUBLIC_APP_URL } from '$env/static/public';
import { env as envPublic } from '$env/dynamic/public';

export const GET: RequestHandler = async ({ locals, params }) => {
const { projectId } = params;
Expand Down Expand Up @@ -38,7 +38,7 @@ export const GET: RequestHandler = async ({ locals, params }) => {
description: `${project.name}: ${event.event} in ${event.channel}`,
content: event.content ?? '',
date: new Date(parseInt(event.createdAt ?? '')),
link: PUBLIC_APP_URL + '/events/' + event.id
link: envPublic.PUBLIC_APP_URL + '/events/' + event.id
});
});
return new Response(feed.rss2(), { headers: { 'Content-Type': 'text/xml' } });
Expand Down

0 comments on commit 91c30a5

Please sign in to comment.