replace static env vars with dynamic ones
This commit is contained in:
parent
48a090be5f
commit
6f74c3a789
|
@ -1,8 +1,8 @@
|
|||
import { MongoClient } from 'mongodb';
|
||||
import { DB_URL } from '$env/static/private';
|
||||
import { env } from '$env/dynamic/private';
|
||||
import type PasteSchema from "./paste-schema";
|
||||
|
||||
const client = new MongoClient(DB_URL);
|
||||
const client = new MongoClient(env.DB_URL);
|
||||
await client.connect();
|
||||
|
||||
const db = client.db("paste69");
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { SENTRY_DSN } from '$env/static/private';
|
||||
import { env } from '$env/dynamic/private';
|
||||
import * as Sentry from '@sentry/node';
|
||||
import type { HandleServerError } from '@sveltejs/kit';
|
||||
|
||||
Sentry.init({
|
||||
dsn: SENTRY_DSN,
|
||||
dsn: env.SENTRY_DSN,
|
||||
});
|
||||
|
||||
interface ServerError extends Error {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { error } from '@sveltejs/kit';
|
||||
import type { PageLoad } from './$types';
|
||||
import { pastes } from '$db/index';
|
||||
import { SITE_URL } from '$env/static/private';
|
||||
import { env } from '$env/dynamic/private';
|
||||
|
||||
export const load: PageLoad = async ({ params }) => {
|
||||
const [id, ext] = params.slug.split('.');
|
||||
|
@ -15,7 +15,7 @@ export const load: PageLoad = async ({ params }) => {
|
|||
// Build the response object
|
||||
const response = {
|
||||
id: paste.id,
|
||||
url: `${SITE_URL}/${id}.${paste.highlight}`,
|
||||
url: `${env.SITE_URL}/${id}.${paste.highlight}`,
|
||||
contents: paste.contents,
|
||||
encrypted: paste.encrypted,
|
||||
highlight: ext || paste.highlight,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { error } from '@sveltejs/kit';
|
||||
import type { PageLoad } from './$types';
|
||||
import { pastes } from '$db/index';
|
||||
import { SITE_URL } from '$env/static/private';
|
||||
import { env } from '$env/dynamic/private';
|
||||
|
||||
export const load: PageLoad = async ({ params }) => {
|
||||
const paste = await pastes.findOne({ id: params.slug });
|
||||
|
@ -10,7 +10,7 @@ export const load: PageLoad = async ({ params }) => {
|
|||
throw error(404, 'Paste not found');
|
||||
}
|
||||
|
||||
const pasteUrl = `${SITE_URL}/${paste.id}.${paste.highlight}`;
|
||||
const pasteUrl = `${env.SITE_URL}/${paste.id}.${paste.highlight}`;
|
||||
|
||||
return {
|
||||
pasteUrl,
|
||||
|
|
|
@ -3,7 +3,7 @@ import { encrypt as doEncrypt } from "$utils/crypto";
|
|||
import { error, json, type RequestHandler } from "@sveltejs/kit";
|
||||
import { generate } from 'random-words';
|
||||
import { pastes } from "$db/index";
|
||||
import { SITE_URL } from "$env/static/private";
|
||||
import { env } from "$env/dynamic/private";
|
||||
import { extensionMap } from "$utils/languages";
|
||||
|
||||
export const POST: RequestHandler = async ({ request }) => {
|
||||
|
@ -36,7 +36,7 @@ export const POST: RequestHandler = async ({ request }) => {
|
|||
|
||||
const data = {
|
||||
id,
|
||||
url: `${SITE_URL}/${id}.${highlight}`,
|
||||
url: `${env.SITE_URL}/${id}.${highlight}`,
|
||||
highlight,
|
||||
encrypted: !!encrypt,
|
||||
contents: pasteContents,
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { pastes } from "$db/index";
|
||||
import { SITE_URL } from "$env/static/private";
|
||||
import { env } from "$env/dynamic/private";
|
||||
import { error, type RequestHandler } from "@sveltejs/kit";
|
||||
|
||||
export const GET: RequestHandler = async ({ params }) => {
|
||||
|
@ -27,7 +27,7 @@ export const GET: RequestHandler = async ({ params }) => {
|
|||
// Truncate each line to 80 characters, and pad the rest with spaces.
|
||||
lines = lines.map(line => line.slice(0, 70).padEnd(70, ' '));
|
||||
|
||||
const title = `${SITE_URL}/${id}.${paste.highlight}`;
|
||||
const title = `${env.SITE_URL}/${id}.${paste.highlight}`;
|
||||
const url = `https://inkify.0x45.st/generate?code=${encodeURIComponent(lines.join('\n'))}&window_title=${encodeURIComponent(title)}&language=${encodeURIComponent(paste.highlight)}&pad_horiz=5&pad_vert=5`;
|
||||
|
||||
const res = await fetch(url);
|
||||
|
|
Loading…
Reference in New Issue