Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update +server.ts to bypass cloudflared for self-hosting #78

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/routes/api/share/+server.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { error } from '@sveltejs/kit';
import type { Config } from '@sveltejs/adapter-vercel';
import type { RequestHandler } from './$types';
import { ref, set, update } from 'firebase/database';
// bypassing firebase
// import { ref, set, update } from 'firebase/database';
import { generateSlug } from 'random-word-slugs';
import { db, loadChatFromDb } from '$misc/firebase';
// bypassing firebase
// import { db, loadChatFromDb } from '$misc/firebase';
import type { Chat } from '$misc/shared';
import { respondToClient, throwIfUnset, getErrorMessage } from '$misc/error';

Expand Down Expand Up @@ -60,7 +62,9 @@ export const POST: RequestHandler = async ({ request }) => {
};

// save to firebase
await set(ref(db, `sharedchats/${slug}`), documentToSave);
//await set(ref(db, `sharedchats/${slug}`), documentToSave);
// bypass
console.log('Saving document to Firebase:', documentToSave);

return respondToClient({ slug, updateToken });
} catch (err) {
Expand Down Expand Up @@ -95,7 +99,9 @@ export const DELETE: RequestHandler = async ({ request }) => {

if (deleted.length) {
// delete in firebase
await update(ref(db), updates);
// await update(ref(db), updates);
// bypass firebase
console.log('Deleting documents:', updates);
}

return respondToClient({ deleted });
Expand Down