fix: make env dynamic
This commit is contained in:
@@ -1,5 +1,3 @@
|
|||||||
|
|
||||||
|
|
||||||
FROM node:18
|
FROM node:18
|
||||||
|
|
||||||
WORKDIR "/app"
|
WORKDIR "/app"
|
||||||
@@ -15,11 +13,11 @@ COPY . /app/
|
|||||||
|
|
||||||
WORKDIR "/app/apps/dashboard"
|
WORKDIR "/app/apps/dashboard"
|
||||||
|
|
||||||
RUN pnpm i --frozen-lockfile
|
RUN pnpm i --frozen-lockfile
|
||||||
|
RUN pnpm prepare
|
||||||
RUN pnpm build
|
RUN pnpm build
|
||||||
|
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
|
||||||
CMD ["ls", "-la"]
|
|
||||||
CMD ["pnpm", "start"]
|
CMD ["pnpm", "start"]
|
||||||
# CMD [ "sh", "-c", "ls -la && cd apps/dashboard && pnpm build && pnpm start" ]
|
# CMD [ "sh", "-c", "ls -la && cd apps/dashboard && pnpm build && pnpm start" ]
|
||||||
|
|||||||
@@ -5,17 +5,17 @@ import {
|
|||||||
DomainConfigResponse,
|
DomainConfigResponse,
|
||||||
DomainVerificationResponse
|
DomainVerificationResponse
|
||||||
} from '$lib/utils/types/org';
|
} from '$lib/utils/types/org';
|
||||||
import { PROJECT_ID_VERCEL, TEAM_ID_VERCEL, AUTH_BEARER_TOKEN } from '$env/static/private';
|
import { env } from '$env/dynamic/private';
|
||||||
|
|
||||||
export const addDomainToVercel = async (domain: string) => {
|
export const addDomainToVercel = async (domain: string) => {
|
||||||
return await fetch(
|
return await fetch(
|
||||||
`https://api.vercel.com/v10/projects/${PROJECT_ID_VERCEL}/domains${
|
`https://api.vercel.com/v10/projects/${env.PROJECT_ID_VERCEL}/domains${
|
||||||
TEAM_ID_VERCEL ? `?teamId=${TEAM_ID_VERCEL}` : ''
|
env.TEAM_ID_VERCEL ? `?teamId=${env.TEAM_ID_VERCEL}` : ''
|
||||||
}`,
|
}`,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${AUTH_BEARER_TOKEN}`,
|
Authorization: `Bearer ${env.AUTH_BEARER_TOKEN}`,
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
@@ -31,12 +31,12 @@ export const addDomainToVercel = async (domain: string) => {
|
|||||||
|
|
||||||
export const removeDomainFromVercelProject = async (domain: string) => {
|
export const removeDomainFromVercelProject = async (domain: string) => {
|
||||||
return await fetch(
|
return await fetch(
|
||||||
`https://api.vercel.com/v9/projects/${PROJECT_ID_VERCEL}/domains/${domain}${
|
`https://api.vercel.com/v9/projects/${env.PROJECT_ID_VERCEL}/domains/${domain}${
|
||||||
TEAM_ID_VERCEL ? `?teamId=${TEAM_ID_VERCEL}` : ''
|
env.TEAM_ID_VERCEL ? `?teamId=${env.TEAM_ID_VERCEL}` : ''
|
||||||
}`,
|
}`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${AUTH_BEARER_TOKEN}`
|
Authorization: `Bearer ${env.AUTH_BEARER_TOKEN}`
|
||||||
},
|
},
|
||||||
method: 'DELETE'
|
method: 'DELETE'
|
||||||
}
|
}
|
||||||
@@ -46,11 +46,11 @@ export const removeDomainFromVercelProject = async (domain: string) => {
|
|||||||
export const removeDomainFromVercelTeam = async (domain: string) => {
|
export const removeDomainFromVercelTeam = async (domain: string) => {
|
||||||
return await fetch(
|
return await fetch(
|
||||||
`https://api.vercel.com/v6/domains/${domain}${
|
`https://api.vercel.com/v6/domains/${domain}${
|
||||||
TEAM_ID_VERCEL ? `?teamId=${TEAM_ID_VERCEL}` : ''
|
env.TEAM_ID_VERCEL ? `?teamId=${env.TEAM_ID_VERCEL}` : ''
|
||||||
}`,
|
}`,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${AUTH_BEARER_TOKEN}`
|
Authorization: `Bearer ${env.AUTH_BEARER_TOKEN}`
|
||||||
},
|
},
|
||||||
method: 'DELETE'
|
method: 'DELETE'
|
||||||
}
|
}
|
||||||
@@ -61,13 +61,13 @@ export const getDomainResponse = async (
|
|||||||
domain: string
|
domain: string
|
||||||
): Promise<DomainResponse & { error: { code: string; message: string } }> => {
|
): Promise<DomainResponse & { error: { code: string; message: string } }> => {
|
||||||
return await fetch(
|
return await fetch(
|
||||||
`https://api.vercel.com/v9/projects/${PROJECT_ID_VERCEL}/domains/${domain}${
|
`https://api.vercel.com/v9/projects/${env.PROJECT_ID_VERCEL}/domains/${domain}${
|
||||||
TEAM_ID_VERCEL ? `?teamId=${TEAM_ID_VERCEL}` : ''
|
env.TEAM_ID_VERCEL ? `?teamId=${env.TEAM_ID_VERCEL}` : ''
|
||||||
}`,
|
}`,
|
||||||
{
|
{
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${AUTH_BEARER_TOKEN}`,
|
Authorization: `Bearer ${env.AUTH_BEARER_TOKEN}`,
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -79,12 +79,12 @@ export const getDomainResponse = async (
|
|||||||
export const getConfigResponse = async (domain: string): Promise<DomainConfigResponse> => {
|
export const getConfigResponse = async (domain: string): Promise<DomainConfigResponse> => {
|
||||||
return await fetch(
|
return await fetch(
|
||||||
`https://api.vercel.com/v6/domains/${domain}/config${
|
`https://api.vercel.com/v6/domains/${domain}/config${
|
||||||
TEAM_ID_VERCEL ? `?teamId=${TEAM_ID_VERCEL}` : ''
|
env.TEAM_ID_VERCEL ? `?teamId=${env.TEAM_ID_VERCEL}` : ''
|
||||||
}`,
|
}`,
|
||||||
{
|
{
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${AUTH_BEARER_TOKEN}`,
|
Authorization: `Bearer ${env.AUTH_BEARER_TOKEN}`,
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -93,13 +93,13 @@ export const getConfigResponse = async (domain: string): Promise<DomainConfigRes
|
|||||||
|
|
||||||
export const verifyDomain = async (domain: string): Promise<DomainVerificationResponse> => {
|
export const verifyDomain = async (domain: string): Promise<DomainVerificationResponse> => {
|
||||||
return await fetch(
|
return await fetch(
|
||||||
`https://api.vercel.com/v9/projects/${PROJECT_ID_VERCEL}/domains/${domain}/verify${
|
`https://api.vercel.com/v9/projects/${env.PROJECT_ID_VERCEL}/domains/${domain}/verify${
|
||||||
TEAM_ID_VERCEL ? `?teamId=${TEAM_ID_VERCEL}` : ''
|
env.TEAM_ID_VERCEL ? `?teamId=${env.TEAM_ID_VERCEL}` : ''
|
||||||
}`,
|
}`,
|
||||||
{
|
{
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${AUTH_BEARER_TOKEN}`,
|
Authorization: `Bearer ${env.AUTH_BEARER_TOKEN}`,
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { PRIVATE_SUPABASE_SERVICE_ROLE } from '$env/static/private';
|
import { env } from '$env/dynamic/private';
|
||||||
import { createClient, SupabaseClient } from '@supabase/supabase-js';
|
import { createClient, SupabaseClient } from '@supabase/supabase-js';
|
||||||
import { config } from '$lib/config';
|
import { config } from '$lib/config';
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ export let supabase: SupabaseClient;
|
|||||||
export const getServerSupabase = () => {
|
export const getServerSupabase = () => {
|
||||||
if (supabase) return supabase;
|
if (supabase) return supabase;
|
||||||
|
|
||||||
supabase = createClient(config.supabaseConfig.url, PRIVATE_SUPABASE_SERVICE_ROLE || '', {
|
supabase = createClient(config.supabaseConfig.url, env.PRIVATE_SUPABASE_SERVICE_ROLE || '', {
|
||||||
auth: {
|
auth: {
|
||||||
persistSession: false,
|
persistSession: false,
|
||||||
autoRefreshToken: false,
|
autoRefreshToken: false,
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { LEMON_SQUEEZY_API_KEY } from '$env/static/private';
|
import { env } from '$env/dynamic/private';
|
||||||
import { lemonSqueezySetup } from '@lemonsqueezy/lemonsqueezy.js';
|
import { lemonSqueezySetup } from '@lemonsqueezy/lemonsqueezy.js';
|
||||||
|
|
||||||
export function configureLemonSqueezy() {
|
export function configureLemonSqueezy() {
|
||||||
return lemonSqueezySetup({
|
return lemonSqueezySetup({
|
||||||
apiKey: LEMON_SQUEEZY_API_KEY,
|
apiKey: env.LEMON_SQUEEZY_API_KEY,
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
throw new Error(`Lemon Squeezy API error: ${error.message}`);
|
throw new Error(`Lemon Squeezy API error: ${error.message}`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { getCurrentOrg } from '$lib/utils/services/org';
|
|||||||
import { getSupabase, supabase } from '$lib/utils/functions/supabase';
|
import { getSupabase, supabase } from '$lib/utils/functions/supabase';
|
||||||
import { loadTranslations } from '$lib/utils/functions/translations';
|
import { loadTranslations } from '$lib/utils/functions/translations';
|
||||||
import type { CurrentOrg } from '$lib/utils/types/org';
|
import type { CurrentOrg } from '$lib/utils/types/org';
|
||||||
import { PRIVATE_APP_SUBDOMAINS, IS_SELFHOSTED, PRIVATE_APP_HOST } from '$env/static/private';
|
import { env } from '$env/dynamic/private';
|
||||||
|
|
||||||
if (!supabase) {
|
if (!supabase) {
|
||||||
getSupabase();
|
getSupabase();
|
||||||
@@ -30,7 +30,7 @@ export const load = async ({ url, cookies }): Promise<LoadOutput> => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Selfhosted usecase would be here
|
// Selfhosted usecase would be here
|
||||||
if (IS_SELFHOSTED === 'true') {
|
if (env.IS_SELFHOSTED === 'true') {
|
||||||
const subdomain = getSubdomain(url);
|
const subdomain = getSubdomain(url);
|
||||||
|
|
||||||
// Student dashboard
|
// Student dashboard
|
||||||
@@ -97,7 +97,7 @@ export const load = async ({ url, cookies }): Promise<LoadOutput> => {
|
|||||||
}
|
}
|
||||||
} else if (subdomain === 'play' || debugPlay === 'true') {
|
} else if (subdomain === 'play' || debugPlay === 'true') {
|
||||||
response.skipAuth = true;
|
response.skipAuth = true;
|
||||||
} else if (!PRIVATE_APP_SUBDOMAINS.split(',').includes(subdomain) && !isDev) {
|
} else if (!env.PRIVATE_APP_SUBDOMAINS.split(',').includes(subdomain) && !isDev) {
|
||||||
// This case is for anything in our blockedSubdomains
|
// This case is for anything in our blockedSubdomains
|
||||||
throw redirect(307, 'https://app.classroomio.com');
|
throw redirect(307, 'https://app.classroomio.com');
|
||||||
}
|
}
|
||||||
@@ -165,7 +165,7 @@ function getSubdomain(url: URL) {
|
|||||||
const host = url.host.replace('www.', '');
|
const host = url.host.replace('www.', '');
|
||||||
const parts = host.split('.');
|
const parts = host.split('.');
|
||||||
|
|
||||||
if (host.endsWith(PRIVATE_APP_HOST)) {
|
if (host.endsWith(env.PRIVATE_APP_HOST)) {
|
||||||
return parts.length >= 3 ? parts[0] : null;
|
return parts.length >= 3 ? parts[0] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { Configuration, OpenAIApi } from 'openai-edge';
|
import { Configuration, OpenAIApi } from 'openai-edge';
|
||||||
import { OpenAIStream, StreamingTextResponse } from 'ai';
|
import { OpenAIStream, StreamingTextResponse } from 'ai';
|
||||||
import { OPENAI_API_KEY } from '$env/static/private';
|
import { env } from '$env/dynamic/private';
|
||||||
|
|
||||||
// Create an OpenAI API client (that's edge friendly!)
|
// Create an OpenAI API client (that's edge friendly!)
|
||||||
const openAIConfig = new Configuration({
|
const openAIConfig = new Configuration({
|
||||||
apiKey: OPENAI_API_KEY
|
apiKey: env.OPENAI_API_KEY
|
||||||
});
|
});
|
||||||
const openai = new OpenAIApi(openAIConfig);
|
const openai = new OpenAIApi(openAIConfig);
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { OPENAI_API_KEY } from '$env/static/private';
|
import { env } from '$env/dynamic/private';
|
||||||
import { OpenAIStream, StreamingTextResponse } from 'ai';
|
import { OpenAIStream, StreamingTextResponse } from 'ai';
|
||||||
import { Configuration, OpenAIApi } from 'openai-edge';
|
import { Configuration, OpenAIApi } from 'openai-edge';
|
||||||
|
|
||||||
// Create an OpenAI API client (that's edge friendly!)
|
// Create an OpenAI API client (that's edge friendly!)
|
||||||
const openAIConfig = new Configuration({
|
const openAIConfig = new Configuration({
|
||||||
apiKey: OPENAI_API_KEY
|
apiKey: env.OPENAI_API_KEY
|
||||||
});
|
});
|
||||||
const openai = new OpenAIApi(openAIConfig);
|
const openai = new OpenAIApi(openAIConfig);
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { Configuration, OpenAIApi } from 'openai-edge';
|
import { Configuration, OpenAIApi } from 'openai-edge';
|
||||||
import { OpenAIStream, StreamingTextResponse } from 'ai';
|
import { OpenAIStream, StreamingTextResponse } from 'ai';
|
||||||
import { OPENAI_API_KEY } from '$env/static/private';
|
import { env } from '$env/dynamic/private';
|
||||||
|
|
||||||
// Create an OpenAI API client (that's edge friendly!)
|
// Create an OpenAI API client (that's edge friendly!)
|
||||||
const openAIConfig = new Configuration({
|
const openAIConfig = new Configuration({
|
||||||
apiKey: OPENAI_API_KEY
|
apiKey: env.OPENAI_API_KEY
|
||||||
});
|
});
|
||||||
const openai = new OpenAIApi(openAIConfig);
|
const openai = new OpenAIApi(openAIConfig);
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { OPENAI_API_KEY } from '$env/static/private';
|
import { env } from '$env/dynamic/private';
|
||||||
import { OpenAIStream, StreamingTextResponse } from 'ai';
|
import { OpenAIStream, StreamingTextResponse } from 'ai';
|
||||||
import { Configuration, OpenAIApi } from 'openai-edge';
|
import { Configuration, OpenAIApi } from 'openai-edge';
|
||||||
|
|
||||||
// Create an OpenAI API client (that's edge friendly!)
|
// Create an OpenAI API client (that's edge friendly!)
|
||||||
const openAIConfig = new Configuration({
|
const openAIConfig = new Configuration({
|
||||||
apiKey: OPENAI_API_KEY
|
apiKey: env.OPENAI_API_KEY
|
||||||
});
|
});
|
||||||
const openai = new OpenAIApi(openAIConfig);
|
const openai = new OpenAIApi(openAIConfig);
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { json } from '@sveltejs/kit';
|
import { json } from '@sveltejs/kit';
|
||||||
import { createCheckout } from '@lemonsqueezy/lemonsqueezy.js';
|
import { createCheckout } from '@lemonsqueezy/lemonsqueezy.js';
|
||||||
import { LEMON_SQUEEZY_STORE_ID } from '$env/static/private';
|
import { env } from '$env/dynamic/private';
|
||||||
import { configureLemonSqueezy } from '$lib/utils/services/lemonsqueezy';
|
import { configureLemonSqueezy } from '$lib/utils/services/lemonsqueezy';
|
||||||
|
|
||||||
export async function POST({ request }) {
|
export async function POST({ request }) {
|
||||||
@@ -23,7 +23,7 @@ export async function POST({ request }) {
|
|||||||
|
|
||||||
console.log({ checkoutData });
|
console.log({ checkoutData });
|
||||||
|
|
||||||
const { data } = await createCheckout(LEMON_SQUEEZY_STORE_ID, productId, {
|
const { data } = await createCheckout(env.LEMON_SQUEEZY_STORE_ID, productId, {
|
||||||
checkoutData
|
checkoutData
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { json } from '@sveltejs/kit';
|
import { json } from '@sveltejs/kit';
|
||||||
import crypto from 'crypto';
|
import crypto from 'crypto';
|
||||||
import { LEMON_SQUEEZY_WEBHOOK_SECRET } from '$env/static/private';
|
import { env } from '$env/dynamic/private';
|
||||||
import { createOrgPlan, cancelOrgPlan } from '$lib/utils/services/org';
|
import { createOrgPlan, cancelOrgPlan } from '$lib/utils/services/org';
|
||||||
import { PLAN } from 'shared/src/plans/constants';
|
import { PLAN } from 'shared/src/plans/constants';
|
||||||
import { getServerSupabase } from '$lib/utils/functions/supabase.server';
|
import { getServerSupabase } from '$lib/utils/functions/supabase.server';
|
||||||
@@ -15,7 +15,7 @@ export async function POST({ request }) {
|
|||||||
const body = await request.json();
|
const body = await request.json();
|
||||||
|
|
||||||
// Check signature
|
// Check signature
|
||||||
const secret = LEMON_SQUEEZY_WEBHOOK_SECRET;
|
const secret = env.LEMON_SQUEEZY_WEBHOOK_SECRET;
|
||||||
const hmac = crypto.createHmac('sha256', secret);
|
const hmac = crypto.createHmac('sha256', secret);
|
||||||
const digest = Buffer.from(hmac.update(await clonedReq.text()).digest('hex'), 'utf8');
|
const digest = Buffer.from(hmac.update(await clonedReq.text()).digest('hex'), 'utf8');
|
||||||
const signature = Buffer.from(request.headers.get('X-Signature') || '', 'utf8');
|
const signature = Buffer.from(request.headers.get('X-Signature') || '', 'utf8');
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { json } from '@sveltejs/kit';
|
import { json } from '@sveltejs/kit';
|
||||||
import { UNSPLASH_API_KEY } from '$env/static/private';
|
import { env } from '$env/dynamic/private';
|
||||||
|
|
||||||
const UNSPLASH_API_URL = `https://api.unsplash.com/search/photos?page=2&per_page=15&auto=format&fit=crop&w=2970&q=80&client_id=${UNSPLASH_API_KEY}`;
|
const UNSPLASH_API_URL = `https://api.unsplash.com/search/photos?page=2&per_page=15&auto=format&fit=crop&w=2970&q=80&client_id=${env.UNSPLASH_API_KEY}`;
|
||||||
|
|
||||||
// API to fetch photos from Unsplash
|
// API to fetch photos from Unsplash
|
||||||
export async function POST({ request }) {
|
export async function POST({ request }) {
|
||||||
|
|||||||
Reference in New Issue
Block a user