diff --git a/backend/.env b/backend/.env index e69de29..1740cd9 100644 --- a/backend/.env +++ b/backend/.env @@ -0,0 +1 @@ +MONGODB_URI='mongodb://localhost:27017' \ No newline at end of file diff --git a/backend/app.js b/backend/app.js index 0e91df3..4480035 100644 --- a/backend/app.js +++ b/backend/app.js @@ -3,12 +3,17 @@ const express = require('express'); const { MongoClient, ObjectId } = require('mongodb'); const cors = require('cors'); const app = express(); +require('dotenv').config(); const port = process.env.PORT || 3000; const mongodb_uri = process.env.MONGODB_URI || 'mongodb://localhost:27017'; const mongodb_name = process.env.MONGODB_NAME || 'docucenter'; +if(process.env.MONGODB_URI){ + console.log("Using ENV: " + process.env.MONGODB_URI); +} + // Parse JSON bodies app.use(express.json({ limit: '50mb' })); // For JSON data app.use(express.urlencoded({ limit: '50mb', extended: true })); // For URL-encoded data @@ -112,14 +117,14 @@ app.get('/documents/:id', async (req, res) => { // Update a document app.put('/documents/:id', async (req, res) => { const { id } = req.params; - const { title, body } = req.body; + const { title, body, tags, edited_by } = req.body; if (!title || !body) { return res.status(400).json({ error: 'Title and body are required' }); } try { const result = await db.collection('documents').updateOne( { _id: new ObjectId(id) }, - { $set: { title, body, updated_at: new Date() } } + { $set: { title, body, tags, edited_by, updated_at: new Date() } } ); if (result.matchedCount === 0) { return res.status(404).json({ error: 'Document not found' }); @@ -211,4 +216,5 @@ app.use((req, res) => { // Start the server app.listen(port, () => { console.log(`Server running on http://localhost:${port}`); + console.log("Searching for database: URI: "+mongodb_uri); }); \ No newline at end of file diff --git a/backend/package-lock.json b/backend/package-lock.json index d496232..047472e 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -332,7 +332,6 @@ "version": "16.4.7", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz", "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==", - "license": "BSD-2-Clause", "engines": { "node": ">=12" }, diff --git a/frontend/env.locals b/frontend/env.locals index e69de29..3f8e4f4 100644 --- a/frontend/env.locals +++ b/frontend/env.locals @@ -0,0 +1 @@ +BACKEND_URI='http://localhost:3000' \ No newline at end of file diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 4b290f2..53aae52 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -25,6 +25,7 @@ "@tiptap/extension-underline": "^2.10.3", "@tiptap/pm": "^2.10.3", "@tiptap/starter-kit": "^2.10.3", + "dotenv": "^16.4.7", "tippy.js": "^6.3.7" }, "devDependencies": { @@ -2046,6 +2047,17 @@ "url": "https://github.com/fb55/domhandler?sponsor=1" } }, + "node_modules/dotenv": { + "version": "16.4.7", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz", + "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/eastasianwidth": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index d706fad..5648eb6 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -51,6 +51,7 @@ "@tiptap/extension-underline": "^2.10.3", "@tiptap/pm": "^2.10.3", "@tiptap/starter-kit": "^2.10.3", + "dotenv": "^16.4.7", "tippy.js": "^6.3.7" } } diff --git a/frontend/src/lib/components/Tiptap.svelte b/frontend/src/lib/components/Tiptap.svelte index 53a5796..a0a7b10 100644 --- a/frontend/src/lib/components/Tiptap.svelte +++ b/frontend/src/lib/components/Tiptap.svelte @@ -17,6 +17,7 @@ export function setHTML(html){ editor.commands.insertContent(html); + //initialHTML = html; } export function getHTML(){ diff --git a/frontend/src/routes/+layout.svelte b/frontend/src/routes/+layout.svelte index a980d5e..81801c2 100644 --- a/frontend/src/routes/+layout.svelte +++ b/frontend/src/routes/+layout.svelte @@ -25,7 +25,7 @@ {/if} {:else} -

Not Signed In

+ {/if} diff --git a/frontend/src/routes/add/+page.svelte b/frontend/src/routes/add/+page.svelte index b7570c8..5295f54 100644 --- a/frontend/src/routes/add/+page.svelte +++ b/frontend/src/routes/add/+page.svelte @@ -5,15 +5,15 @@
-
+
-
+
\ No newline at end of file diff --git a/frontend/src/routes/document/+page.svelte b/frontend/src/routes/document/+page.svelte index 64b10ef..834e134 100644 --- a/frontend/src/routes/document/+page.svelte +++ b/frontend/src/routes/document/+page.svelte @@ -1,6 +1,7 @@
-
+
-
+
\ No newline at end of file diff --git a/frontend/src/routes/home/+page.svelte b/frontend/src/routes/home/+page.svelte index ae3476d..1b2cb63 100644 --- a/frontend/src/routes/home/+page.svelte +++ b/frontend/src/routes/home/+page.svelte @@ -1,6 +1,7 @@