⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
improved env config
Daniele7d76616cab0
diff --git a/.env.sample b/.env.sampleindex 8e0d4a53..ea08bfa9 100644--- a/.env.sample+++ b/.env.sample@@ -1,18 +1,19 @@NEXTAUTH_SECRET=very_sensitive_secretDATABASE_URL=postgresql://user:password@localhost:5432/linkwardenNEXTAUTH_URL=http://localhost:3000-PAGINATION_TAKE_COUNT=20-# Don't define this if you're defining the "AWS S3 Settings" below-STORAGE_FOLDER=data+# Additional Optional Settings-# AWS S3 Settings (Optional)+PAGINATION_TAKE_COUNT=+STORAGE_FOLDER=++# AWS S3 SettingsSPACES_KEY=SPACES_SECRET=SPACES_ENDPOINT=SPACES_REGION=-# SMTP Settings (Optional)+# SMTP SettingsNEXT_PUBLIC_EMAIL_PROVIDER=EMAIL_FROM=EMAIL_SERVER=diff --git a/lib/api/controllers/links/getLinks.ts b/lib/api/controllers/links/getLinks.tsindex 127ccd19..d5ed6dfb 100644--- a/lib/api/controllers/links/getLinks.ts+++ b/lib/api/controllers/links/getLinks.ts@@ -33,7 +33,7 @@ export default async function getLink(userId: number, body: string) {};const links = await prisma.link.findMany({- take: Number(process.env.PAGINATION_TAKE_COUNT),+ take: Number(process.env.PAGINATION_TAKE_COUNT) || 20,skip: query.cursor ? 1 : undefined,cursor: query.cursor? {diff --git a/lib/api/controllers/public/getCollection.ts b/lib/api/controllers/public/getCollection.tsindex 2564df7a..a9a27532 100644--- a/lib/api/controllers/public/getCollection.ts+++ b/lib/api/controllers/public/getCollection.ts@@ -16,7 +16,7 @@ export default async function getCollection(body: string) {if (collection) {const links = await prisma.link.findMany({- take: Number(process.env.PAGINATION_TAKE_COUNT),+ take: Number(process.env.PAGINATION_TAKE_COUNT) || 20,skip: query.cursor ? 1 : undefined,cursor: query.cursor? {diff --git a/lib/api/storage/createFile.ts b/lib/api/storage/createFile.tsindex 1190ec8b..8f55b451 100644--- a/lib/api/storage/createFile.ts+++ b/lib/api/storage/createFile.ts@@ -28,7 +28,7 @@ export default async function createFile({return false;}} else {- const storagePath = process.env.STORAGE_FOLDER;+ const storagePath = process.env.STORAGE_FOLDER || "data";const creationPath = path.join(process.cwd(), storagePath + "/" + filePath);fs.writeFile(creationPath, data, isBase64 ? "base64" : {}, function (err) {diff --git a/lib/api/storage/createFolder.ts b/lib/api/storage/createFolder.tsindex 7c2f0b0b..42b5dab0 100644--- a/lib/api/storage/createFolder.ts+++ b/lib/api/storage/createFolder.ts@@ -6,7 +6,7 @@ export default function createFolder({ filePath }: { filePath: string }) {if (s3Client) {// Do nothing, S3 creates directories recursively} else {- const storagePath = process.env.STORAGE_FOLDER;+ const storagePath = process.env.STORAGE_FOLDER || "data";const creationPath = path.join(process.cwd(), storagePath + "/" + filePath);fs.mkdirSync(creationPath, { recursive: true });diff --git a/lib/api/storage/readFile.ts b/lib/api/storage/readFile.tsindex 74fdc3e8..237fac55 100644--- a/lib/api/storage/readFile.ts+++ b/lib/api/storage/readFile.ts@@ -41,7 +41,7 @@ export default async function readFile({ filePath }: { filePath: string }) {};}} else {- const storagePath = process.env.STORAGE_FOLDER;+ const storagePath = process.env.STORAGE_FOLDER || "data";const creationPath = path.join(process.cwd(), storagePath + "/" + filePath);const file = fs.existsSync(creationPath)diff --git a/lib/api/storage/removeFile.ts b/lib/api/storage/removeFile.tsindex 83e4bddd..491e24c7 100644--- a/lib/api/storage/removeFile.ts+++ b/lib/api/storage/removeFile.ts@@ -16,7 +16,7 @@ export default async function removeFile({ filePath }: { filePath: string }) {console.log("Error", err);}} else {- const storagePath = process.env.STORAGE_FOLDER;+ const storagePath = process.env.STORAGE_FOLDER || "data";const creationPath = path.join(process.cwd(), storagePath + "/" + filePath);fs.unlink(creationPath, (err) => {diff --git a/lib/api/storage/removeFolder.ts b/lib/api/storage/removeFolder.tsindex 54f66325..7383b884 100644--- a/lib/api/storage/removeFolder.ts+++ b/lib/api/storage/removeFolder.ts@@ -45,7 +45,7 @@ export default async function removeFolder({ filePath }: { filePath: string }) {console.log("Error", err);}} else {- const storagePath = process.env.STORAGE_FOLDER;+ const storagePath = process.env.STORAGE_FOLDER || "data";const creationPath = path.join(process.cwd(), storagePath + "/" + filePath);try {diff --git a/types/enviornment.d.ts b/types/enviornment.d.tsindex a093c11c..047994ce 100644--- a/types/enviornment.d.ts+++ b/types/enviornment.d.ts@@ -4,7 +4,7 @@ declare global {NEXTAUTH_SECRET: string;DATABASE_URL: string;NEXTAUTH_URL: string;- PAGINATION_TAKE_COUNT: string;+ PAGINATION_TAKE_COUNT?: string;STORAGE_FOLDER?: string;SPACES_KEY?: string;