Made some changes!

This commit is contained in:
Donavon McDowell 2024-12-18 11:53:42 -07:00
parent 80ac373d39
commit 80b951e216
2 changed files with 12 additions and 7 deletions

View File

@ -11,8 +11,8 @@ const app = express();
const corsUrl = process.env.FRONTEND_URL; const corsUrl = process.env.FRONTEND_URL;
app.use(express.urlencoded({ extended: true })); // Parses form data app.use(express.urlencoded({ extended: true, limit: '50mb' })); // Increase URL-encoded payload limit
app.use(express.json()); // Parses JSON data app.use(express.json({ limit: '50mb' })); // Increase JSON payload limit
// Configure CORS to allow specific origins // Configure CORS to allow specific origins
const allowedOrigins = [ const allowedOrigins = [

View File

@ -26,7 +26,7 @@
// Function to simulate search API call // Function to simulate search API call
async function searchDocuments(query) { async function searchDocuments(query) {
try { try {
const res = await fetch(`http://localhost:3010/api/document/search?query=${query}`); const res = await fetch(`https://docucenter.mpe.ca/api/document/search?query=${query}`);
const data = await res.json(); const data = await res.json();
if (data.length > 0) { if (data.length > 0) {
@ -43,7 +43,7 @@
// Function to fetch all documents from the API // Function to fetch all documents from the API
async function getAllDocuments() { async function getAllDocuments() {
try { try {
const res = await fetch(`http://localhost:3010/api/document`); const res = await fetch(`https://docucenter.mpe.ca/api/document`);
if (!res.ok) { if (!res.ok) {
throw new Error(`Failed to fetch documents: ${res.statusText}`); throw new Error(`Failed to fetch documents: ${res.statusText}`);
@ -77,7 +77,6 @@
<svelte:head> <svelte:head>
<title>DocuCenter</title> <title>DocuCenter</title>
</svelte:head> </svelte:head>
<div class="flex items-center justify-center h-full flex-col"> <div class="flex items-center justify-center h-full flex-col">
{#if $page.data.user.role == "admin"} {#if $page.data.user.role == "admin"}
<div class="flex flex-row justify-end w-full"> <div class="flex flex-row justify-end w-full">
@ -129,10 +128,16 @@
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 mt-4"> <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 mt-4">
{#each documents as document} {#each documents as document}
<a href="/document?id={document._id}" class="block"> <a href="/document?id={document._id}" class="block">
<div class="bg-white rounded-2xl p-4 font-roboto border mt-1 mb-1 hover:bg-slate-200 truncate h-48 shadow-lg"> <div class="relative bg-white rounded-2xl p-4 font-roboto border mt-1 mb-1 hover:bg-slate-200 truncate h-48 shadow-lg">
<h3 class="text-lg font-semibold">{@html document.title}</h3> <h3 class="text-lg font-semibold">{@html document.title}</h3>
<p class="text-sm text-gray-600">{@html truncateBody(document.body)}</p> <p class="text-sm text-gray-600">{@html truncateBody(document.body)}</p>
<div class="absolute bottom-1 right-1 flex flex-row overflow-x-none">
{#each document.tags as tag}
<div class="rounded-xl px-3 p-1 items-center bg-blue-500 text-white space-x-2 mr-1 border-dashed border-blue-100 border-2">
<p>{@html tag}</p>
</div>
{/each}
</div>
</div> </div>
</a> </a>
{/each} {/each}