mirror of
https://github.com/kyantech/Palmr.git
synced 2025-10-23 06:11:58 +00:00
Compare commits
107 Commits
v3.1.1-bet
...
feat/remov
Author | SHA1 | Date | |
---|---|---|---|
|
64d28dc778 | ||
|
2446f2fb55 | ||
|
15d3f3bdb6 | ||
|
3117904009 | ||
|
b078e94189 | ||
|
bd4212b44c | ||
|
b699bffb5b | ||
|
a755c5324f | ||
|
9072e7e866 | ||
|
d3d1057ba8 | ||
|
24eda85fdc | ||
|
d49d15ac9b | ||
|
e7b2062764 | ||
|
f21f972825 | ||
|
4f4e4a079e | ||
|
6fbb9aa9da | ||
|
0e610d002c | ||
|
abd8366e94 | ||
|
5d8c243125 | ||
|
d23af700da | ||
|
494161eb47 | ||
|
6a9728be4b | ||
|
5e889956c7 | ||
|
5afc6ea271 | ||
|
cc368377c2 | ||
|
51764be7d4 | ||
|
fe598b4a30 | ||
|
80286e57d9 | ||
|
9f36a48d15 | ||
|
94286e8452 | ||
|
0ce2d6a998 | ||
|
9e15fd7d2e | ||
|
736348ebe8 | ||
|
ddb981cba2 | ||
|
724452fb40 | ||
|
a2ac6a6268 | ||
|
aecda25b25 | ||
|
0f22b0bb23 | ||
|
edf6d70d69 | ||
|
a2ecd2e221 | ||
|
2f022cae5d | ||
|
bb3669f5b2 | ||
|
87fd8caf2c | ||
|
e8087a7c01 | ||
|
4075a7df29 | ||
|
c081b6f764 | ||
|
ecaa6d0321 | ||
|
e7ae7833ad | ||
|
22f34f6f81 | ||
|
29efe0a10e | ||
|
965c64b468 | ||
|
ce57cda672 | ||
|
a59857079e | ||
|
9ae2a0c628 | ||
|
f2c514cd82 | ||
|
6755230c53 | ||
|
f2a0e60f20 | ||
|
6cb21e95c4 | ||
|
868add68a5 | ||
|
307148d951 | ||
|
9cb4235550 | ||
|
6014b3e961 | ||
|
32f0a891ba | ||
|
124ac46eeb | ||
|
d3e76c19bf | ||
|
dd1ce189ae | ||
|
82e43b06c6 | ||
|
aab4e6d9df | ||
|
1f097678ce | ||
|
96cb4a04ec | ||
|
b7c4b37e89 | ||
|
952cf27ecb | ||
|
765810e4e5 | ||
|
36d09a7679 | ||
|
c6d6648942 | ||
|
54ca7580b0 | ||
|
4e53d239bb | ||
|
6491894f0e | ||
|
93e05dd913 | ||
|
2efe69e50b | ||
|
761865a6a3 | ||
|
25fed8db61 | ||
|
de42e1ca47 | ||
|
138e20d36d | ||
|
433610286c | ||
|
236f94247a | ||
|
1a5c1de510 | ||
|
6fb55005d4 | ||
|
4779671323 | ||
|
e7876739e7 | ||
|
e699e30af3 | ||
|
7541a2b085 | ||
|
24aa605973 | ||
|
fd28445680 | ||
|
19b7448c3a | ||
|
53c39135af | ||
|
b9147038e6 | ||
|
9a0b7f5c55 | ||
|
2a5f9f03ae | ||
|
78f6e36fc9 | ||
|
8e7aadd183 | ||
|
794a2782ac | ||
|
383f26e777 | ||
|
2db88d3902 | ||
|
5e96633a1e | ||
|
6c80ad8b2a | ||
|
96bd39eb25 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -30,6 +30,7 @@ apps/server/dist/*
|
||||
|
||||
#DEFAULT
|
||||
.env
|
||||
.steering
|
||||
data/
|
||||
|
||||
node_modules/
|
11
Dockerfile
11
Dockerfile
@@ -82,7 +82,7 @@ RUN addgroup --system --gid ${PALMR_GID} nodejs
|
||||
RUN adduser --system --uid ${PALMR_UID} --ingroup nodejs palmr
|
||||
|
||||
# Create application directories
|
||||
RUN mkdir -p /app/palmr-app /app/web /home/palmr/.npm /home/palmr/.cache
|
||||
RUN mkdir -p /app/palmr-app /app/web /app/infra /home/palmr/.npm /home/palmr/.cache
|
||||
RUN chown -R palmr:nodejs /app /home/palmr
|
||||
|
||||
# === Copy Server Files to /app/palmr-app (separate from /app/server for bind mounts) ===
|
||||
@@ -117,10 +117,13 @@ WORKDIR /app
|
||||
# Create supervisor configuration
|
||||
RUN mkdir -p /etc/supervisor/conf.d
|
||||
|
||||
# Copy server start script
|
||||
# Copy server start script and configuration files
|
||||
COPY infra/server-start.sh /app/server-start.sh
|
||||
COPY infra/configs.json /app/infra/configs.json
|
||||
COPY infra/providers.json /app/infra/providers.json
|
||||
COPY infra/check-missing.js /app/infra/check-missing.js
|
||||
RUN chmod +x /app/server-start.sh
|
||||
RUN chown palmr:nodejs /app/server-start.sh
|
||||
RUN chown -R palmr:nodejs /app/server-start.sh /app/infra
|
||||
|
||||
# Copy supervisor configuration
|
||||
COPY infra/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
|
||||
@@ -133,10 +136,12 @@ set -e
|
||||
echo "Starting Palmr Application..."
|
||||
echo "Storage Mode: \${ENABLE_S3:-false}"
|
||||
echo "Secure Site: \${SECURE_SITE:-false}"
|
||||
echo "Encryption: \${DISABLE_FILESYSTEM_ENCRYPTION:-true}"
|
||||
echo "Database: SQLite"
|
||||
|
||||
# Set global environment variables
|
||||
export DATABASE_URL="file:/app/server/prisma/palmr.db"
|
||||
export NEXT_PUBLIC_DEFAULT_LANGUAGE=\${DEFAULT_LANGUAGE:-en-US}
|
||||
|
||||
# Ensure /app/server directory exists for bind mounts
|
||||
mkdir -p /app/server/uploads /app/server/temp-uploads /app/server/prisma
|
||||
|
212
LICENSE
212
LICENSE
@@ -1,40 +1,190 @@
|
||||
Kyantech-Permissive License (Based on BSD 2-Clause)
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
Copyright (c) 2025, Daniel Luiz Alves (danielalves96) - Kyantech Solutions
|
||||
All rights reserved.
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted for any purpose — private, commercial,
|
||||
educational, governmental — **fully free and unrestricted**, provided
|
||||
that the following conditions are met:
|
||||
1. Definitions.
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions, and the following disclaimer.
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions, and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
3. **If this software (or derivative works) is used in any public-facing
|
||||
interface** — such as websites, apps, dashboards, admin panels, or
|
||||
similar — a **simple credit** must appear in the footer or similar
|
||||
location. The credit text should read:
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
> “Powered by Kyantech Solutions · https://kyantech.com.br”
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
This credit must be reasonably visible but **must not interfere** with
|
||||
your UI, branding, or user experience. You may style it to match your
|
||||
own design and choose its size, placement, or color.
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
---
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
Copyright 2025 Daniel Luiz Alves (danielalves96) - Kyantech Solutions, Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
285
README.md
285
README.md
@@ -1,142 +1,143 @@
|
||||
# 🌴 Palmr. - Open-Source File Transfer
|
||||
|
||||
<p align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749825361/Group_47_1_bcx8gw.png" alt="Palmr Banner" style="width: 100%;"/>
|
||||
</p>
|
||||
|
||||
**Palmr.** is a **flexible** and **open-source** alternative to file transfer services like **WeTransfer**, **SendGB**, **Send Anywhere**, and **Files.fm**.
|
||||
|
||||
|
||||
🔗 **For detailed documentation visit:** [Palmr. - Documentation](https://palmr.kyantech.com.br)
|
||||
|
||||
## 📌 Why Choose Palmr.?
|
||||
|
||||
- **Self-hosted** – Deploy on your own server or VPS.
|
||||
- **Full control** – No third-party dependencies, ensuring privacy and security.
|
||||
- **No artificial limits** – Share files without hidden restrictions or fees.
|
||||
- **Simple deployment** – SQLite database and filesystem storage for easy setup.
|
||||
- **Scalable storage** – Optional S3-compatible object storage for enterprise needs.
|
||||
|
||||
## 🚀 Technologies Used
|
||||
|
||||
### **Palmr.** is built with a focus on **performance**, **scalability**, and **security**.
|
||||
|
||||
<div align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1745548231/Palmr./Captura_de_Tela_2025-04-24_a%CC%80s_23.24.26_kr4hsl.png" style="width: 100%; border-radius: 15px;" />
|
||||
</div>
|
||||
|
||||
|
||||
### **Backend & API**
|
||||
- **Fastify (Node.js)** – High-performance API framework with built-in schema validation.
|
||||
- **SQLite** – Lightweight, reliable database with zero-configuration setup.
|
||||
- **Filesystem Storage** – Direct file storage with optional S3-compatible object storage.
|
||||
|
||||
### **Frontend**
|
||||
- **NextJS 15 + TypeScript + Shadcn/ui** – Modern and fast web interface.
|
||||
|
||||
|
||||
## 🛠️ How It Works
|
||||
|
||||
1. **Web Interface** → Built with Next, React and TypeScript for a seamless user experience.
|
||||
2. **Backend API** → Fastify handles requests and manages file operations.
|
||||
3. **Database** → SQLite stores metadata and transactional data with zero configuration.
|
||||
4. **Storage** → Filesystem storage ensures reliable file storage with optional S3-compatible object storage for scalability.
|
||||
|
||||
## 📸 Screenshots
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824929/Login_veq6e7.png" alt="Login Page" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Login Page</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824929/Home_lzvfzu.png" alt="Home Page" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Home Page</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Dashboard_uycmxb.png" alt="Dashboard" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Dashboard</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824929/Profile_wvnlzw.png" alt="Profile Page" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Profile Page</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Files_List_ztwr1e.png" alt="Files List View" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Files List View</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Files_Cards_pwsh5e.png" alt="Files Card View" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Files Card View</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824927/Shares_cgplgw.png" alt="Shares Management" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Shares Management</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Reive_Files_uhkeyc.png" alt="Receive Files" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Receive Files</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824927/Default_Reverse_xedmhw.png" alt="Reverse Share" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Reverse Share</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Settings_oampxr.png" alt="Settings Panel" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Settings Panel</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/User_Management_xjbfhn.png" alt="User Management" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>User Management</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Forgot_Password_jcz9ad.png" alt="Forgot Password" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Forgot Password</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/WeTransfer_Reverse_u0g7eb.png" alt="Forgot Password" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Reverse Share (WeTransfer Style)</strong>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
## 👨💻 Core Maintainers
|
||||
|
||||
| [**Daniel Luiz Alves**](https://github.com/danielalves96) |
|
||||
|------------------|
|
||||
| <img src="https://github.com/danielalves96.png" width="150px" alt="Daniel Luiz Alves" /> |
|
||||
|
||||
</br>
|
||||
|
||||
## 🤝 Supporters
|
||||
|
||||
[<img src="https://i.ibb.co/nMN40STL/Repoflow.png" width="200px" alt="Daniel Luiz Alves" />](https://www.repoflow.io/)
|
||||
|
||||
## ⭐ Star History
|
||||
|
||||
<a href="https://www.star-history.com/#kyantech/Palmr&Date">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=kyantech/Palmr&type=Date&theme=dark" />
|
||||
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=kyantech/Palmr&type=Date" />
|
||||
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=kyantech/Palmr&type=Date" />
|
||||
</picture>
|
||||
</a>
|
||||
|
||||
## 🛠️ Contributing
|
||||
|
||||
For contribution guidelines, please refer to the [CONTRIBUTING.md](CONTRIBUTING.md) file.
|
||||
|
||||
# 🌴 Palmr. - Open-Source File Transfer
|
||||
|
||||
<p align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749825361/Group_47_1_bcx8gw.png" alt="Palmr Banner" style="width: 100%;"/>
|
||||
</p>
|
||||
|
||||
**Palmr.** is a **flexible** and **open-source** alternative to file transfer services like **WeTransfer**, **SendGB**, **Send Anywhere**, and **Files.fm**.
|
||||
|
||||
|
||||
🔗 **For detailed documentation visit:** [Palmr. - Documentation](https://palmr.kyantech.com.br)
|
||||
|
||||
## 📌 Why Choose Palmr.?
|
||||
|
||||
- **Self-hosted** – Deploy on your own server or VPS.
|
||||
- **Full control** – No third-party dependencies, ensuring privacy and security.
|
||||
- **No artificial limits** – Share files without hidden restrictions or fees.
|
||||
- **Folder organization** – Create folders to organize and share files.
|
||||
- **Simple deployment** – SQLite database and filesystem storage for easy setup.
|
||||
- **Scalable storage** – Optional S3-compatible object storage for enterprise needs.
|
||||
|
||||
## 🚀 Technologies Used
|
||||
|
||||
### **Palmr.** is built with a focus on **performance**, **scalability**, and **security**.
|
||||
|
||||
<div align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1745548231/Palmr./Captura_de_Tela_2025-04-24_a%CC%80s_23.24.26_kr4hsl.png" style="width: 100%; border-radius: 15px;" />
|
||||
</div>
|
||||
|
||||
|
||||
### **Backend & API**
|
||||
- **Fastify (Node.js)** – High-performance API framework with built-in schema validation.
|
||||
- **SQLite** – Lightweight, reliable database with zero-configuration setup.
|
||||
- **Filesystem Storage** – Direct file storage with optional S3-compatible object storage.
|
||||
|
||||
### **Frontend**
|
||||
- **NextJS 15 + TypeScript + Shadcn/ui** – Modern and fast web interface.
|
||||
|
||||
|
||||
## 🛠️ How It Works
|
||||
|
||||
1. **Web Interface** → Built with Next, React and TypeScript for a seamless user experience.
|
||||
2. **Backend API** → Fastify handles requests and manages file operations.
|
||||
3. **Database** → SQLite stores metadata and transactional data with zero configuration.
|
||||
4. **Storage** → Filesystem storage ensures reliable file storage with optional S3-compatible object storage for scalability.
|
||||
|
||||
## 📸 Screenshots
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824929/Login_veq6e7.png" alt="Login Page" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Login Page</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824929/Home_lzvfzu.png" alt="Home Page" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Home Page</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Dashboard_uycmxb.png" alt="Dashboard" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Dashboard</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824929/Profile_wvnlzw.png" alt="Profile Page" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Profile Page</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Files_List_ztwr1e.png" alt="Files List View" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Files List View</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Files_Cards_pwsh5e.png" alt="Files Card View" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Files Card View</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824927/Shares_cgplgw.png" alt="Shares Management" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Shares Management</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Reive_Files_uhkeyc.png" alt="Receive Files" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Receive Files</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824927/Default_Reverse_xedmhw.png" alt="Reverse Share" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Reverse Share</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Settings_oampxr.png" alt="Settings Panel" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Settings Panel</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/User_Management_xjbfhn.png" alt="User Management" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>User Management</strong>
|
||||
</td>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/Forgot_Password_jcz9ad.png" alt="Forgot Password" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Forgot Password</strong>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<img src="https://res.cloudinary.com/technical-intelligence/image/upload/v1749824928/WeTransfer_Reverse_u0g7eb.png" alt="Forgot Password" style="width: 100%; border-radius: 8px;" />
|
||||
<br /><strong>Reverse Share (WeTransfer Style)</strong>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
## 👨💻 Core Maintainers
|
||||
|
||||
| [**Daniel Luiz Alves**](https://github.com/danielalves96) |
|
||||
|------------------|
|
||||
| <img src="https://github.com/danielalves96.png" width="150px" alt="Daniel Luiz Alves" /> |
|
||||
|
||||
</br>
|
||||
|
||||
## 🤝 Supporters
|
||||
|
||||
[<img src="https://i.ibb.co/nMN40STL/Repoflow.png" width="200px" alt="Daniel Luiz Alves" />](https://www.repoflow.io/)
|
||||
|
||||
## ⭐ Star History
|
||||
|
||||
<a href="https://www.star-history.com/#kyantech/Palmr&Date">
|
||||
<picture>
|
||||
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=kyantech/Palmr&type=Date&theme=dark" />
|
||||
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=kyantech/Palmr&type=Date" />
|
||||
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=kyantech/Palmr&type=Date" />
|
||||
</picture>
|
||||
</a>
|
||||
|
||||
## 🛠️ Contributing
|
||||
|
||||
For contribution guidelines, please refer to the [CONTRIBUTING.md](CONTRIBUTING.md) file.
|
||||
|
||||
|
@@ -1,5 +0,0 @@
|
||||
|
||||
|
||||
> palmr-docs@3.1-beta lint /Users/daniel/clones/Palmr/apps/docs
|
||||
> eslint "src/**/*.+(ts|tsx)"
|
||||
|
@@ -1,267 +0,0 @@
|
||||
---
|
||||
title: Quick Start (Docker)
|
||||
icon: "Rocket"
|
||||
---
|
||||
|
||||
Welcome to the fastest way to deploy <span className="font-bold">Palmr.</span> - your secure, self-hosted file sharing solution. This guide will have you up and running in minutes, whether you're new to self-hosting or an experienced developer.
|
||||
|
||||
Palmr. offers flexible deployment options to match your infrastructure needs. This guide focuses on Docker deployment with our recommended filesystem storage, perfect for most use cases.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Ensure you have the following installed on your system:
|
||||
|
||||
- **Docker** - Container runtime ([installation guide](https://docs.docker.com/get-docker/))
|
||||
- **Docker Compose** - Multi-container orchestration ([installation guide](https://docs.docker.com/compose/install/))
|
||||
|
||||
> **Platform Support**: Palmr. is developed on macOS and extensively tested on Linux servers. While we haven't formally tested other platforms, Docker's cross-platform nature should ensure compatibility. Report any issues on our [GitHub repository](https://github.com/kyantech/Palmr/issues).
|
||||
|
||||
## Storage Options
|
||||
|
||||
Palmr. supports two storage approaches for persistent data:
|
||||
|
||||
### Named Volumes (Recommended)
|
||||
|
||||
**Best for**: Production environments, automated deployments
|
||||
|
||||
- ✅ **Managed by Docker**: No permission issues or manual path management
|
||||
- ✅ **Optimized Performance**: Docker-native storage optimization
|
||||
- ✅ **Cross-platform**: Consistent behavior across operating systems
|
||||
- ✅ **Simplified Backups**: Docker volume commands for backup/restore
|
||||
|
||||
### Bind Mounts
|
||||
|
||||
**Best for**: Development, direct file access requirements
|
||||
|
||||
- ✅ **Direct Access**: Files stored in local directory you specify
|
||||
- ✅ **Transparent Storage**: Direct filesystem access from host
|
||||
- ✅ **Custom Backup**: Use existing file system backup solutions
|
||||
- ⚠️ **Permission Considerations**: **Common Issue** - Requires UID/GID configuration (see troubleshooting below)
|
||||
|
||||
---
|
||||
|
||||
## Option 1: Named Volumes (Recommended)
|
||||
|
||||
Named volumes provide the best performance and are managed entirely by Docker.
|
||||
|
||||
### Configuration
|
||||
|
||||
Use the provided `docker-compose.yaml` for named volumes:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
palmr:
|
||||
image: kyantech/palmr:latest
|
||||
container_name: palmr
|
||||
environment:
|
||||
- ENABLE_S3=false
|
||||
- ENCRYPTION_KEY=change-this-key-in-production-min-32-chars # CHANGE THIS KEY FOR SECURITY
|
||||
# - SECURE_SITE=false # Set to true if you are using a reverse proxy
|
||||
ports:
|
||||
- "5487:5487" # Web interface
|
||||
- "3333:3333" # API port (OPTIONAL EXPOSED - ONLY IF YOU WANT TO ACCESS THE API DIRECTLY)
|
||||
volumes:
|
||||
- palmr_data:/app/server # Named volume for the application data
|
||||
restart: unless-stopped # Restart the container unless it is stopped
|
||||
|
||||
volumes:
|
||||
palmr_data:
|
||||
```
|
||||
|
||||
> **Note:** If you haveing problem with uploading files, try to change the `PALMR_UID` and `PALMR_GID` to the UID and GID of the user running the container. You can find the UID and GID of the user running the container with the command `id -u` and `id -g`. in Linux systems the default user is `1000` and the default group is `1000`. For test you can add the environment variables below to the `docker-compose.yaml` file and restart the container.
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
- PALMR_UID=1000 # UID for the container processes (default is 1001)
|
||||
- PALMR_GID=1000 # GID for the container processes (default is 1001)
|
||||
```
|
||||
|
||||
> **Note:** For more information about UID and GID, see our [UID/GID Configuration](/docs/3.1-beta/uid-gid-configuration) guide.
|
||||
|
||||
### Deployment
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Option 2: Bind Mounts
|
||||
|
||||
Bind mounts store data in a local directory, providing direct file system access.
|
||||
|
||||
### Configuration
|
||||
|
||||
To use bind mounts, **replace the content** of your `docker-compose.yaml` with the following configuration (you can also reference `docker-compose-bind-mount-example.yaml` as a template):
|
||||
|
||||
```yaml
|
||||
services:
|
||||
palmr:
|
||||
image: kyantech/palmr:latest
|
||||
container_name: palmr
|
||||
environment:
|
||||
- ENABLE_S3=false
|
||||
- ENCRYPTION_KEY=change-this-key-in-production-min-32-chars # CHANGE THIS KEY FOR SECURITY
|
||||
# - SECURE_SITE=false # Set to true if you are using a reverse proxy
|
||||
- PALMR_UID=1000 # UID for the container processes (default is 1001)
|
||||
- PALMR_GID=1000 # GID for the container processes (default is 1001)
|
||||
ports:
|
||||
- "5487:5487" # Web port
|
||||
- "3333:3333" # API port (OPTIONAL EXPOSED - ONLY IF YOU WANT TO ACCESS THE API DIRECTLY)
|
||||
volumes:
|
||||
# Bind mount for persistent data (uploads, database, temp files)
|
||||
- ./data:/app/server # Local directory for the application data
|
||||
restart: unless-stopped # Restart the container unless it is stopped
|
||||
```
|
||||
|
||||
### Deployment
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
> **Permission Configuration**: If you encounter permission issues with bind mounts (common on NAS systems), see our [UID/GID Configuration](/docs/3.1-beta/uid-gid-configuration) guide for automatic permission handling.
|
||||
|
||||
---
|
||||
|
||||
## Environment Variables
|
||||
|
||||
Configure Palmr. behavior through environment variables:
|
||||
|
||||
| Variable | Default | Description |
|
||||
| ---------------- | ------- | ------------------------------------------------------- |
|
||||
| `ENABLE_S3` | `false` | Enable S3-compatible storage |
|
||||
| `ENCRYPTION_KEY` | - | **Required**: Minimum 32 characters for file encryption |
|
||||
| `SECURE_SITE` | `false` | Enable secure cookies for HTTPS/reverse proxy setups |
|
||||
|
||||
> **⚠️ Security Warning**: Always change the `ENCRYPTION_KEY` in production. This key encrypts your files - losing it makes files permanently inaccessible.
|
||||
|
||||
> **🔗 Reverse Proxy**: If deploying behind a reverse proxy (Traefik, Nginx, etc.), set `SECURE_SITE=true` and review our [Reverse Proxy Configuration](/docs/3.1-beta/reverse-proxy-configuration) guide for proper setup.
|
||||
|
||||
### Generate Secure Encryption Keys
|
||||
|
||||
Need a strong key for `ENCRYPTION_KEY`? Use our built-in generator to create cryptographically secure keys:
|
||||
|
||||
<KeyGenerator />
|
||||
|
||||
---
|
||||
|
||||
## Accessing Palmr.
|
||||
|
||||
Once deployed, access Palmr. through your web browser:
|
||||
|
||||
- **Local**: `http://localhost:5487`
|
||||
- **Server**: `http://YOUR_SERVER_IP:5487`
|
||||
|
||||
### API Access (Optional)
|
||||
|
||||
If you exposed port 3333 in your configuration, you can also access:
|
||||
|
||||
- **API Documentation**: `http://localhost:3333/docs` (local) or `http://YOUR_SERVER_IP:3333/docs` (server)
|
||||
- **API Endpoints**: Available at `http://localhost:3333` (local) or `http://YOUR_SERVER_IP:3333` (server)
|
||||
|
||||
> **📚 Learn More**: For complete API documentation, authentication, and integration examples, see our [API Reference](/docs/3.1-beta/api) guide.
|
||||
|
||||
> **💡 Production Tip**: For production deployments, configure HTTPS with a valid SSL certificate for enhanced security.
|
||||
|
||||
---
|
||||
|
||||
## Docker CLI Alternative
|
||||
|
||||
Prefer using Docker directly? Both storage options are supported:
|
||||
|
||||
**Named Volume:**
|
||||
|
||||
```bash
|
||||
docker run -d \
|
||||
--name palmr \
|
||||
-e ENABLE_S3=false \
|
||||
-e ENCRYPTION_KEY=your-secure-key-min-32-chars \
|
||||
-p 5487:5487 \
|
||||
-p 3333:3333 \
|
||||
-v palmr_data:/app/server \
|
||||
--restart unless-stopped \
|
||||
kyantech/palmr:latest
|
||||
```
|
||||
|
||||
**Bind Mount:**
|
||||
|
||||
```bash
|
||||
docker run -d \
|
||||
--name palmr \
|
||||
-e ENABLE_S3=false \
|
||||
-e ENCRYPTION_KEY=your-secure-key-min-32-chars \
|
||||
-p 5487:5487 \
|
||||
-p 3333:3333 \
|
||||
-v $(pwd)/data:/app/server \
|
||||
--restart unless-stopped \
|
||||
kyantech/palmr:latest
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Maintenance
|
||||
|
||||
### Updates
|
||||
|
||||
Keep Palmr. current with the latest features and security fixes:
|
||||
|
||||
```bash
|
||||
docker-compose pull
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### Backup & Restore
|
||||
|
||||
The backup method depends on which storage option you're using:
|
||||
|
||||
**Named Volume Backup:**
|
||||
|
||||
```bash
|
||||
docker run --rm \
|
||||
-v palmr_data:/data \
|
||||
-v $(pwd):/backup \
|
||||
alpine tar czf /backup/palmr-backup.tar.gz -C /data .
|
||||
```
|
||||
|
||||
**Named Volume Restore:**
|
||||
|
||||
```bash
|
||||
docker run --rm \
|
||||
-v palmr_data:/data \
|
||||
-v $(pwd):/backup \
|
||||
alpine tar xzf /backup/palmr-backup.tar.gz -C /data
|
||||
```
|
||||
|
||||
**Bind Mount Backup:**
|
||||
|
||||
```bash
|
||||
tar czf palmr-backup.tar.gz ./data
|
||||
```
|
||||
|
||||
**Bind Mount Restore:**
|
||||
|
||||
```bash
|
||||
tar xzf palmr-backup.tar.gz
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Next Steps
|
||||
|
||||
Your Palmr. instance is now ready! Explore additional configuration options:
|
||||
|
||||
### Advanced Configuration
|
||||
|
||||
- **[UID/GID Configuration](/docs/3.1-beta/uid-gid-configuration)** - Configure user permissions for NAS systems and custom environments
|
||||
- **[S3 Storage](/docs/3.1-beta/s3-configuration)** - Scale with Amazon S3 or compatible storage providers
|
||||
- **[Manual Installation](/docs/3.1-beta/manual-installation)** - Manual installation and custom configurations
|
||||
|
||||
### Integration & Development
|
||||
|
||||
- **[API Reference](/docs/3.1-beta/api)** - Integrate Palmr. with your applications
|
||||
- **[Architecture Guide](/docs/3.1-beta/architecture)** - Understanding Palmr. components and design
|
||||
|
||||
---
|
||||
|
||||
Need help? Visit our [GitHub Issues](https://github.com/kyantech/Palmr/issues) or community discussions.
|
@@ -30,8 +30,6 @@ services:
|
||||
```bash
|
||||
docker run -d \
|
||||
--name palmr \
|
||||
-e ENABLE_S3=false \
|
||||
-e ENCRYPTION_KEY=change-this-key-in-production-min-32-chars \
|
||||
-p 5487:5487 \
|
||||
-p 3333:3333 \
|
||||
-v palmr_data:/app/server \
|
||||
@@ -107,6 +105,12 @@ The Palmr. API provides comprehensive access to all platform features:
|
||||
- **File management** - Rename, delete, and organize files
|
||||
- **Metadata access** - Retrieve file information and properties
|
||||
|
||||
### Folder operations
|
||||
|
||||
- **Create folders** - Build folder structures for organization
|
||||
- **Folder management** - Rename, move, delete folders
|
||||
- **Folder sharing** - Share folders with same controls as files
|
||||
|
||||
### Share management
|
||||
|
||||
- **Create shares** - Generate public links for file sharing
|
@@ -43,6 +43,16 @@ Palmr. uses **filesystem storage** as the default storage solution, keeping thin
|
||||
- Excellent performance for local file operations
|
||||
- Optional S3-compatible storage support for cloud deployments and scalability
|
||||
|
||||
#### Performance Considerations with Encryption
|
||||
|
||||
By default, filesystem storage operates without encryption for optimal performance, providing fast uploads and downloads with minimal CPU overhead. This approach is ideal for most use cases where performance is prioritized.
|
||||
|
||||
If you need to protect sensitive files at rest, you can enable encryption by setting `DISABLE_FILESYSTEM_ENCRYPTION=false` and providing an `ENCRYPTION_KEY` in your configuration. When enabled, Palmr uses AES-256-CBC encryption, which adds CPU overhead during uploads (encryption) and downloads (decryption), particularly for large files or in resource-constrained environments like containers or low-end VMs.
|
||||
|
||||
For optimal performance with encryption enabled, ensure your hardware supports AES-NI acceleration (check with `cat /proc/cpuinfo | grep aes` on Linux).
|
||||
|
||||
As an alternative, consider using S3-compatible object storage (e.g., AWS S3 or MinIO), which can offload file storage from the local filesystem and potentially reduce local CPU overhead for encryption/decryption. See [S3 Providers](/docs/3.2-beta/s3-providers) for setup instructions.
|
||||
|
||||
### Fastify + Zod + TypeScript
|
||||
|
||||
The backend of Palmr. is powered by **Fastify**, **Zod**, and **TypeScript**, creating a robust and type-safe API layer. Fastify is a super-fast Node.js web framework optimized for performance and low overhead, designed to handle lots of concurrent requests with minimal resource usage. Zod provides runtime type validation and schema definition, ensuring all incoming data is properly validated before reaching business logic. TypeScript adds compile-time type safety throughout the entire backend codebase. This combination creates a highly reliable and maintainable backend that prevents bugs and security issues while maintaining excellent performance.
|
||||
@@ -117,7 +127,7 @@ Palmr. is designed to be flexible in how you handle file storage:
|
||||
|
||||
**Optional S3-compatible storage:**
|
||||
|
||||
- Enable S3 storage by setting `ENABLE_S3=true`, look at [S3 Providers](/docs/3.1-beta/s3-providers) for more information.
|
||||
- Enable S3 storage by setting `ENABLE_S3=true`, look at [S3 Providers](/docs/3.2-beta/s3-providers) for more information.
|
||||
- Compatible with AWS S3, MinIO, and other S3-compatible services
|
||||
- Ideal for cloud deployments and distributed setups
|
||||
- Provides additional scalability and redundancy options
|
391
apps/docs/content/docs/3.2-beta/download-memory-management.mdx
Normal file
391
apps/docs/content/docs/3.2-beta/download-memory-management.mdx
Normal file
@@ -0,0 +1,391 @@
|
||||
---
|
||||
title: Memory Management
|
||||
icon: Download
|
||||
---
|
||||
|
||||
import { Callout } from "fumadocs-ui/components/callout";
|
||||
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
|
||||
|
||||
Palmr implements an intelligent memory management system that prevents crashes during large file downloads (3GB+ by default), maintaining unlimited download capacity through adaptive resource control and an automatic queue system.
|
||||
|
||||
## How It Works
|
||||
|
||||
### Automatic Resource Detection
|
||||
|
||||
The system automatically detects available container/system memory and configures appropriate limits based on available infrastructure:
|
||||
|
||||
```typescript
|
||||
const totalMemoryGB = require("os").totalmem() / 1024 ** 3;
|
||||
```
|
||||
|
||||
### System Configuration
|
||||
|
||||
The system supports two configuration approaches that you can choose based on your needs:
|
||||
|
||||
<Tabs items={["Manual Configuration", "Auto-scaling (Default)"]}>
|
||||
<Tab value="Manual Configuration">
|
||||
Manually configure all parameters for total control over the system:
|
||||
|
||||
```bash
|
||||
# Custom configuration (overrides auto-scaling)
|
||||
DOWNLOAD_MAX_CONCURRENT=8 # Maximum simultaneous downloads
|
||||
DOWNLOAD_MEMORY_THRESHOLD_MB=1536 # Memory threshold in MB
|
||||
DOWNLOAD_QUEUE_SIZE=40 # Maximum queue size
|
||||
DOWNLOAD_AUTO_SCALE=false # Disable auto-scaling
|
||||
```
|
||||
|
||||
<Callout>
|
||||
Manual configuration offers total control and predictability for specific environments where you know exactly the available resources.
|
||||
</Callout>
|
||||
|
||||
</Tab>
|
||||
<Tab value="Auto-scaling (Default)">
|
||||
Automatic configuration based on detected system memory:
|
||||
|
||||
| Available Memory | Concurrent Downloads | Memory Threshold | Queue Size | Recommended Use |
|
||||
|------------------|----------------------|-------------------|------------|--------------------|
|
||||
| ≤ 2GB | 1 | 256MB | 5 | Development |
|
||||
| 2GB - 4GB | 2 | 512MB | 10 | Small Environment |
|
||||
| 4GB - 8GB | 3 | 1GB | 15 | Standard Production|
|
||||
| 8GB - 16GB | 5 | 2GB | 25 | High Performance |
|
||||
| > 16GB | 10 | 4GB | 50 | Enterprise |
|
||||
|
||||
<Callout>
|
||||
Auto-scaling automatically adapts to different environments without manual configuration, perfect for flexible deployment.
|
||||
</Callout>
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
<Callout type="info">If environment variables are configured, they take **priority** over auto-scaling.</Callout>
|
||||
|
||||
## Download Queue System
|
||||
|
||||
### How It Works
|
||||
|
||||
The memory management system only activates for files larger than the configured minimum size (3GB by default). Smaller files bypass the queue system entirely and download immediately without memory management.
|
||||
|
||||
When a user requests a download for a large file but all slots are occupied, the system automatically queues the download instead of returning a 429 error. The queue processes downloads in FIFO order (first in, first out).
|
||||
|
||||
### Practical Example
|
||||
|
||||
Consider a system with 8GB RAM (5 concurrent downloads, queue of 25, 3GB minimum) where users want to download files of various sizes:
|
||||
|
||||
```bash
|
||||
# Small files (< 3GB): Bypass queue entirely
|
||||
[DOWNLOAD MANAGER] File document.pdf (0.05GB) below threshold (3.0GB), bypassing queue
|
||||
|
||||
# Large files 1-5: Start immediately
|
||||
[DOWNLOAD MANAGER] Immediate start: 1734567890-abc123def
|
||||
[DOWNLOAD MANAGER] Starting video1.mp4 (5.2GB)
|
||||
|
||||
# Large files 6-10: Automatically queued
|
||||
[DOWNLOAD MANAGER] Queued: 1734567891-def456ghi (Position: 1/25)
|
||||
[DOWNLOAD MANAGER] Queued file: video2.mp4 (8.1GB)
|
||||
|
||||
# When download 1 finishes: download 6 starts automatically
|
||||
[DOWNLOAD MANAGER] Processing queue: 1734567891-def456ghi (4 remaining)
|
||||
[DOWNLOAD MANAGER] Starting queued file: video2.mp4 (8.1GB)
|
||||
```
|
||||
|
||||
### System Benefits
|
||||
|
||||
**User Experience**
|
||||
|
||||
- Users don't receive errors, they simply wait in queue
|
||||
- Downloads start automatically when slots become available
|
||||
- Transparent operation without client changes
|
||||
- Fair processing order with FIFO queue
|
||||
|
||||
**Technical Features**
|
||||
|
||||
- Limited buffers (64KB per stream) for controlled memory usage
|
||||
- Automatic backpressure control with pipeline streams
|
||||
- Adaptive memory throttling based on usage patterns
|
||||
- Forced garbage collection after large downloads
|
||||
- Smart timeout handling (30 minutes for queued downloads)
|
||||
- Automatic cleanup of orphaned downloads every 30 seconds
|
||||
|
||||
## Container Compatibility
|
||||
|
||||
The system works with Docker, Kubernetes, and any containerized environment:
|
||||
|
||||
<Tabs items={["Docker", "Kubernetes", "Docker Compose"]}>
|
||||
<Tab value="Docker">
|
||||
|
||||
```bash
|
||||
# Example: Container with 8GB
|
||||
docker run -m 8g palmr/server
|
||||
# Result: 5 concurrent downloads, queue of 25, threshold 2GB
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab value="Kubernetes">
|
||||
|
||||
```yaml
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: palmr-server
|
||||
resources:
|
||||
limits:
|
||||
memory: "4Gi" # Detects 4GB
|
||||
cpu: "2"
|
||||
requests:
|
||||
memory: "2Gi"
|
||||
cpu: "1"
|
||||
# Result: 3 concurrent downloads, queue of 15, threshold 1GB
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab value="Docker Compose">
|
||||
|
||||
```yaml
|
||||
services:
|
||||
palmr-server:
|
||||
image: palmr/server
|
||||
deploy:
|
||||
resources:
|
||||
limits:
|
||||
memory: 16G # Detects 16GB
|
||||
# Result: 10 concurrent downloads, queue of 50, threshold 4GB
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
## Configuration
|
||||
|
||||
### Environment Variables
|
||||
|
||||
Configure the download memory management system using these environment variables:
|
||||
|
||||
| Variable | Default | Description |
|
||||
| ------------------------------ | ---------- | ----------------------------------------------------- |
|
||||
| `DOWNLOAD_MAX_CONCURRENT` | auto-scale | Maximum number of simultaneous downloads |
|
||||
| `DOWNLOAD_MEMORY_THRESHOLD_MB` | auto-scale | Memory limit in MB before throttling |
|
||||
| `DOWNLOAD_QUEUE_SIZE` | auto-scale | Maximum download queue size |
|
||||
| `DOWNLOAD_AUTO_SCALE` | `true` | Enable/disable auto-scaling based on system memory |
|
||||
| `DOWNLOAD_MIN_FILE_SIZE_GB` | `3.0` | Minimum file size in GB to activate memory management |
|
||||
|
||||
### Configuration Examples by Scenario
|
||||
|
||||
<Tabs items={["Home Server", "Enterprise", "High Performance", "Conservative"]}>
|
||||
<Tab value="Home Server">
|
||||
Configuration optimized for personal use or small groups (4GB RAM):
|
||||
|
||||
```bash
|
||||
DOWNLOAD_MAX_CONCURRENT=2
|
||||
DOWNLOAD_MEMORY_THRESHOLD_MB=1024
|
||||
DOWNLOAD_QUEUE_SIZE=8
|
||||
DOWNLOAD_MIN_FILE_SIZE_GB=2.0
|
||||
DOWNLOAD_AUTO_SCALE=false
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab value="Enterprise">
|
||||
Configuration for corporate environments with multiple users (16GB RAM):
|
||||
|
||||
```bash
|
||||
DOWNLOAD_MAX_CONCURRENT=12
|
||||
DOWNLOAD_MEMORY_THRESHOLD_MB=4096
|
||||
DOWNLOAD_QUEUE_SIZE=60
|
||||
DOWNLOAD_MIN_FILE_SIZE_GB=5.0
|
||||
DOWNLOAD_AUTO_SCALE=false
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab value="High Performance">
|
||||
Configuration for maximum performance and throughput (32GB RAM):
|
||||
|
||||
```bash
|
||||
DOWNLOAD_MAX_CONCURRENT=20
|
||||
DOWNLOAD_MEMORY_THRESHOLD_MB=8192
|
||||
DOWNLOAD_QUEUE_SIZE=100
|
||||
DOWNLOAD_MIN_FILE_SIZE_GB=10.0
|
||||
DOWNLOAD_AUTO_SCALE=false
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab value="Conservative">
|
||||
For environments with limited or shared resources:
|
||||
|
||||
```bash
|
||||
DOWNLOAD_MAX_CONCURRENT=3
|
||||
DOWNLOAD_MEMORY_THRESHOLD_MB=1024
|
||||
DOWNLOAD_QUEUE_SIZE=15
|
||||
DOWNLOAD_MIN_FILE_SIZE_GB=1.0
|
||||
DOWNLOAD_AUTO_SCALE=false
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
### Additional Configuration
|
||||
|
||||
For optimal performance with large downloads, consider these additional settings:
|
||||
|
||||
```bash
|
||||
# Force garbage collection (recommended for large downloads)
|
||||
NODE_OPTIONS="--expose-gc"
|
||||
|
||||
# Adjust timeout for very large downloads
|
||||
KEEP_ALIVE_TIMEOUT=300000
|
||||
REQUEST_TIMEOUT=0
|
||||
```
|
||||
|
||||
## Monitoring and Logs
|
||||
|
||||
### System Logs
|
||||
|
||||
The system provides detailed logs to track operation:
|
||||
|
||||
```bash
|
||||
[DOWNLOAD MANAGER] System Memory: 8.0GB, Max Concurrent: 5, Memory Threshold: 2048MB, Queue Size: 25
|
||||
[DOWNLOAD] Requesting slot for 1734567890-abc123def: video.mp4 (15.2GB)
|
||||
[DOWNLOAD MANAGER] Queued: 1734567890-abc123def (Position: 3/25)
|
||||
[DOWNLOAD MANAGER] Processing queue: 1734567890-abc123def (2 remaining)
|
||||
[DOWNLOAD] Starting 1734567890-abc123def: video.mp4 (15.2GB)
|
||||
[MEMORY THROTTLE] video.mp4 - Pausing stream due to high memory usage: 1843MB
|
||||
[DOWNLOAD] Applying throttling: 100ms delay for 1734567890-abc123def
|
||||
```
|
||||
|
||||
### Configuration Validation
|
||||
|
||||
The system automatically validates configurations at startup and provides warnings or errors:
|
||||
|
||||
**Warnings**
|
||||
|
||||
- `DOWNLOAD_MAX_CONCURRENT > 50`: May cause performance issues
|
||||
- `DOWNLOAD_MEMORY_THRESHOLD_MB < 128MB`: Downloads may be throttled frequently
|
||||
- `DOWNLOAD_MEMORY_THRESHOLD_MB > 16GB`: System may run out of memory
|
||||
- `DOWNLOAD_QUEUE_SIZE > 1000`: May consume significant memory
|
||||
- `DOWNLOAD_QUEUE_SIZE < DOWNLOAD_MAX_CONCURRENT`: Queue smaller than concurrent downloads
|
||||
|
||||
**Errors**
|
||||
|
||||
- `DOWNLOAD_MAX_CONCURRENT < 1`: Invalid value
|
||||
- `DOWNLOAD_QUEUE_SIZE < 1`: Invalid value
|
||||
|
||||
## Queue Management APIs
|
||||
|
||||
The system provides REST APIs to monitor and manage the download queue:
|
||||
|
||||
### Get Queue Status
|
||||
|
||||
```http
|
||||
GET /api/filesystem/download-queue/status
|
||||
```
|
||||
|
||||
**Response:**
|
||||
|
||||
```json
|
||||
{
|
||||
"data": {
|
||||
"queueLength": 3,
|
||||
"maxQueueSize": 25,
|
||||
"activeDownloads": 5,
|
||||
"maxConcurrent": 5,
|
||||
"queuedDownloads": [
|
||||
{
|
||||
"downloadId": "1734567890-abc123def",
|
||||
"position": 1,
|
||||
"waitTime": 45000,
|
||||
"fileName": "video.mp4",
|
||||
"fileSize": 16106127360
|
||||
}
|
||||
]
|
||||
},
|
||||
"status": "success"
|
||||
}
|
||||
```
|
||||
|
||||
### Cancel Download
|
||||
|
||||
```http
|
||||
DELETE /api/filesystem/download-queue/{downloadId}
|
||||
```
|
||||
|
||||
**Response:**
|
||||
|
||||
```json
|
||||
{
|
||||
"downloadId": "1734567890-abc123def",
|
||||
"message": "Download cancelled successfully"
|
||||
}
|
||||
```
|
||||
|
||||
### Clear Queue (Admin)
|
||||
|
||||
```http
|
||||
DELETE /api/filesystem/download-queue
|
||||
```
|
||||
|
||||
**Response:**
|
||||
|
||||
```json
|
||||
{
|
||||
"clearedCount": 8,
|
||||
"message": "Download queue cleared successfully"
|
||||
}
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Common Issues
|
||||
|
||||
**Downloads failing with "Download queue is full"**
|
||||
|
||||
_Cause:_ Too many simultaneous downloads with a full queue
|
||||
|
||||
_Solutions:_
|
||||
|
||||
- Wait for some downloads to finish
|
||||
- Check for orphaned downloads in queue
|
||||
- Consider increasing container resources
|
||||
- Use API to clear queue if necessary
|
||||
|
||||
**Downloads stay too long in queue**
|
||||
|
||||
_Cause:_ Active downloads are slow or stuck
|
||||
|
||||
_Solutions:_
|
||||
|
||||
- Check logs for orphaned downloads
|
||||
- Use API to cancel specific downloads
|
||||
- Check client network connections
|
||||
- Monitor memory throttling
|
||||
|
||||
**Very slow downloads**
|
||||
|
||||
_Cause:_ Active throttling due to high memory usage
|
||||
|
||||
_Solutions:_
|
||||
|
||||
- Check other processes consuming memory
|
||||
- Consider increasing container resources
|
||||
- Monitor throttling logs
|
||||
- Check number of simultaneous downloads
|
||||
|
||||
## Summary
|
||||
|
||||
This system enables unlimited downloads (including 50TB+ files) without compromising system stability through:
|
||||
|
||||
**Key Features**
|
||||
|
||||
- Auto-configuration based on available resources
|
||||
- Automatic FIFO queue system for pending downloads
|
||||
- Adaptive control of simultaneous downloads
|
||||
- Intelligent throttling when needed
|
||||
|
||||
**System Benefits**
|
||||
|
||||
- Management APIs to monitor and control queue
|
||||
- Automatic cleanup of resources and orphaned downloads
|
||||
- Full compatibility with Docker/Kubernetes
|
||||
- Perfect user experience with no 429 errors
|
||||
|
||||
The system maintains high performance for small/medium files while preventing crashes with gigantic files, offering a seamless experience where users never see 429 errors, they simply wait in queue until their download starts automatically.
|
@@ -49,6 +49,7 @@ The frontend is organized with:
|
||||
- **Custom hooks** to isolate logic and side effects
|
||||
- A **route protection system** using session cookies and middleware
|
||||
- A **file management interface** integrated with the backend
|
||||
- **Folder support** for organizing files hierarchically
|
||||
- A **reusable modal system** used for file actions, confirmations, and more
|
||||
- **Dynamic, locale-aware routing** using next-intl
|
||||
|
||||
@@ -68,7 +69,7 @@ Data is stored in **SQLite**, which handles user info, file metadata, session to
|
||||
Key features include:
|
||||
|
||||
- **Authentication/authorization** with JWT + cookie sessions
|
||||
- **File management logic** including uploads, deletes, and renames
|
||||
- **File management logic** including uploads, deletes, renames, and folders
|
||||
- **Storage operations** to handle file organization, usage tracking, and cleanup
|
||||
- A **share system** that generates tokenized public file links
|
||||
- Schema-based request validation for all endpoints
|
||||
@@ -106,9 +107,10 @@ Volumes are used to persist data locally, and containers are networked together
|
||||
|
||||
### File management
|
||||
|
||||
Files are at the heart of Palmr. Users can upload files via the frontend, and they're stored directly in the filesystem. The backend handles metadata (name, size, type, ownership), and also handles deletion, renaming, and public sharing. Every file operation is tracked, and all actions can be scoped per user.
|
||||
Files are at the heart of Palmr. Users can upload files via the frontend, and they're stored directly in the filesystem. Users can also create folders to organize files. The backend handles metadata (name, size, type, ownership), and also handles deletion, renaming, and public sharing. Every file operation is tracked, and all actions can be scoped per user.
|
||||
|
||||
- Upload/download with instant feedback
|
||||
- Create and organize files in folders
|
||||
- File previews, type validation, and size limits
|
||||
- Token-based sharing system
|
||||
- Disk usage tracking by user
|
@@ -5,7 +5,7 @@ icon: Cog
|
||||
|
||||
Hey there! Looking to run **Palmr.** your way, with complete control over every piece of the stack? This manual installation guide is for you. No Docker, no pre-built containers just the raw source code to tweak, customize, and deploy as you see fit.
|
||||
|
||||
> **Prefer a quicker setup?** If this hands-on approach feels like overkill, check out our [**Quick Start (Docker)**](/docs/3.1-beta/quick-start) guide for a fast, containerized deployment. This manual path is tailored for developers who want to dive deep, modify the codebase, or integrate custom services.
|
||||
> **Prefer a quicker setup?** If this hands-on approach feels like overkill, check out our [**Quick Start (Docker)**](/docs/3.2-beta/quick-start) guide for a fast, containerized deployment. This manual path is tailored for developers who want to dive deep, modify the codebase, or integrate custom services.
|
||||
|
||||
Here's what you'll do at a glance:
|
||||
|
||||
@@ -201,6 +201,17 @@ You should see the full Palmr. application ready to go!
|
||||
|
||||
This guide sets up Palmr. using the local file system for storage. Want to use an S3-compatible object storage instead? You can configure that in the `.env` file. Check the Palmr. documentation for details on setting up S3 storage just update the environment variables, then build and run as shown here.
|
||||
|
||||
### Custom Installation Paths and Symlinks
|
||||
|
||||
If you're using a custom installation setup with symlinks (for example, `/opt/palmr_data/uploads -> /mnt/data/uploads`), you might encounter issues with disk space detection. Palmr. includes a `CUSTOM_PATH` environment variable to handle these scenarios:
|
||||
|
||||
```bash
|
||||
# In your .env file (apps/server/.env)
|
||||
CUSTOM_PATH=/opt/palmr_data
|
||||
```
|
||||
|
||||
This tells Palmr. to check your custom path first when determining available disk space, ensuring proper detection even when using symlinks or non-standard directory structures.
|
||||
|
||||
---
|
||||
|
||||
## Command cheat sheet
|
||||
@@ -232,10 +243,10 @@ pnpm serve
|
||||
|
||||
Palmr. is now up and running locally . Here are some suggested next steps:
|
||||
|
||||
- **Manage Users**: Dive into the [Users Management](/docs/3.1-beta/manage-users) guide.
|
||||
- **Manage Users**: Dive into the [Users Management](/docs/3.2-beta/manage-users) guide.
|
||||
- **Switch to Object Storage**: Update `.env` variables to use an S3-compatible bucket (see Quick Notes above).
|
||||
- **Secure Your Instance**: Put Palmr. behind a reverse proxy like **Nginx** or **Caddy** and enable HTTPS.
|
||||
- **Learn the Internals**: Explore how everything connects in the [Architecture](/docs/3.1-beta/architecture) overview.
|
||||
- **Learn the Internals**: Explore how everything connects in the [Architecture](/docs/3.2-beta/architecture) overview.
|
||||
|
||||
Jump into whichever area fits your needs our docs are designed for exploration in any order.
|
||||
|
@@ -14,6 +14,7 @@
|
||||
"available-languages",
|
||||
"uid-gid-configuration",
|
||||
"reverse-proxy-configuration",
|
||||
"download-memory-management",
|
||||
"password-reset-without-smtp",
|
||||
"oidc-authentication",
|
||||
"troubleshooting",
|
||||
@@ -29,5 +30,5 @@
|
||||
"gh-sponsor"
|
||||
],
|
||||
"root": true,
|
||||
"title": "v3.1-beta"
|
||||
"title": "v3.2-beta"
|
||||
}
|
@@ -360,7 +360,7 @@ With Auth0 authentication configured, you might want to:
|
||||
- **Review security settings**: Ensure your authentication setup meets your security requirements
|
||||
- **Monitor usage**: Keep track of authentication patterns and user activity
|
||||
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.1-beta/oidc-authentication).
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.2-beta/oidc-authentication).
|
||||
|
||||
## Useful resources
|
||||
|
@@ -374,7 +374,7 @@ With Authentik authentication configured, you might want to:
|
||||
- **Review security settings**: Ensure your authentication setup meets your security requirements
|
||||
- **Monitor usage**: Keep track of authentication patterns and user activity
|
||||
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.1-beta/oidc-authentication).
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.2-beta/oidc-authentication).
|
||||
|
||||
## Useful resources
|
||||
|
@@ -332,7 +332,7 @@ With Discord authentication configured, you might want to:
|
||||
- **Review security settings**: Ensure your authentication setup meets your security requirements
|
||||
- **Monitor usage**: Keep track of authentication patterns and user activity
|
||||
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.1-beta/oidc-authentication).
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.2-beta/oidc-authentication).
|
||||
|
||||
## Useful resources
|
||||
|
@@ -314,7 +314,7 @@ With Frontegg authentication configured, you might want to:
|
||||
- **Review security settings**: Ensure your authentication setup meets your security requirements
|
||||
- **Monitor usage**: Keep track of authentication patterns and user activity
|
||||
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.1-beta/oidc-authentication).
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.2-beta/oidc-authentication).
|
||||
|
||||
## Useful resources
|
||||
|
@@ -295,7 +295,7 @@ With GitHub authentication configured, you might want to:
|
||||
- **Review security settings**: Ensure your authentication setup meets your security requirements
|
||||
- **Monitor usage**: Keep track of authentication patterns and user activity
|
||||
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.1-beta/oidc-authentication).
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.2-beta/oidc-authentication).
|
||||
|
||||
## Useful resources
|
||||
|
@@ -325,7 +325,7 @@ With Google authentication configured, you might want to:
|
||||
- **Review security settings**: Ensure your authentication setup meets your security requirements
|
||||
- **Monitor usage**: Keep track of authentication patterns and user activity
|
||||
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.1-beta/oidc-authentication).
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.2-beta/oidc-authentication).
|
||||
|
||||
## Useful resources
|
||||
|
@@ -38,14 +38,14 @@ Before configuring OIDC authentication, ensure you have:
|
||||
|
||||
Palmr's OIDC implementation is compatible with any OpenID Connect compliant provider, including as official providers:
|
||||
|
||||
- **[Google](/docs/3.1-beta/oidc-authentication/google)**
|
||||
- **[Discord](/docs/3.1-beta/oidc-authentication/discord)**
|
||||
- **[Github](/docs/3.1-beta/oidc-authentication/github)**
|
||||
- **[Zitadel](/docs/3.1-beta/oidc-authentication/zitadel)**
|
||||
- **[Auth0](/docs/3.1-beta/oidc-authentication/auth0)**
|
||||
- **[Authentik](/docs/3.1-beta/oidc-authentication/authentik)**
|
||||
- **[Frontegg](/docs/3.1-beta/oidc-authentication/frontegg)**
|
||||
- **[Kinde Auth](/docs/3.1-beta/oidc-authentication/kinde-auth)**
|
||||
- **[Google](/docs/3.2-beta/oidc-authentication/google)**
|
||||
- **[Discord](/docs/3.2-beta/oidc-authentication/discord)**
|
||||
- **[Github](/docs/3.2-beta/oidc-authentication/github)**
|
||||
- **[Zitadel](/docs/3.2-beta/oidc-authentication/zitadel)**
|
||||
- **[Auth0](/docs/3.2-beta/oidc-authentication/auth0)**
|
||||
- **[Authentik](/docs/3.2-beta/oidc-authentication/authentik)**
|
||||
- **[Frontegg](/docs/3.2-beta/oidc-authentication/frontegg)**
|
||||
- **[Kinde Auth](/docs/3.2-beta/oidc-authentication/kinde-auth)**
|
||||
|
||||
Although these are the official providers (internally tested with 100% success), you can connect any OIDC provider by providing your credentials and connection URL. We've developed a practical way to integrate virtually all OIDC providers available in the market. In this documentation, you can consult how to configure each of the official providers, as well as include other providers not listed as official. Just below, you will find instructions on how to access the OIDC provider configuration. For specific details about configuring each provider, select the desired option in the sidebar, in the "OIDC Authentication" section.
|
||||
|
@@ -359,7 +359,7 @@ With Kinde Auth authentication configured, you might want to:
|
||||
- **Review security settings**: Ensure your authentication setup meets your security requirements
|
||||
- **Monitor usage**: Keep track of authentication patterns and user activity
|
||||
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.1-beta/oidc-authentication).
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.2-beta/oidc-authentication).
|
||||
|
||||
## Useful resources
|
||||
|
@@ -15,4 +15,4 @@
|
||||
"other"
|
||||
],
|
||||
"title": "OIDC Authentication"
|
||||
}
|
||||
}
|
@@ -270,10 +270,10 @@ After configuring Pocket ID authentication:
|
||||
- **User management**: Review auto-registration settings
|
||||
- **Backup verification**: Test backup and restore procedures
|
||||
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.1-beta/oidc-authentication).
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.2-beta/oidc-authentication).
|
||||
|
||||
## Useful resources
|
||||
|
||||
- [Pocket ID Documentation](https://docs.pocket-id.org)
|
||||
- [OIDC Specification](https://openid.net/specs/openid-connect-core-1_0.html)
|
||||
- [Palmr OIDC Overview](/docs/3.1-beta/oidc-authentication)
|
||||
- [Palmr OIDC Overview](/docs/3.2-beta/oidc-authentication)
|
@@ -413,7 +413,7 @@ With Zitadel authentication configured, you might want to:
|
||||
- **Review security settings**: Ensure your authentication setup meets your security requirements
|
||||
- **Monitor usage**: Keep track of authentication patterns and user activity
|
||||
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.1-beta/oidc-authentication).
|
||||
For more information about OIDC authentication in Palmr, see the [OIDC Authentication overview](/docs/3.2-beta/oidc-authentication).
|
||||
|
||||
## Useful resources
|
||||
|
@@ -47,12 +47,12 @@ docker exec -it <container_name_or_id> /bin/sh
|
||||
|
||||
Replace `<container_name_or_id>` with the name or ID of your Palmr container. This command opens an interactive shell session inside the container, allowing you to execute commands directly.
|
||||
|
||||
### 3. Navigate to the server directory
|
||||
### 3. Navigate to the application directory
|
||||
|
||||
Once inside the container, navigate to the server directory where the reset script is located:
|
||||
Once inside the container, navigate to the application directory where the reset script is located:
|
||||
|
||||
```bash
|
||||
cd /app/server
|
||||
cd /app/palmr-app
|
||||
```
|
||||
|
||||
This directory contains the necessary scripts and configurations for managing Palmr's backend operations.
|
||||
@@ -135,11 +135,11 @@ If you encounter issues while running the script, refer to the following solutio
|
||||
- Confirm that the `prisma/palmr.db` file exists and has the correct permissions.
|
||||
- Verify that the container has access to the database volume.
|
||||
|
||||
- **Error: "Script must be run from server directory"**
|
||||
This error appears if you are not in the correct directory. Navigate to the server directory with:
|
||||
- **Error: "Script must be run from application directory"**
|
||||
This error appears if you are not in the correct directory. Navigate to the application directory with:
|
||||
|
||||
```bash
|
||||
cd /app/server
|
||||
cd /app/palmr-app
|
||||
```
|
||||
|
||||
- **Error: "User not found"**
|
385
apps/docs/content/docs/3.2-beta/quick-start.mdx
Normal file
385
apps/docs/content/docs/3.2-beta/quick-start.mdx
Normal file
@@ -0,0 +1,385 @@
|
||||
---
|
||||
title: Quick Start (Docker)
|
||||
icon: "Rocket"
|
||||
---
|
||||
|
||||
import { Callout } from "fumadocs-ui/components/callout";
|
||||
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
|
||||
|
||||
import { Card, CardGrid } from "@/components/ui/card";
|
||||
|
||||
Welcome to the fastest way to deploy <span className="font-bold">Palmr.</span> - your secure, self-hosted file sharing solution. This guide will have you up and running in minutes, whether you're new to self-hosting or an experienced developer.
|
||||
|
||||
Palmr. offers flexible deployment options to match your infrastructure needs. This guide focuses on Docker deployment with our recommended filesystem storage, perfect for most use cases.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Before you begin, make sure you have:
|
||||
|
||||
- **Docker** - Container runtime ([installation guide](https://docs.docker.com/get-docker/))
|
||||
- **Docker Compose** - Multi-container orchestration ([installation guide](https://docs.docker.com/compose/install/))
|
||||
- **2GB+ available disk space** for the application and your files
|
||||
- **Port 5487** available for the web interface
|
||||
- **Port 3333** available for API access (optional)
|
||||
|
||||
<Callout>
|
||||
**Platform Support**: Palmr. is developed on macOS and extensively tested on Linux servers. While we haven't formally
|
||||
tested other platforms, Docker's cross-platform nature should ensure compatibility. Report any issues on our [GitHub
|
||||
repository](https://github.com/kyantech/Palmr/issues).
|
||||
</Callout>
|
||||
|
||||
## Storage Options
|
||||
|
||||
Palmr. supports two storage approaches for persistent data:
|
||||
|
||||
- **Named Volumes (Recommended)** - Docker-managed storage with optimal performance and no permission issues
|
||||
- **Bind Mounts** - Direct host filesystem access, ideal for development and direct file management
|
||||
|
||||
## Deployment Options
|
||||
|
||||
Choose your storage method based on your needs:
|
||||
|
||||
<Tabs items={['Named Volumes (Recommended)', 'Bind Mounts']}>
|
||||
<Tab value="Named Volumes (Recommended)">
|
||||
Docker-managed storage that provides the best balance of performance, security, and ease of use:
|
||||
|
||||
- **No Permission Issues**: Docker handles all permission management automatically
|
||||
- **Performance**: Optimized for container workloads with better I/O performance
|
||||
- **Production Ready**: Recommended for production deployments
|
||||
|
||||
### Configuration
|
||||
|
||||
Create a `docker-compose.yml` file:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
palmr:
|
||||
image: kyantech/palmr:latest
|
||||
container_name: palmr
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "5487:5487" # Web interface
|
||||
# - "3333:3333" # API (optional)
|
||||
environment:
|
||||
# Optional: Uncomment and configure as needed (if you don`t use, you can remove)
|
||||
# - ENABLE_S3=true # Set to true to enable S3-compatible storage
|
||||
# - DISABLE_FILESYSTEM_ENCRYPTION=true # Set to false to enable file encryption
|
||||
# - ENCRYPTION_KEY=your-secure-key-min-32-chars # Required only if encryption is enabled
|
||||
# - PALMR_UID=1000 # UID for the container processes (default is 1000)
|
||||
# - PALMR_GID=1000 # GID for the container processes (default is 1000)
|
||||
# - SECURE_SITE=false # Set to true if you are using a reverse proxy
|
||||
# - DEFAULT_LANGUAGE=en-US # Default language for the application (optional, defaults to en-US)
|
||||
# - PRESIGNED_URL_EXPIRATION=3600 # Duration in seconds for presigned URL expiration (optional, defaults to 3600 seconds / 1 hour)
|
||||
# - DOWNLOAD_MAX_CONCURRENT=5 # Maximum simultaneous downloads (auto-scales if not set)
|
||||
# - DOWNLOAD_MEMORY_THRESHOLD_MB=2048 # Memory threshold in MB before throttling (auto-scales if not set)
|
||||
# - DOWNLOAD_QUEUE_SIZE=25 # Maximum queue size for pending downloads (auto-scales if not set)
|
||||
# - DOWNLOAD_MIN_FILE_SIZE_GB=3.0 # Minimum file size in GB to activate memory management (default: 3.0)
|
||||
# - DOWNLOAD_AUTO_SCALE=true # Enable auto-scaling based on system memory (default: true)
|
||||
# - NODE_OPTIONS=--expose-gc # Enable garbage collection for large downloads (recommended for production)
|
||||
volumes:
|
||||
- palmr_data:/app/server
|
||||
|
||||
volumes:
|
||||
palmr_data:
|
||||
```
|
||||
|
||||
<Callout type="info">
|
||||
**Having upload or permission issues?** Add `PALMR_UID=1000` and `PALMR_GID=1000` to your environment variables. Check our [UID/GID Configuration](/docs/3.2-beta/uid-gid-configuration) guide for more details.
|
||||
</Callout>
|
||||
|
||||
### Deploy
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
</Tab>
|
||||
<Tab value="Bind Mounts">
|
||||
Direct mapping to host filesystem directories, providing direct file access:
|
||||
|
||||
- **Direct Access**: Files are directly accessible from your host system
|
||||
- **Development Friendly**: Easy to inspect, modify, or backup files manually
|
||||
- **Platform Dependent**: May require UID/GID configuration, especially on NAS systems
|
||||
|
||||
### Configuration
|
||||
|
||||
Create a `docker-compose.yml` file:
|
||||
|
||||
```yaml
|
||||
services:
|
||||
palmr:
|
||||
image: kyantech/palmr:latest
|
||||
container_name: palmr
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "5487:5487" # Web interface
|
||||
# - "3333:3333" # API (optional)
|
||||
environment:
|
||||
# Optional: Uncomment and configure as needed (if you don`t use, you can remove)
|
||||
# - ENABLE_S3=true # Set to true to enable S3-compatible storage
|
||||
# - DISABLE_FILESYSTEM_ENCRYPTION=false # Set to false to enable file encryption
|
||||
# - ENCRYPTION_KEY=your-secure-key-min-32-chars # Required only if encryption is enabled
|
||||
# - PALMR_UID=1000 # UID for the container processes (default is 1000)
|
||||
# - PALMR_GID=1000 # GID for the container processes (default is 1000)
|
||||
# - SECURE_SITE=false # Set to true if you are using a reverse proxy
|
||||
# - DEFAULT_LANGUAGE=en-US # Default language for the application (optional, defaults to en-US)
|
||||
# - PRESIGNED_URL_EXPIRATION=3600 # Duration in seconds for presigned URL expiration (optional, defaults to 3600 seconds / 1 hour)
|
||||
# - DOWNLOAD_MAX_CONCURRENT=5 # Maximum simultaneous downloads (auto-scales if not set)
|
||||
# - DOWNLOAD_MEMORY_THRESHOLD_MB=2048 # Memory threshold in MB before throttling (auto-scales if not set)
|
||||
# - DOWNLOAD_QUEUE_SIZE=25 # Maximum queue size for pending downloads (auto-scales if not set)
|
||||
# - DOWNLOAD_MIN_FILE_SIZE_GB=3.0 # Minimum file size in GB to activate memory management (default: 3.0)
|
||||
# - DOWNLOAD_AUTO_SCALE=true # Enable auto-scaling based on system memory (default: true)
|
||||
# - NODE_OPTIONS=--expose-gc # Enable garbage collection for large downloads (recommended for production)
|
||||
volumes:
|
||||
- ./data:/app/server
|
||||
```
|
||||
|
||||
<Callout type="info">
|
||||
**Having upload or permission issues?** Add `PALMR_UID=1000` and `PALMR_GID=1000` to your environment variables. Check our [UID/GID Configuration](/docs/3.2-beta/uid-gid-configuration) guide for more details.
|
||||
</Callout>
|
||||
|
||||
### Deploy
|
||||
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
## Configuration
|
||||
|
||||
Customize Palmr's behavior with these environment variables:
|
||||
|
||||
| Variable | Default | Description |
|
||||
| ------------------------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------- |
|
||||
| `ENABLE_S3` | `false` | Enable S3-compatible storage backends |
|
||||
| `S3_ENDPOINT` | - | S3 server endpoint URL (required when using S3) |
|
||||
| `S3_PORT` | - | S3 server port (optional when using S3) |
|
||||
| `S3_USE_SSL` | - | Enable SSL for S3 connections (optional when using S3) |
|
||||
| `S3_ACCESS_KEY` | - | S3 access key for authentication (required when using S3) |
|
||||
| `S3_SECRET_KEY` | - | S3 secret key for authentication (required when using S3) |
|
||||
| `S3_REGION` | - | S3 region configuration (optional when using S3) |
|
||||
| `S3_BUCKET_NAME` | - | S3 bucket name for file storage (required when using S3) |
|
||||
| `S3_FORCE_PATH_STYLE` | `false` | Force path-style S3 URLs (optional when using S3) |
|
||||
| `S3_REJECT_UNAUTHORIZED` | `true` | Enable strict SSL certificate validation for S3 (set to `false` for self-signed certificates) |
|
||||
| `ENCRYPTION_KEY` | - | **Required when encryption is enabled**: 32+ character key for file encryption |
|
||||
| `DISABLE_FILESYSTEM_ENCRYPTION` | `true` | Disable file encryption for better performance (set to `false` to enable encryption) |
|
||||
| `PRESIGNED_URL_EXPIRATION` | `3600` | Duration in seconds for presigned URL expiration (applies to both filesystem and S3 storage) |
|
||||
| `CUSTOM_PATH` | - | Custom base path for disk space detection in manual installations with symlinks |
|
||||
| `SECURE_SITE` | `false` | Enable secure cookies for HTTPS/reverse proxy deployments |
|
||||
| `DEFAULT_LANGUAGE` | `en-US` | Default application language ([see available languages](/docs/3.2-beta/available-languages)) |
|
||||
| `PALMR_UID` | `1000` | User ID for container processes (helps with file permissions) |
|
||||
| `PALMR_GID` | `1000` | Group ID for container processes (helps with file permissions) |
|
||||
| `NODE_OPTIONS` | - | Node.js options (recommended: `--expose-gc` for garbage collection in production) |
|
||||
| `DOWNLOAD_MAX_CONCURRENT` | auto-scale | Maximum number of simultaneous downloads (see [Download Memory Management](/docs/3.2-beta/download-memory-management)) |
|
||||
| `DOWNLOAD_MEMORY_THRESHOLD_MB` | auto-scale | Memory threshold in MB before throttling |
|
||||
| `DOWNLOAD_QUEUE_SIZE` | auto-scale | Maximum queue size for pending downloads |
|
||||
| `DOWNLOAD_MIN_FILE_SIZE_GB` | `3.0` | Minimum file size in GB to activate memory management |
|
||||
| `DOWNLOAD_AUTO_SCALE` | `true` | Enable auto-scaling based on system memory |
|
||||
|
||||
<Callout type="info">
|
||||
**Performance First**: Palmr runs without encryption by default for optimal speed and lower resource usage—perfect for
|
||||
most use cases.
|
||||
</Callout>
|
||||
|
||||
<Callout type="warn">
|
||||
**Encryption Notice**: To enable encryption, set `DISABLE_FILESYSTEM_ENCRYPTION=false` and provide a 32+ character
|
||||
`ENCRYPTION_KEY`. **Important**: This choice is permanent—switching encryption modes after uploading files will break
|
||||
access to existing uploads.
|
||||
</Callout>
|
||||
|
||||
<Callout>
|
||||
**Using a Reverse Proxy?** Set `SECURE_SITE=true` and check our [Reverse Proxy
|
||||
Configuration](/docs/3.2-beta/reverse-proxy-configuration) guide for proper HTTPS setup.
|
||||
</Callout>
|
||||
|
||||
### Generate Encryption Keys (Optional)
|
||||
|
||||
Need file encryption? Generate a secure key:
|
||||
|
||||
<KeyGenerator />
|
||||
|
||||
> **Pro Tip**: Only enable encryption if you're handling sensitive data. For most users, the default unencrypted mode provides better performance.
|
||||
|
||||
## Access Your Instance
|
||||
|
||||
Once deployed, open Palmr in your browser:
|
||||
|
||||
- **Web Interface**: `http://localhost:5487` (local) or `http://YOUR_SERVER_IP:5487` (remote)
|
||||
- **API Documentation**: `http://localhost:3333/docs` (if port 3333 is exposed)
|
||||
|
||||
<Callout type="info">
|
||||
**Learn More**: For complete API documentation, authentication, and integration examples, see our [API
|
||||
Reference](/docs/3.2-beta/api) guide
|
||||
</Callout>
|
||||
|
||||
<Callout type="warn">
|
||||
**Production Ready?** Configure HTTPS with a valid SSL certificate for secure production deployments.
|
||||
</Callout>
|
||||
|
||||
---
|
||||
|
||||
## Docker CLI Alternative
|
||||
|
||||
Prefer Docker commands over Compose? Here are the equivalent commands:
|
||||
|
||||
<Tabs items={["Named Volume", "Bind Mount"]}>
|
||||
<Tab value="Named Volume">
|
||||
|
||||
```bash
|
||||
docker run -d \
|
||||
--name palmr \
|
||||
# Optional: Uncomment and configure as needed (if you don`t use, you can remove)
|
||||
# -e ENABLE_S3=true \ # Set to true to enable S3-compatible storage (OPTIONAL - default is false)
|
||||
# -e DISABLE_FILESYSTEM_ENCRYPTION=false \ # Set to false to enable file encryption (ENCRYPTION_KEY becomes required) | (OPTIONAL - default is true)
|
||||
# -e ENCRYPTION_KEY=your-secure-key-min-32-chars # Required only if encryption is enabled
|
||||
# -e PALMR_UID=1000 # UID for the container processes (default is 1000)
|
||||
# -e PALMR_GID=1000 # GID for the container processes (default is 1000)
|
||||
# -e SECURE_SITE=false # Set to true if you are using a reverse proxy
|
||||
# -e DEFAULT_LANGUAGE=en-US # Default language for the application (optional, defaults to en-US)
|
||||
-p 5487:5487 \
|
||||
-p 3333:3333 \
|
||||
-v palmr_data:/app/server \
|
||||
--restart unless-stopped \
|
||||
kyantech/palmr:latest
|
||||
```
|
||||
|
||||
|
||||
<Callout type="info">
|
||||
**Permission Issues?** Add `-e PALMR_UID=1000 -e PALMR_GID=1000` to the command above. See our [UID/GID Configuration](/docs/3.2-beta/uid-gid-configuration) guide for details.
|
||||
</Callout>
|
||||
|
||||
</Tab>
|
||||
|
||||
<Tab value="Bind Mount">
|
||||
|
||||
```bash
|
||||
docker run -d \
|
||||
--name palmr \
|
||||
# Optional: Uncomment and configure as needed (if you don`t use, you can remove)
|
||||
# -e ENABLE_S3=true \ # Set to true to enable S3-compatible storage (OPTIONAL - default is false)
|
||||
# -e DISABLE_FILESYSTEM_ENCRYPTION=true \ # Set to false to enable file encryption (ENCRYPTION_KEY becomes required) | (OPTIONAL - default is true)
|
||||
# -e ENCRYPTION_KEY=your-secure-key-min-32-chars # Required only if encryption is enabled
|
||||
# -e PALMR_UID=1000 # UID for the container processes (default is 1000)
|
||||
# -e PALMR_GID=1000 # GID for the container processes (default is 1000)
|
||||
# -e SECURE_SITE=false # Set to true if you are using a reverse proxy
|
||||
# -e DEFAULT_LANGUAGE=en-US # Default language for the application (optional, defaults to en-US)
|
||||
-p 5487:5487 \
|
||||
-p 3333:3333 \
|
||||
-v $(pwd)/data:/app/server \
|
||||
--restart unless-stopped \
|
||||
kyantech/palmr:latest
|
||||
```
|
||||
|
||||
<Callout type="info">
|
||||
**Permission Issues?** Add `-e PALMR_UID=1000 -e PALMR_GID=1000` to the command above. See our [UID/GID Configuration](/docs/3.2-beta/uid-gid-configuration) guide for details.
|
||||
</Callout>
|
||||
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
---
|
||||
|
||||
## Common Configuration Options
|
||||
|
||||
### Presigned URL Expiration
|
||||
|
||||
Palmr. uses temporary URLs (presigned URLs) for secure file access. These URLs expire after a configurable time period to enhance security.
|
||||
|
||||
**Default:** 1 hour (3600 seconds)
|
||||
|
||||
You can customize this for all storage types (filesystem or S3) by adding:
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
- PRESIGNED_URL_EXPIRATION=7200 # 2 hours
|
||||
```
|
||||
|
||||
**When to adjust:**
|
||||
|
||||
- **Shorter time (1800 = 30 min):** Higher security, but users may need to refresh download links
|
||||
- **Longer time (7200-21600 = 2-6 hours):** Better for large file transfers, but URLs stay valid longer
|
||||
- **Default (3600 = 1 hour):** Good balance for most use cases
|
||||
|
||||
### File Encryption
|
||||
|
||||
For filesystem storage, you can enable file encryption:
|
||||
|
||||
```yaml
|
||||
environment:
|
||||
- DISABLE_FILESYSTEM_ENCRYPTION=false
|
||||
- ENCRYPTION_KEY=your-secure-32-character-key-here
|
||||
```
|
||||
|
||||
**Note:** S3 storage handles encryption through your S3 provider's encryption features.
|
||||
|
||||
---
|
||||
|
||||
## Maintenance
|
||||
|
||||
### Updates
|
||||
|
||||
Keep Palmr up to date with the latest features and security patches:
|
||||
|
||||
```bash
|
||||
docker-compose pull
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### Backup Your Data
|
||||
|
||||
**Named Volumes:**
|
||||
|
||||
```bash
|
||||
docker run --rm -v palmr_data:/data -v $(pwd):/backup alpine tar czf /backup/palmr-backup.tar.gz -C /data .
|
||||
```
|
||||
|
||||
**Bind Mounts:**
|
||||
|
||||
```bash
|
||||
tar czf palmr-backup.tar.gz ./data
|
||||
```
|
||||
|
||||
### Restore From Backup
|
||||
|
||||
**Named Volumes:**
|
||||
|
||||
```bash
|
||||
docker-compose down
|
||||
docker run --rm -v palmr_data:/data -v $(pwd):/backup alpine tar xzf /backup/palmr-backup.tar.gz -C /data
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
**Bind Mounts:**
|
||||
|
||||
```bash
|
||||
docker-compose down
|
||||
tar xzf palmr-backup.tar.gz
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## What's Next?
|
||||
|
||||
Your Palmr instance is ready! Here's what you can explore:
|
||||
|
||||
### Advanced Configuration
|
||||
|
||||
- **[UID/GID Configuration](/docs/3.2-beta/uid-gid-configuration)** - Configure user permissions for NAS systems and custom environments
|
||||
- **[Download Memory Management](/docs/3.2-beta/download-memory-management)** - Configure large file download handling and queue system
|
||||
- **[S3 Storage](/docs/3.2-beta/s3-configuration)** - Scale with Amazon S3 or compatible storage providers
|
||||
- **[Manual Installation](/docs/3.2-beta/manual-installation)** - Manual installation and custom configurations
|
||||
|
||||
### Integration & Development
|
||||
|
||||
- **[API Reference](/docs/3.2-beta/api)** - Integrate Palmr. with your applications
|
||||
|
||||
<Callout type="info">
|
||||
**Need help?** Check our [Troubleshooting Guide](/docs/3.2-beta/troubleshooting) for common issues and solutions.
|
||||
</Callout>
|
||||
|
||||
---
|
||||
|
||||
**Questions?** Visit our [GitHub Issues](https://github.com/kyantech/Palmr/issues) or join the community discussions.
|
@@ -127,10 +127,11 @@ proxy_pass_header Set-Cookie;
|
||||
environment:
|
||||
- PALMR_UID=1000 # Your host UID (check with: id)
|
||||
- PALMR_GID=1000 # Your host GID
|
||||
- ENCRYPTION_KEY=your-key-here
|
||||
- DISABLE_FILESYSTEM_ENCRYPTION=true # Set to false to enable file encryption
|
||||
# - ENCRYPTION_KEY=your-key-here # Required only if encryption is enabled
|
||||
```
|
||||
|
||||
> **💡 Note**: Check your host UID/GID with `id` command and use those values. See [UID/GID Configuration](/docs/3.1-beta/uid-gid-configuration) for detailed setup.
|
||||
> **💡 Note**: Check your host UID/GID with `id` command and use those values. See [UID/GID Configuration](/docs/3.2-beta/uid-gid-configuration) for detailed setup.
|
||||
|
||||
---
|
||||
|
@@ -7,6 +7,8 @@ This guide provides comprehensive configuration instructions for integrating Pal
|
||||
|
||||
> **Overview:** Palmr. supports any S3-compatible storage provider, giving you flexibility to choose the solution that best fits your needs and budget.
|
||||
|
||||
> **Note:** Some configuration options (like presigned URL expiration) apply to **all storage types**, including filesystem storage. These are marked accordingly in the documentation.
|
||||
|
||||
## When to use S3-compatible storage
|
||||
|
||||
Consider using S3-compatible storage when you need:
|
||||
@@ -19,18 +21,27 @@ Consider using S3-compatible storage when you need:
|
||||
|
||||
## Environment variables
|
||||
|
||||
### General configuration (applies to all storage types)
|
||||
|
||||
| Variable | Description | Required | Default |
|
||||
| -------------------------- | ------------------------------------------------ | -------- | --------------- |
|
||||
| `PRESIGNED_URL_EXPIRATION` | Duration in seconds for presigned URL expiration | No | `3600` (1 hour) |
|
||||
|
||||
### S3-specific configuration
|
||||
|
||||
To enable S3-compatible storage, set `ENABLE_S3=true` and configure the following environment variables:
|
||||
|
||||
| Variable | Description | Required | Default |
|
||||
| --------------------- | ----------------------------- | -------- | ----------------- |
|
||||
| `S3_ENDPOINT` | S3 provider endpoint URL | Yes | - |
|
||||
| `S3_PORT` | Connection port | No | Based on protocol |
|
||||
| `S3_USE_SSL` | Enable SSL/TLS encryption | Yes | `true` |
|
||||
| `S3_ACCESS_KEY` | Access key for authentication | Yes | - |
|
||||
| `S3_SECRET_KEY` | Secret key for authentication | Yes | - |
|
||||
| `S3_REGION` | Storage region | Yes | - |
|
||||
| `S3_BUCKET_NAME` | Bucket/container name | Yes | - |
|
||||
| `S3_FORCE_PATH_STYLE` | Use path-style URLs | No | `false` |
|
||||
| Variable | Description | Required | Default |
|
||||
| ------------------------ | ---------------------------------------- | -------- | ----------------- |
|
||||
| `S3_ENDPOINT` | S3 provider endpoint URL | Yes | - |
|
||||
| `S3_PORT` | Connection port | No | Based on protocol |
|
||||
| `S3_USE_SSL` | Enable SSL/TLS encryption | Yes | `true` |
|
||||
| `S3_ACCESS_KEY` | Access key for authentication | Yes | - |
|
||||
| `S3_SECRET_KEY` | Secret key for authentication | Yes | - |
|
||||
| `S3_REGION` | Storage region | Yes | - |
|
||||
| `S3_BUCKET_NAME` | Bucket/container name | Yes | - |
|
||||
| `S3_FORCE_PATH_STYLE` | Use path-style URLs | No | `false` |
|
||||
| `S3_REJECT_UNAUTHORIZED` | Enable strict SSL certificate validation | No | `true` |
|
||||
|
||||
## Provider configurations
|
||||
|
||||
@@ -51,6 +62,7 @@ S3_SECRET_KEY=your-secret-access-key
|
||||
S3_REGION=us-east-1
|
||||
S3_BUCKET_NAME=your-bucket-name
|
||||
S3_FORCE_PATH_STYLE=false
|
||||
# PRESIGNED_URL_EXPIRATION=3600 # Optional: 1 hour (default)
|
||||
```
|
||||
|
||||
**Getting credentials:**
|
||||
@@ -81,6 +93,21 @@ S3_FORCE_PATH_STYLE=true
|
||||
- Default MinIO port is 9000
|
||||
- SSL can be disabled for local development
|
||||
|
||||
**For MinIO with self-signed SSL certificates:**
|
||||
|
||||
```bash
|
||||
ENABLE_S3=true
|
||||
S3_ENDPOINT=your-minio-domain.com
|
||||
S3_PORT=9000
|
||||
S3_USE_SSL=true
|
||||
S3_ACCESS_KEY=your-minio-access-key
|
||||
S3_SECRET_KEY=your-minio-secret-key
|
||||
S3_REGION=us-east-1
|
||||
S3_BUCKET_NAME=your-bucket-name
|
||||
S3_FORCE_PATH_STYLE=true
|
||||
S3_REJECT_UNAUTHORIZED=false # Allows self-signed certificates
|
||||
```
|
||||
|
||||
### Google Cloud Storage
|
||||
|
||||
Google Cloud Storage offers competitive pricing and global infrastructure.
|
||||
@@ -137,6 +164,7 @@ S3_SECRET_KEY=your-application-key
|
||||
S3_REGION=us-west-002
|
||||
S3_BUCKET_NAME=your-bucket-name
|
||||
S3_FORCE_PATH_STYLE=false
|
||||
# PRESIGNED_URL_EXPIRATION=7200 # Optional: 2 hours for large files
|
||||
```
|
||||
|
||||
**Cost advantage:**
|
||||
@@ -187,6 +215,93 @@ S3_FORCE_PATH_STYLE=false
|
||||
- Use container name as bucket name
|
||||
- Configure appropriate access policies
|
||||
|
||||
## Presigned URL configuration
|
||||
|
||||
Palmr. uses presigned URLs to provide secure, temporary access to files stored in **both S3-compatible storage and filesystem storage**. These URLs have a configurable expiration time to balance security and usability.
|
||||
|
||||
> **Note:** This configuration applies to **all storage types** (S3, filesystem, etc.), not just S3-compatible storage.
|
||||
|
||||
### Understanding presigned URLs
|
||||
|
||||
Presigned URLs are temporary URLs that allow direct access to files without exposing storage credentials or requiring authentication. They automatically expire after a specified time period, enhancing security by limiting access duration.
|
||||
|
||||
**How it works:**
|
||||
|
||||
- **S3 Storage:** URLs are signed by AWS/S3-compatible provider credentials
|
||||
- **Filesystem Storage:** URLs use temporary tokens that are validated by Palmr server
|
||||
|
||||
**Default behavior:**
|
||||
|
||||
- Upload URLs: 1 hour (3600 seconds)
|
||||
- Download URLs: 1 hour (3600 seconds)
|
||||
|
||||
### Configuring expiration time
|
||||
|
||||
You can customize the expiration time using the `PRESIGNED_URL_EXPIRATION` environment variable:
|
||||
|
||||
```bash
|
||||
# Set URLs to expire after 2 hours (7200 seconds)
|
||||
PRESIGNED_URL_EXPIRATION=7200
|
||||
|
||||
# Set URLs to expire after 30 minutes (1800 seconds)
|
||||
PRESIGNED_URL_EXPIRATION=1800
|
||||
|
||||
# Set URLs to expire after 6 hours (21600 seconds)
|
||||
PRESIGNED_URL_EXPIRATION=21600
|
||||
```
|
||||
|
||||
### Choosing the right expiration time
|
||||
|
||||
**Shorter expiration (15-30 minutes):**
|
||||
|
||||
- [+] Higher security
|
||||
- [+] Reduced risk of unauthorized access
|
||||
- [-] May interrupt long uploads/downloads
|
||||
- [-] Users may need to refresh links more often
|
||||
|
||||
**Longer expiration (2-6 hours):**
|
||||
|
||||
- [+] Better user experience for large files
|
||||
- [+] Fewer interruptions during transfers
|
||||
- [-] Longer exposure window if URLs are compromised
|
||||
- [-] Potential for increased storage costs if users leave downloads incomplete
|
||||
|
||||
**Recommended settings:**
|
||||
|
||||
- **High security environments:** 1800 seconds (30 minutes)
|
||||
- **Standard usage:** 3600 seconds (1 hour) - default
|
||||
- **Large file transfers:** 7200-21600 seconds (2-6 hours)
|
||||
|
||||
### Example configurations
|
||||
|
||||
**For Backblaze B2 with extended expiration:**
|
||||
|
||||
```bash
|
||||
ENABLE_S3=true
|
||||
S3_ENDPOINT=s3.us-west-002.backblazeb2.com
|
||||
S3_USE_SSL=true
|
||||
S3_ACCESS_KEY=your-key-id
|
||||
S3_SECRET_KEY=your-application-key
|
||||
S3_REGION=us-west-002
|
||||
S3_BUCKET_NAME=your-bucket-name
|
||||
S3_FORCE_PATH_STYLE=false
|
||||
PRESIGNED_URL_EXPIRATION=7200 # 2 hours for large file transfers
|
||||
```
|
||||
|
||||
**For high-security environments:**
|
||||
|
||||
```bash
|
||||
ENABLE_S3=true
|
||||
S3_ENDPOINT=s3.amazonaws.com
|
||||
S3_USE_SSL=true
|
||||
S3_ACCESS_KEY=your-access-key-id
|
||||
S3_SECRET_KEY=your-secret-access-key
|
||||
S3_REGION=us-east-1
|
||||
S3_BUCKET_NAME=your-bucket-name
|
||||
S3_FORCE_PATH_STYLE=false
|
||||
PRESIGNED_URL_EXPIRATION=1800 # 30 minutes for enhanced security
|
||||
```
|
||||
|
||||
## Configuration best practices
|
||||
|
||||
### Security considerations
|
||||
@@ -212,6 +327,19 @@ S3_FORCE_PATH_STYLE=false
|
||||
- Check firewall and network connectivity
|
||||
- Ensure SSL/TLS settings match provider requirements
|
||||
|
||||
**SSL certificate errors (self-signed certificates):**
|
||||
|
||||
If you encounter errors like `unable to verify the first certificate` or `UNABLE_TO_VERIFY_LEAF_SIGNATURE`, you're likely using self-signed SSL certificates. This is common with self-hosted MinIO or other S3-compatible services.
|
||||
|
||||
**Solution:**
|
||||
Set `S3_REJECT_UNAUTHORIZED=false` in your environment variables to allow self-signed certificates:
|
||||
|
||||
```bash
|
||||
S3_REJECT_UNAUTHORIZED=false
|
||||
```
|
||||
|
||||
**Note:** SSL certificate validation is enabled by default (`true`) for security. Set it to `false` only when using self-hosted S3 services with self-signed certificates.
|
||||
|
||||
**Authentication failures:**
|
||||
|
||||
- Confirm access key and secret key are correct
|
@@ -44,7 +44,7 @@ The central hub after login, providing an overview of recent activity, quick act
|
||||
|
||||
### Files list view
|
||||
|
||||
Comprehensive file browser displaying all uploaded files in a detailed list format with metadata, actions, and sorting options.
|
||||
Comprehensive file browser displaying all uploaded files in a detailed list format with metadata, actions, sorting options, and folder navigation.
|
||||
|
||||
<ZoomableImage
|
||||
src="/assets/v3/screenshots/files-list.png"
|
||||
@@ -53,7 +53,7 @@ Comprehensive file browser displaying all uploaded files in a detailed list form
|
||||
|
||||
### Files card view
|
||||
|
||||
Alternative file browser layout showing files as visual cards, perfect for quick browsing and visual file identification.
|
||||
Alternative file browser layout showing files as visual cards, perfect for quick browsing, visual file identification, and folder navigation.
|
||||
|
||||
<ZoomableImage
|
||||
src="/assets/v3/screenshots/files-card.png"
|
||||
@@ -73,7 +73,7 @@ File upload interface where users can drag and drop or select files to upload to
|
||||
|
||||
### Shares page
|
||||
|
||||
Management interface for all shared files and folders, showing share status, permissions, and access controls.
|
||||
Management interface for all shared files and folders, showing share status, permissions, and access controls for both individual files and folders.
|
||||
|
||||
<ZoomableImage
|
||||
src="/assets/v3/screenshots/shares.png"
|
@@ -17,7 +17,7 @@ docker-compose logs palmr | grep -i "permission\|denied\|eacces"
|
||||
|
||||
# Common error messages:
|
||||
# EACCES: permission denied, open '/app/server/uploads/file.txt'
|
||||
# Error: EACCES: permission denied, mkdir '/app/server/temp-chunks'
|
||||
# Error: EACCES: permission denied, mkdir '/app/server/temp-uploads'
|
||||
```
|
||||
|
||||
### The Root Cause
|
||||
@@ -25,7 +25,7 @@ docker-compose logs palmr | grep -i "permission\|denied\|eacces"
|
||||
**Palmr. defaults**: UID 1001, GID 1001
|
||||
**Linux standard**: UID 1000, GID 1000
|
||||
|
||||
When using bind mounts, your host directories are owned by UID 1000, but Palmr. runs as UID 1001.
|
||||
When using bind mounts, your host directories may have different ownership than Palmr's default UID/GID.
|
||||
|
||||
### Solution 1: Environment Variables (Recommended)
|
||||
|
||||
@@ -63,8 +63,8 @@ If you prefer to keep Palmr's defaults:
|
||||
chown -R 1001:1001 ./data
|
||||
|
||||
# For separate upload/temp directories
|
||||
mkdir -p uploads temp-chunks
|
||||
chown -R 1001:1001 uploads temp-chunks
|
||||
mkdir -p uploads temp-uploads
|
||||
chown -R 1001:1001 uploads temp-uploads
|
||||
```
|
||||
|
||||
### Solution 3: Docker Volume (Avoid the Issue)
|
||||
@@ -109,16 +109,19 @@ docker-compose logs palmr
|
||||
2. **Invalid encryption key**
|
||||
|
||||
```bash
|
||||
# Error: Encryption key must be at least 32 characters
|
||||
# Fix: Update ENCRYPTION_KEY in docker-compose.yaml
|
||||
# Error: Encryption key must be at least 32 characters (only if encryption is enabled)
|
||||
# Fix: Either disable encryption or provide a valid key
|
||||
environment:
|
||||
- ENCRYPTION_KEY=your-very-long-secure-key-at-least-32-characters
|
||||
- DISABLE_FILESYSTEM_ENCRYPTION=true # Disable encryption (default)
|
||||
# OR enable encryption with:
|
||||
# - DISABLE_FILESYSTEM_ENCRYPTION=false
|
||||
# - ENCRYPTION_KEY=your-very-long-secure-key-at-least-32-characters
|
||||
```
|
||||
|
||||
3. **Missing environment variables**
|
||||
```bash
|
||||
# Check required variables are set
|
||||
docker exec palmr env | grep -E "ENCRYPTION_KEY|DATABASE_URL"
|
||||
# Check variables are set (encryption is optional)
|
||||
docker exec palmr env | grep -E "DISABLE_FILESYSTEM_ENCRYPTION|ENCRYPTION_KEY|DATABASE_URL"
|
||||
```
|
||||
|
||||
### Container Starts But App Doesn't Load
|
||||
@@ -151,7 +154,7 @@ curl http://localhost:3333/health
|
||||
|
||||
```bash
|
||||
docker exec palmr ls -la /app/server/uploads/
|
||||
# Should show ownership by palmr user
|
||||
# Should show ownership by palmr user (UID 1001)
|
||||
```
|
||||
|
||||
3. **Check upload limits:**
|
||||
@@ -178,13 +181,13 @@ docker exec palmr stat /app/server/uploads/your-file.txt
|
||||
|
||||
```bash
|
||||
# Using the built-in reset script
|
||||
docker exec -it palmr /app/reset-password.sh
|
||||
docker exec -it palmr /app/palmr-app/reset-password.sh
|
||||
```
|
||||
|
||||
2. **Check database permissions:**
|
||||
```bash
|
||||
docker exec palmr ls -la /app/server/prisma/
|
||||
# palmr.db should be writable by palmr user
|
||||
# palmr.db should be writable by palmr user (UID 1001)
|
||||
```
|
||||
|
||||
### OIDC Authentication Not Working
|
||||
@@ -243,8 +246,8 @@ docker exec palmr ls -la /app/server/prisma/palmr.db
|
||||
# Check database logs
|
||||
docker-compose logs palmr | grep -i database
|
||||
|
||||
# Verify Prisma schema
|
||||
docker exec palmr npx prisma db push --schema=./prisma/schema.prisma
|
||||
# Verify Prisma schema (run from palmr-app directory)
|
||||
docker exec palmr sh -c "cd /app/palmr-app && npx prisma db push"
|
||||
```
|
||||
|
||||
### Database Corruption
|
||||
@@ -283,7 +286,7 @@ docker-compose up -d
|
||||
|
||||
3. **Check temp directory permissions:**
|
||||
```bash
|
||||
docker exec palmr ls -la /app/server/temp-chunks/
|
||||
docker exec palmr ls -la /app/server/temp-uploads/
|
||||
```
|
||||
|
||||
### High Memory Usage
|
||||
@@ -318,16 +321,19 @@ docker port palmr
|
||||
echo "4. File Permissions:"
|
||||
docker exec palmr ls -la /app/server/
|
||||
|
||||
echo "5. Environment Variables:"
|
||||
docker exec palmr env | grep -E "PALMR_|ENCRYPTION_|DATABASE_"
|
||||
echo "5. Application Files:"
|
||||
docker exec palmr ls -la /app/palmr-app/
|
||||
|
||||
echo "6. API Health:"
|
||||
echo "6. Environment Variables:"
|
||||
docker exec palmr env | grep -E "PALMR_|DISABLE_FILESYSTEM_ENCRYPTION|ENCRYPTION_|DATABASE_"
|
||||
|
||||
echo "7. API Health:"
|
||||
curl -s http://localhost:3333/health || echo "API not accessible"
|
||||
|
||||
echo "7. Web Interface:"
|
||||
echo "8. Web Interface:"
|
||||
curl -s -o /dev/null -w "%{http_code}" http://localhost:5487 || echo "Web interface not accessible"
|
||||
|
||||
echo "8. Disk Space:"
|
||||
echo "9. Disk Space:"
|
||||
df -h
|
||||
|
||||
echo "=== End Health Check ==="
|
||||
@@ -360,13 +366,11 @@ If none of these solutions work:
|
||||
```
|
||||
|
||||
2. **Check our documentation:**
|
||||
|
||||
- [UID/GID Configuration](/docs/3.0-beta/uid-gid-configuration)
|
||||
- [Quick Start Guide](/docs/3.0-beta/quick-start)
|
||||
- [API Reference](/docs/3.0-beta/api)
|
||||
|
||||
3. **Open an issue on GitHub:**
|
||||
|
||||
- Include your `docker-compose.yaml`
|
||||
- Include relevant log output
|
||||
- Describe your system (OS, Docker version, etc.)
|
@@ -9,15 +9,15 @@ Configure user and group permissions for seamless bind mount compatibility acros
|
||||
|
||||
Palmr. supports runtime UID/GID configuration to resolve permission conflicts when using bind mounts. This eliminates the need for manual permission management on your host system.
|
||||
|
||||
**⚠️ Important**: Palmr uses **UID 1001, GID 1001** by default, which is different from the standard Linux convention of **UID 1000, GID 1000**. This is the most common cause of permission issues with bind mounts.
|
||||
**⚠️ Important**: Palmr uses **UID 1000, GID 1000** by default, which matches the standard Linux convention. However, some systems may use different UID/GID values, which can cause permission issues with bind mounts.
|
||||
|
||||
## The Permission Problem
|
||||
|
||||
### Why This Happens
|
||||
|
||||
- **Palmr Default**: UID 1001, GID 1001 (container)
|
||||
- **Palmr Default**: UID 1000, GID 1000 (container)
|
||||
- **Linux Standard**: UID 1000, GID 1000 (most host systems)
|
||||
- **Result**: Container can't write to host directories
|
||||
- **Result**: Usually compatible, but some systems may use different values
|
||||
|
||||
### Common Error Scenarios
|
||||
|
||||
@@ -30,7 +30,7 @@ EACCES: permission denied, open '/app/server/uploads/file.txt'
|
||||
# Or when checking permissions:
|
||||
$ ls -la uploads/
|
||||
drwxr-xr-x 2 user user 4096 Jan 15 10:00 uploads/
|
||||
# Container tries to write as UID 1001, but directory is owned by UID 1000
|
||||
# Container tries to write with different UID/GID than directory owner
|
||||
```
|
||||
|
||||
## Quick Fix
|
||||
@@ -45,15 +45,13 @@ services:
|
||||
image: kyantech/palmr:latest
|
||||
container_name: palmr
|
||||
environment:
|
||||
- ENABLE_S3=false
|
||||
- ENCRYPTION_KEY=your-secure-key-min-32-chars
|
||||
- PALMR_UID=1000
|
||||
- PALMR_GID=1000
|
||||
ports:
|
||||
- "5487:5487"
|
||||
volumes:
|
||||
- ./uploads:/app/server/uploads:rw
|
||||
- ./temp-chunks:/app/server/temp-chunks:rw
|
||||
- ./temp-uploads:/app/server/temp-uploads:rw
|
||||
restart: unless-stopped
|
||||
```
|
||||
|
||||
@@ -63,8 +61,8 @@ If you prefer to keep Palmr's defaults:
|
||||
|
||||
```bash
|
||||
# Create directories with correct ownership
|
||||
mkdir -p uploads temp-chunks
|
||||
chown -R 1001:1001 uploads temp-chunks
|
||||
mkdir -p uploads temp-uploads
|
||||
chown -R 1001:1001 uploads temp-uploads
|
||||
```
|
||||
|
||||
## Environment Variables
|
||||
@@ -104,8 +102,6 @@ services:
|
||||
image: kyantech/palmr:latest
|
||||
container_name: palmr
|
||||
environment:
|
||||
- ENABLE_S3=false
|
||||
- ENCRYPTION_KEY=your-secure-key-min-32-chars
|
||||
- PALMR_UID=1000
|
||||
- PALMR_GID=1000
|
||||
ports:
|
||||
@@ -123,8 +119,6 @@ services:
|
||||
image: kyantech/palmr:latest
|
||||
container_name: palmr
|
||||
environment:
|
||||
- ENABLE_S3=false
|
||||
- ENCRYPTION_KEY=your-secure-key-min-32-chars
|
||||
- PALMR_UID=1026
|
||||
- PALMR_GID=100
|
||||
ports:
|
||||
@@ -142,8 +136,6 @@ services:
|
||||
image: kyantech/palmr:latest
|
||||
container_name: palmr
|
||||
environment:
|
||||
- ENABLE_S3=false
|
||||
- ENCRYPTION_KEY=your-secure-key-min-32-chars
|
||||
- PALMR_UID=1000
|
||||
- PALMR_GID=100
|
||||
ports:
|
||||
@@ -166,7 +158,7 @@ services:
|
||||
id
|
||||
|
||||
# 2. Check directory ownership
|
||||
ls -la uploads/ temp-chunks/
|
||||
ls -la uploads/ temp-uploads/
|
||||
|
||||
# 3. Fix via environment variables (preferred)
|
||||
# Add to docker-compose.yaml:
|
||||
@@ -174,7 +166,7 @@ ls -la uploads/ temp-chunks/
|
||||
# - PALMR_GID=1000
|
||||
|
||||
# 4. Or fix via chown (alternative)
|
||||
chown -R 1001:1001 uploads temp-chunks
|
||||
chown -R 1001:1001 uploads temp-uploads
|
||||
```
|
||||
|
||||
**Error**: Container starts but files aren't accessible
|
||||
@@ -225,11 +217,11 @@ cat /etc/passwd | grep -v nobody
|
||||
```bash
|
||||
# Check if directories exist and are writable
|
||||
test -w uploads && echo "uploads writable" || echo "uploads NOT writable"
|
||||
test -w temp-chunks && echo "temp-chunks writable" || echo "temp-chunks NOT writable"
|
||||
test -w temp-uploads && echo "temp-uploads writable" || echo "temp-uploads NOT writable"
|
||||
|
||||
# Create directories with correct permissions
|
||||
mkdir -p uploads temp-chunks
|
||||
sudo chown -R $(id -u):$(id -g) uploads temp-chunks
|
||||
mkdir -p uploads temp-uploads
|
||||
sudo chown -R $(id -u):$(id -g) uploads temp-uploads
|
||||
```
|
||||
|
||||
---
|
||||
@@ -270,7 +262,7 @@ To add UID/GID configuration to running installations:
|
||||
cp -r ./data ./data-backup
|
||||
# or
|
||||
cp -r ./uploads ./uploads-backup
|
||||
cp -r ./temp-chunks ./temp-chunks-backup
|
||||
cp -r ./temp-uploads ./temp-uploads-backup
|
||||
```
|
||||
|
||||
3. **Check your UID/GID**
|
||||
@@ -344,4 +336,4 @@ For most users experiencing permission issues with bind mounts:
|
||||
```
|
||||
3. **Restart**: `docker-compose down && docker-compose up -d`
|
||||
|
||||
This resolves the mismatch between Palmr's default UID 1001 and the standard Linux UID 1000.
|
||||
This ensures compatibility between Palmr's UID/GID and your host system's file ownership.
|
@@ -1,3 +1,3 @@
|
||||
{
|
||||
"pages": ["3.1-beta", "2.0.0-beta"]
|
||||
"pages": ["3.2-beta", "2.0.0-beta"]
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "palmr-docs",
|
||||
"version": "v3.1.1-beta",
|
||||
"version": "3.2.1-beta",
|
||||
"description": "Docs for Palmr",
|
||||
"private": true,
|
||||
"author": "Daniel Luiz Alves <daniel@kyantech.com.br>",
|
||||
@@ -62,4 +62,4 @@
|
||||
"tw-animate-css": "^1.2.8",
|
||||
"typescript": "^5.8.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
4878
apps/docs/pnpm-lock.yaml
generated
4878
apps/docs/pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,5 @@
|
||||
"use client";
|
||||
|
||||
import type { ReactNode } from "react";
|
||||
import Link from "next/link";
|
||||
import {
|
||||
@@ -57,13 +59,13 @@ const images = [
|
||||
"https://res.cloudinary.com/technical-intelligence/image/upload/v1745546005/Palmr./profile_mizwvg.png",
|
||||
];
|
||||
|
||||
const docsLink = "/docs/3.1-beta";
|
||||
const docsLink = "/docs/3.2-beta";
|
||||
|
||||
function Hero() {
|
||||
return (
|
||||
<section className="relative z-[2] flex flex-col border-x border-t px-6 pt-12 pb-10 md:px-12 md:pt-16 max-md:text-center">
|
||||
<h1 className="mb-8 text-6xl font-bold">
|
||||
Palmr. <span className="text-[13px] font-light text-muted-foreground/50 font-mono">v3.1-beta</span>
|
||||
Palmr. <span className="text-[13px] font-light text-muted-foreground/50 font-mono">v3.2-beta</span>
|
||||
</h1>
|
||||
<h1 className="hidden text-4xl font-medium max-w-[600px] md:block mb-4">Modern & efficient file sharing</h1>
|
||||
<p className="mb-8 text-fd-muted-foreground md:max-w-[80%] md:text-xl">
|
||||
@@ -79,7 +81,6 @@ function Hero() {
|
||||
<Link href={docsLink}>Documentation</Link>
|
||||
</div>
|
||||
</PulsatingButton>
|
||||
|
||||
<RippleButton>
|
||||
<a
|
||||
href="https://github.com/kyantech/Palmr"
|
||||
@@ -293,7 +294,7 @@ function FullWidthFooter() {
|
||||
<div className="flex items-center gap-1 text-sm max-w-7xl">
|
||||
<span>Powered by</span>
|
||||
<Link
|
||||
href="http://kyantech.com.br"
|
||||
href="https://github.com/kyantech"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
className="flex items-center hover:text-green-700 text-green-500 transition-colors font-light"
|
||||
|
@@ -9,6 +9,6 @@ export const { GET } = createFromSource(source, (page) => {
|
||||
url: page.url,
|
||||
id: page.url,
|
||||
structuredData: page.data.structuredData,
|
||||
tag: page.url.startsWith("/docs/3.1-beta") ? "v3.1-beta" : "v2.0.0-beta",
|
||||
tag: page.url.startsWith("/docs/3.2-beta") ? "v3.2-beta" : "v2.0.0-beta",
|
||||
};
|
||||
});
|
||||
|
@@ -11,7 +11,7 @@ import { Sponsor } from "../components/sponsor";
|
||||
export default async function Page(props: { params: Promise<{ slug?: string[] }> }) {
|
||||
const params = await props.params;
|
||||
const page = source.getPage(params.slug);
|
||||
if (!page) redirect("/docs/3.1-beta");
|
||||
if (!page) redirect("/docs/3.2-beta");
|
||||
|
||||
const MDXContent = page.data.body;
|
||||
|
||||
@@ -49,7 +49,7 @@ export async function generateStaticParams() {
|
||||
export async function generateMetadata(props: { params: Promise<{ slug?: string[] }> }) {
|
||||
const params = await props.params;
|
||||
const page = source.getPage(params.slug);
|
||||
if (!page) redirect("/docs/3.1-beta");
|
||||
if (!page) redirect("/docs/3.2-beta");
|
||||
|
||||
return {
|
||||
title: page.data.title + " | Palmr. Docs",
|
||||
|
@@ -6,7 +6,7 @@ export function Footer() {
|
||||
<div className="flex items-center gap-1 text-sm ">
|
||||
<span>Powered by</span>
|
||||
<Link
|
||||
href="http://kyantech.com.br"
|
||||
href="https://github.com/kyantech"
|
||||
rel="noopener noreferrer"
|
||||
target="_blank"
|
||||
className="flex items-center hover:text-green-700 text-green-500 transition-colors font-light"
|
||||
|
@@ -28,7 +28,7 @@ export default function Layout({ children }: { children: ReactNode }) {
|
||||
<RootProvider
|
||||
search={{
|
||||
options: {
|
||||
defaultTag: "3.1-beta",
|
||||
defaultTag: "3.2-beta",
|
||||
tags: [
|
||||
{
|
||||
name: "v2.0.0 Beta",
|
||||
@@ -36,7 +36,7 @@ export default function Layout({ children }: { children: ReactNode }) {
|
||||
},
|
||||
{
|
||||
name: "v3.0 Beta ✨",
|
||||
value: "3.1-beta",
|
||||
value: "3.2-beta",
|
||||
props: {
|
||||
style: {
|
||||
border: "1px solid rgba(0,165,80,0.2)",
|
||||
|
@@ -6,61 +6,61 @@ const providers = [
|
||||
{
|
||||
name: "Google",
|
||||
description: "Configure authentication using Google OAuth2 services",
|
||||
href: "/docs/3.1-beta/oidc-authentication/google",
|
||||
href: "/docs/3.2-beta/oidc-authentication/google",
|
||||
icon: <Chrome className="w-4 h-4" />,
|
||||
},
|
||||
{
|
||||
name: "Discord",
|
||||
description: "Set up Discord OAuth2 for community-based authentication",
|
||||
href: "/docs/3.1-beta/oidc-authentication/discord",
|
||||
href: "/docs/3.2-beta/oidc-authentication/discord",
|
||||
icon: <MessageSquare className="w-4 h-4" />,
|
||||
},
|
||||
{
|
||||
name: "GitHub",
|
||||
description: "Enable GitHub OAuth for developer-friendly sign-in",
|
||||
href: "/docs/3.1-beta/oidc-authentication/github",
|
||||
href: "/docs/3.2-beta/oidc-authentication/github",
|
||||
icon: <Github className="w-4 h-4" />,
|
||||
},
|
||||
{
|
||||
name: "Zitadel",
|
||||
description: "Enterprise-grade identity and access management",
|
||||
href: "/docs/3.1-beta/oidc-authentication/zitadel",
|
||||
href: "/docs/3.2-beta/oidc-authentication/zitadel",
|
||||
icon: <Shield className="w-4 h-4" />,
|
||||
},
|
||||
{
|
||||
name: "Auth0",
|
||||
description: "Flexible identity platform with extensive customization",
|
||||
href: "/docs/3.1-beta/oidc-authentication/auth0",
|
||||
href: "/docs/3.2-beta/oidc-authentication/auth0",
|
||||
icon: <Lock className="w-4 h-4" />,
|
||||
},
|
||||
{
|
||||
name: "Authentik",
|
||||
description: "Open-source identity provider with modern features",
|
||||
href: "/docs/3.1-beta/oidc-authentication/authentik",
|
||||
href: "/docs/3.2-beta/oidc-authentication/authentik",
|
||||
icon: <Key className="w-4 h-4" />,
|
||||
},
|
||||
{
|
||||
name: "Frontegg",
|
||||
description: "User management platform for B2B applications",
|
||||
href: "/docs/3.1-beta/oidc-authentication/frontegg",
|
||||
href: "/docs/3.2-beta/oidc-authentication/frontegg",
|
||||
icon: <Egg className="w-4 h-4" />,
|
||||
},
|
||||
{
|
||||
name: "Kinde Auth",
|
||||
description: "Developer-first authentication and user management",
|
||||
href: "/docs/3.1-beta/oidc-authentication/kinde-auth",
|
||||
href: "/docs/3.2-beta/oidc-authentication/kinde-auth",
|
||||
icon: <Users className="w-4 h-" />,
|
||||
},
|
||||
{
|
||||
name: "Pocket ID",
|
||||
description: "Open-source identity provider with OIDC support",
|
||||
href: "/docs/3.1-beta/oidc-authentication/pocket-id",
|
||||
href: "/docs/3.2-beta/oidc-authentication/pocket-id",
|
||||
icon: <Key className="w-4 h-4" />,
|
||||
},
|
||||
{
|
||||
name: "Other",
|
||||
description: "Configure any other OIDC-compliant identity provider",
|
||||
href: "/docs/3.1-beta/oidc-authentication/other",
|
||||
href: "/docs/3.2-beta/oidc-authentication/other",
|
||||
icon: <Settings className="w-4 h-4" />,
|
||||
},
|
||||
];
|
||||
|
33
apps/docs/src/components/ui/background-lights.tsx
Normal file
33
apps/docs/src/components/ui/background-lights.tsx
Normal file
@@ -0,0 +1,33 @@
|
||||
import { motion } from "motion/react";
|
||||
|
||||
export function BackgroundLights() {
|
||||
return (
|
||||
<div className="absolute inset-0 -z-10 overflow-hidden">
|
||||
<motion.div
|
||||
animate={{
|
||||
scale: [1, 1.1, 1],
|
||||
opacity: [0.3, 0.5, 0.3],
|
||||
}}
|
||||
className="absolute -top-[20%] -left-[20%] w-[140%] h-[140%] bg-[radial-gradient(circle,rgba(34,197,94,0.15)_0%,transparent_70%)] dark:opacity-100 opacity-50"
|
||||
transition={{
|
||||
duration: 5,
|
||||
repeat: Infinity,
|
||||
ease: "easeInOut",
|
||||
}}
|
||||
/>
|
||||
<motion.div
|
||||
animate={{
|
||||
scale: [1, 1.1, 1],
|
||||
opacity: [0.3, 0.5, 0.3],
|
||||
}}
|
||||
className="absolute -bottom-[20%] -right-[20%] w-[140%] h-[140%] bg-[radial-gradient(circle,rgba(34,197,94,0.15)_0%,transparent_70%)] dark:opacity-100 opacity-50"
|
||||
transition={{
|
||||
duration: 5,
|
||||
repeat: Infinity,
|
||||
ease: "easeInOut",
|
||||
delay: 2.5,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
@@ -5,14 +5,15 @@ import { cn } from "@/lib/utils";
|
||||
|
||||
interface CardProps {
|
||||
title: string;
|
||||
description: string;
|
||||
description?: string;
|
||||
href?: string;
|
||||
icon?: ReactNode;
|
||||
className?: string;
|
||||
onClick?: () => void;
|
||||
children?: ReactNode;
|
||||
}
|
||||
|
||||
export const Card = ({ title, description, href, icon, className, onClick }: CardProps) => {
|
||||
export const Card = ({ title, description, href, icon, className, onClick, children }: CardProps) => {
|
||||
const cardContent = (
|
||||
<div
|
||||
className={cn(
|
||||
@@ -37,9 +38,16 @@ export const Card = ({ title, description, href, icon, className, onClick }: Car
|
||||
<h3 className="font-medium text-sm text-foreground mb-1 group-hover:text-primary transition-colors duration-200 mt-3 text-decoration-none">
|
||||
{title}
|
||||
</h3>
|
||||
<p className="text-xs text-muted-foreground/80 leading-relaxed line-clamp-2 group-hover:text-muted-foreground transition-colors duration-200">
|
||||
{description}
|
||||
</p>
|
||||
{description && (
|
||||
<p className="text-xs text-muted-foreground/80 leading-relaxed line-clamp-2 group-hover:text-muted-foreground transition-colors duration-200">
|
||||
{description}
|
||||
</p>
|
||||
)}
|
||||
{children && (
|
||||
<div className="text-xs text-muted-foreground/80 leading-relaxed group-hover:text-muted-foreground transition-colors duration-200 mt-2">
|
||||
{children}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="flex-shrink-0 ml-2">
|
||||
<div className="w-5 h-5 rounded-full bg-muted/40 flex items-center justify-center opacity-0 group-hover:opacity-100 group-hover:bg-primary/10 transition-all duration-200">
|
||||
|
@@ -1,2 +1,2 @@
|
||||
export const LATEST_VERSION_PATH = "/docs/3.1-beta";
|
||||
export const LATEST_VERSION = "v3.1-beta";
|
||||
export const LATEST_VERSION_PATH = "/docs/3.2-beta";
|
||||
export const LATEST_VERSION = "v3.2-beta";
|
||||
|
@@ -1,6 +1,7 @@
|
||||
# FOR FILESYSTEM STORAGE ENV VARS
|
||||
ENABLE_S3=false
|
||||
ENCRYPTION_KEY=change-this-key-in-production-min-32-chars
|
||||
DISABLE_FILESYSTEM_ENCRYPTION=true
|
||||
# ENCRYPTION_KEY=change-this-key-in-production-min-32-chars # Required only if encryption is enabled (DISABLE_FILESYSTEM_ENCRYPTION=false)
|
||||
DATABASE_URL="file:./palmr.db"
|
||||
|
||||
# FOR USE WITH S3 COMPATIBLE STORAGE
|
||||
@@ -13,3 +14,5 @@ DATABASE_URL="file:./palmr.db"
|
||||
# S3_REGION=
|
||||
# S3_BUCKET_NAME=
|
||||
# S3_FORCE_PATH_STYLE=
|
||||
# S3_REJECT_UNAUTHORIZED=true # Set to false to disable strict SSL certificate validation for self-signed certificates (optional, defaults to true)
|
||||
# PRESIGNED_URL_EXPIRATION=3600 # Duration in seconds for presigned URL expiration (optional, defaults to 3600 seconds / 1 hour)
|
||||
|
@@ -1,5 +0,0 @@
|
||||
|
||||
|
||||
> palmr-api@3.1-beta lint /Users/daniel/clones/Palmr/apps/server
|
||||
> eslint "src/**/*.+(ts|tsx)"
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "palmr-api",
|
||||
"version": "v3.1.1-beta",
|
||||
"version": "3.2.1-beta",
|
||||
"description": "API for Palmr",
|
||||
"private": true,
|
||||
"author": "Daniel Luiz Alves <daniel@kyantech.com.br>",
|
||||
@@ -42,7 +42,9 @@
|
||||
"@fastify/swagger-ui": "^5.2.3",
|
||||
"@prisma/client": "^6.11.0",
|
||||
"@scalar/fastify-api-reference": "^1.32.1",
|
||||
"@types/archiver": "^6.0.3",
|
||||
"@types/crypto-js": "^4.2.2",
|
||||
"archiver": "^7.0.1",
|
||||
"bcryptjs": "^2.4.3",
|
||||
"crypto-js": "^4.2.0",
|
||||
"fastify": "^5.4.0",
|
||||
|
353
apps/server/pnpm-lock.yaml
generated
353
apps/server/pnpm-lock.yaml
generated
@@ -41,9 +41,15 @@ importers:
|
||||
'@scalar/fastify-api-reference':
|
||||
specifier: ^1.32.1
|
||||
version: 1.32.1
|
||||
'@types/archiver':
|
||||
specifier: ^6.0.3
|
||||
version: 6.0.3
|
||||
'@types/crypto-js':
|
||||
specifier: ^4.2.2
|
||||
version: 4.2.2
|
||||
archiver:
|
||||
specifier: ^7.0.1
|
||||
version: 7.0.1
|
||||
bcryptjs:
|
||||
specifier: ^2.4.3
|
||||
version: 2.4.3
|
||||
@@ -776,6 +782,10 @@ packages:
|
||||
resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==}
|
||||
engines: {node: '>= 8'}
|
||||
|
||||
'@pkgjs/parseargs@0.11.0':
|
||||
resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==}
|
||||
engines: {node: '>=14'}
|
||||
|
||||
'@pkgr/core@0.2.7':
|
||||
resolution: {integrity: sha512-YLT9Zo3oNPJoBjBc4q8G2mjU4tqIbf5CEOORbUUr48dCD9q3umJ3IPlVqOqDakPfd2HuwccBaqlGhN4Gmr5OWg==}
|
||||
engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0}
|
||||
@@ -1054,6 +1064,9 @@ packages:
|
||||
'@tsconfig/node16@1.0.4':
|
||||
resolution: {integrity: sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==}
|
||||
|
||||
'@types/archiver@6.0.3':
|
||||
resolution: {integrity: sha512-a6wUll6k3zX6qs5KlxIggs1P1JcYJaTCx2gnlr+f0S1yd2DoaEwoIK10HmBaLnZwWneBz+JBm0dwcZu0zECBcQ==}
|
||||
|
||||
'@types/bcryptjs@2.4.6':
|
||||
resolution: {integrity: sha512-9xlo6R2qDs5uixm0bcIqCeMCE6HiQsIyel9KQySStiyqNl2tnj2mP3DX1Nf56MD6KMenNNlBBsy3LJ7gUEQPXQ==}
|
||||
|
||||
@@ -1075,6 +1088,9 @@ packages:
|
||||
'@types/qrcode@1.5.5':
|
||||
resolution: {integrity: sha512-CdfBi/e3Qk+3Z/fXYShipBT13OJ2fDO2Q2w5CIP5anLTLIndQG9z6P1cnm+8zCWSpm5dnxMFd/uREtb0EXuQzg==}
|
||||
|
||||
'@types/readdir-glob@1.1.5':
|
||||
resolution: {integrity: sha512-raiuEPUYqXu+nvtY2Pe8s8FEmZ3x5yAH4VkLdihcPdalvsHltomrRC9BzuStrJ9yk06470hS0Crw0f1pXqD+Hg==}
|
||||
|
||||
'@types/speakeasy@2.0.10':
|
||||
resolution: {integrity: sha512-QVRlDW5r4yl7p7xkNIbAIC/JtyOcClDIIdKfuG7PWdDT1MmyhtXSANsildohy0K+Lmvf/9RUtLbNLMacvrVwxA==}
|
||||
|
||||
@@ -1140,6 +1156,10 @@ packages:
|
||||
resolution: {integrity: sha512-VRwixir4zBWCSTP/ljEo091lbpypz57PoeAQ9imjG+vbeof9LplljsL1mos4ccG6H9IjfrVGM359RozUnuFhpw==}
|
||||
engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0}
|
||||
|
||||
abort-controller@3.0.0:
|
||||
resolution: {integrity: sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==}
|
||||
engines: {node: '>=6.5'}
|
||||
|
||||
abstract-logging@2.0.1:
|
||||
resolution: {integrity: sha512-2BjRTZxTPvheOvGbBslFSYOUkr+SjPtOnrLP33f+VIWLzezQpZcqVg7ja3L4dBXmzzgwT+a029jRx5PCi3JuiA==}
|
||||
|
||||
@@ -1195,6 +1215,14 @@ packages:
|
||||
resolution: {integrity: sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
archiver-utils@5.0.2:
|
||||
resolution: {integrity: sha512-wuLJMmIBQYCsGZgYLTy5FIB2pF6Lfb6cXMSF8Qywwk3t20zWnAi7zLcQFdKQmIB8wyZpY5ER38x08GbwtR2cLA==}
|
||||
engines: {node: '>= 14'}
|
||||
|
||||
archiver@7.0.1:
|
||||
resolution: {integrity: sha512-ZcbTaIqJOfCc03QwD468Unz/5Ir8ATtvAHsK+FdXbDIbGfihqh9mrvdcYunQzqn4HrvWWaFyaxJhGZagaJJpPQ==}
|
||||
engines: {node: '>= 14'}
|
||||
|
||||
arg@4.1.3:
|
||||
resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==}
|
||||
|
||||
@@ -1204,6 +1232,9 @@ packages:
|
||||
asn1.js@5.4.1:
|
||||
resolution: {integrity: sha512-+I//4cYPccV8LdmBLiX8CYvf9Sp3vQsrqu2QNXRcrbiWvcx/UdlFiqUJJzxRQxgsZmvhXhn4cSKeSmoFjVdupA==}
|
||||
|
||||
async@3.2.6:
|
||||
resolution: {integrity: sha512-htCUDlxyyCLMgaM3xXg0C0LW2xqfuQ6p05pCEIsXuyQ+a1koYKTuBMzRNwmybfLgvJDMd0r1LTn4+E0Ti6C2AA==}
|
||||
|
||||
atomic-sleep@1.0.0:
|
||||
resolution: {integrity: sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==}
|
||||
engines: {node: '>=8.0.0'}
|
||||
@@ -1211,12 +1242,26 @@ packages:
|
||||
avvio@9.1.0:
|
||||
resolution: {integrity: sha512-fYASnYi600CsH/j9EQov7lECAniYiBFiiAtBNuZYLA2leLe9qOvZzqYHFjtIj6gD2VMoMLP14834LFWvr4IfDw==}
|
||||
|
||||
b4a@1.7.2:
|
||||
resolution: {integrity: sha512-DyUOdz+E8R6+sruDpQNOaV0y/dBbV6X/8ZkxrDcR0Ifc3BgKlpgG0VAtfOozA0eMtJO5GGe9FsZhueLs00pTww==}
|
||||
peerDependencies:
|
||||
react-native-b4a: '*'
|
||||
peerDependenciesMeta:
|
||||
react-native-b4a:
|
||||
optional: true
|
||||
|
||||
balanced-match@1.0.2:
|
||||
resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==}
|
||||
|
||||
bare-events@2.7.0:
|
||||
resolution: {integrity: sha512-b3N5eTW1g7vXkw+0CXh/HazGTcO5KYuu/RCNaJbDMPI6LHDi+7qe8EmxKUVe1sUbY2KZOVZFyj62x0OEz9qyAA==}
|
||||
|
||||
base32.js@0.0.1:
|
||||
resolution: {integrity: sha512-EGHIRiegFa62/SsA1J+Xs2tIzludPdzM064N9wjbiEgHnGnJ1V0WEpA4pEwCYT5nDvZk3ubf0shqaCS7k6xeUQ==}
|
||||
|
||||
base64-js@1.5.1:
|
||||
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
|
||||
|
||||
bcryptjs@2.4.3:
|
||||
resolution: {integrity: sha512-V/Hy/X9Vt7f3BbPJEi8BdVFMByHi+jNXrYkW3huaybV/kQ0KJg0Y6PkEMbn+zeT+i+SiKZ/HMqJGIIt4LZDqNQ==}
|
||||
|
||||
@@ -1236,6 +1281,13 @@ packages:
|
||||
resolution: {integrity: sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
buffer-crc32@1.0.0:
|
||||
resolution: {integrity: sha512-Db1SbgBS/fg/392AblrMJk97KggmvYhr4pB5ZIMTWtaivCPMWLkmb7m21cJvpvgK+J3nsU2CmmixNBZx4vFj/w==}
|
||||
engines: {node: '>=8.0.0'}
|
||||
|
||||
buffer@6.0.3:
|
||||
resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==}
|
||||
|
||||
callsites@3.1.0:
|
||||
resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==}
|
||||
engines: {node: '>=6'}
|
||||
@@ -1265,6 +1317,10 @@ packages:
|
||||
resolution: {integrity: sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==}
|
||||
engines: {node: '>=12.5.0'}
|
||||
|
||||
compress-commons@6.0.2:
|
||||
resolution: {integrity: sha512-6FqVXeETqWPoGcfzrXb37E50NP0LXT8kAMu5ooZayhWWdgEY4lBEEcbQNXtkuKQsGduxiIcI4gOTsxTmuq/bSg==}
|
||||
engines: {node: '>= 14'}
|
||||
|
||||
concat-map@0.0.1:
|
||||
resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==}
|
||||
|
||||
@@ -1276,6 +1332,18 @@ packages:
|
||||
resolution: {integrity: sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
core-util-is@1.0.3:
|
||||
resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==}
|
||||
|
||||
crc-32@1.2.2:
|
||||
resolution: {integrity: sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==}
|
||||
engines: {node: '>=0.8'}
|
||||
hasBin: true
|
||||
|
||||
crc32-stream@6.0.0:
|
||||
resolution: {integrity: sha512-piICUB6ei4IlTv1+653yq5+KoqfBYmj9bw6LqXoOneTMDXk5nM1qt12mFW1caG3LlJXEKW1Bp0WggEmIfQB34g==}
|
||||
engines: {node: '>= 14'}
|
||||
|
||||
create-require@1.1.1:
|
||||
resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==}
|
||||
|
||||
@@ -1411,6 +1479,17 @@ packages:
|
||||
resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
event-target-shim@5.0.1:
|
||||
resolution: {integrity: sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
events-universal@1.0.1:
|
||||
resolution: {integrity: sha512-LUd5euvbMLpwOF8m6ivPCbhQeSiYVNb8Vs0fQ8QjXo0JTkEHpz8pxdQf0gStltaPpw0Cca8b39KxvK9cfKRiAw==}
|
||||
|
||||
events@3.3.0:
|
||||
resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==}
|
||||
engines: {node: '>=0.8.x'}
|
||||
|
||||
fast-decode-uri-component@1.0.1:
|
||||
resolution: {integrity: sha512-WKgKWg5eUxvRZGwW8FvfbaH7AXSh2cL+3j5fMGzUMCxWBJ3dV3a7Wz8y2f/uQ0e3B6WmodD3oS54jTQ9HVTIIg==}
|
||||
|
||||
@@ -1420,6 +1499,9 @@ packages:
|
||||
fast-diff@1.3.0:
|
||||
resolution: {integrity: sha512-VxPP4NqbUjj6MaAOafWeUn2cXWLcCtljklUtZf0Ind4XQ+QPtmA0b18zZy0jIQx+ExRVCR/ZQpBmik5lXshNsw==}
|
||||
|
||||
fast-fifo@1.3.2:
|
||||
resolution: {integrity: sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==}
|
||||
|
||||
fast-glob@3.3.3:
|
||||
resolution: {integrity: sha512-7MptL8U0cqcFdzIzwOTHoilX9x5BrNqye7Z/LuC7kCMRio1EMSyqRK3BEAUD7sXRq4iT4AzTVuZdhgQ2TCvYLg==}
|
||||
engines: {node: '>=8.6.0'}
|
||||
@@ -1541,6 +1623,10 @@ packages:
|
||||
resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==}
|
||||
engines: {node: '>=10.13.0'}
|
||||
|
||||
glob@10.4.5:
|
||||
resolution: {integrity: sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==}
|
||||
hasBin: true
|
||||
|
||||
glob@11.0.3:
|
||||
resolution: {integrity: sha512-2Nim7dha1KVkaiF4q6Dj+ngPPMdfvLJEOpZk/jKiUAkqKebpGAWQXAq9z1xu9HKu5lWfqw/FASuccEjyznjPaA==}
|
||||
engines: {node: 20 || >=22}
|
||||
@@ -1550,6 +1636,9 @@ packages:
|
||||
resolution: {integrity: sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==}
|
||||
engines: {node: '>=18'}
|
||||
|
||||
graceful-fs@4.2.11:
|
||||
resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==}
|
||||
|
||||
graphemer@1.4.0:
|
||||
resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==}
|
||||
|
||||
@@ -1561,6 +1650,9 @@ packages:
|
||||
resolution: {integrity: sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==}
|
||||
engines: {node: '>= 0.8'}
|
||||
|
||||
ieee754@1.2.1:
|
||||
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
|
||||
|
||||
ignore@5.3.2:
|
||||
resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==}
|
||||
engines: {node: '>= 4'}
|
||||
@@ -1603,9 +1695,19 @@ packages:
|
||||
resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==}
|
||||
engines: {node: '>=0.12.0'}
|
||||
|
||||
is-stream@2.0.1:
|
||||
resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
isarray@1.0.0:
|
||||
resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==}
|
||||
|
||||
isexe@2.0.0:
|
||||
resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==}
|
||||
|
||||
jackspeak@3.4.3:
|
||||
resolution: {integrity: sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==}
|
||||
|
||||
jackspeak@4.1.1:
|
||||
resolution: {integrity: sha512-zptv57P3GpL+O0I7VdMJNBZCu+BPHVQUk55Ft8/QCJjTVxrnJHuVuX/0Bl2A6/+2oyR/ZMEuFKwmzqqZ/U5nPQ==}
|
||||
engines: {node: 20 || >=22}
|
||||
@@ -1658,6 +1760,10 @@ packages:
|
||||
keyv@4.5.4:
|
||||
resolution: {integrity: sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==}
|
||||
|
||||
lazystream@1.0.1:
|
||||
resolution: {integrity: sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==}
|
||||
engines: {node: '>= 0.6.3'}
|
||||
|
||||
leven@4.0.0:
|
||||
resolution: {integrity: sha512-puehA3YKku3osqPlNuzGDUHq8WpwXupUg1V6NXdV38G+gr+gkBwFC8g1b/+YcIvp8gnqVIus+eJCH/eGsRmJNw==}
|
||||
engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0}
|
||||
@@ -1680,6 +1786,12 @@ packages:
|
||||
lodash.merge@4.6.2:
|
||||
resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==}
|
||||
|
||||
lodash@4.17.21:
|
||||
resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
|
||||
|
||||
lru-cache@10.4.3:
|
||||
resolution: {integrity: sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==}
|
||||
|
||||
lru-cache@11.1.0:
|
||||
resolution: {integrity: sha512-QIXZUBJUx+2zHUdQujWejBkcD9+cs94tLn0+YL8UrCh+D5sCXZ4c7LaEH48pNwRY3MLDgqUFyhlCyjJPf1WP0A==}
|
||||
engines: {node: 20 || >=22}
|
||||
@@ -1710,6 +1822,10 @@ packages:
|
||||
minimatch@3.1.2:
|
||||
resolution: {integrity: sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==}
|
||||
|
||||
minimatch@5.1.6:
|
||||
resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
minimatch@9.0.5:
|
||||
resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==}
|
||||
engines: {node: '>=16 || 14 >=14.17'}
|
||||
@@ -1748,6 +1864,10 @@ packages:
|
||||
resolution: {integrity: sha512-Z+iLaBGVaSjbIzQ4pX6XV41HrooLsQ10ZWPUehGmuantvzWoDVBnmsdUcOIDM1t+yPor5pDhVlDESgOMEGxhHA==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
|
||||
normalize-path@3.0.0:
|
||||
resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
oauth4webapi@3.5.5:
|
||||
resolution: {integrity: sha512-1K88D2GiAydGblHo39NBro5TebGXa+7tYoyIbxvqv3+haDDry7CBE1eSYuNbOSsYCCU6y0gdynVZAkm4YPw4hg==}
|
||||
|
||||
@@ -1803,6 +1923,10 @@ packages:
|
||||
resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
path-scurry@1.11.1:
|
||||
resolution: {integrity: sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==}
|
||||
engines: {node: '>=16 || 14 >=14.18'}
|
||||
|
||||
path-scurry@2.0.0:
|
||||
resolution: {integrity: sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==}
|
||||
engines: {node: 20 || >=22}
|
||||
@@ -1857,12 +1981,19 @@ packages:
|
||||
typescript:
|
||||
optional: true
|
||||
|
||||
process-nextick-args@2.0.1:
|
||||
resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==}
|
||||
|
||||
process-warning@4.0.1:
|
||||
resolution: {integrity: sha512-3c2LzQ3rY9d0hc1emcsHhfT9Jwz0cChib/QN89oME2R451w5fy3f0afAhERFZAwrbDU43wk12d0ORBpDVME50Q==}
|
||||
|
||||
process-warning@5.0.0:
|
||||
resolution: {integrity: sha512-a39t9ApHNx2L4+HBnQKqxxHNs1r7KF+Intd8Q/g1bUh6q0WIp9voPXJ/x0j+ZL45KF1pJd9+q2jLIRMfvEshkA==}
|
||||
|
||||
process@0.11.10:
|
||||
resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==}
|
||||
engines: {node: '>= 0.6.0'}
|
||||
|
||||
punycode@2.3.1:
|
||||
resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==}
|
||||
engines: {node: '>=6'}
|
||||
@@ -1878,6 +2009,16 @@ packages:
|
||||
quick-format-unescaped@4.0.4:
|
||||
resolution: {integrity: sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==}
|
||||
|
||||
readable-stream@2.3.8:
|
||||
resolution: {integrity: sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==}
|
||||
|
||||
readable-stream@4.7.0:
|
||||
resolution: {integrity: sha512-oIGGmcpTLwPga8Bn6/Z75SVaH1z5dUut2ibSyAMVhmUggWpmDn2dapB0n7f8nwaSiRtepAsfJyfXIO5DCVAODg==}
|
||||
engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0}
|
||||
|
||||
readdir-glob@1.1.3:
|
||||
resolution: {integrity: sha512-v05I2k7xN8zXvPD9N+z/uhXPaj0sUFCe2rcWZIpBsqxfP7xXFQ0tipAd/wjj1YxWyWtUS5IDJpOG82JKt2EAVA==}
|
||||
|
||||
real-require@0.2.0:
|
||||
resolution: {integrity: sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==}
|
||||
engines: {node: '>= 12.13.0'}
|
||||
@@ -1914,6 +2055,9 @@ packages:
|
||||
run-parallel@1.2.0:
|
||||
resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==}
|
||||
|
||||
safe-buffer@5.1.2:
|
||||
resolution: {integrity: sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==}
|
||||
|
||||
safe-buffer@5.2.1:
|
||||
resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==}
|
||||
|
||||
@@ -1984,6 +2128,9 @@ packages:
|
||||
steed@1.1.3:
|
||||
resolution: {integrity: sha512-EUkci0FAUiE4IvGTSKcDJIQ/eRUP2JJb56+fvZ4sdnguLTqIdKjSxUe138poW8mkvKWXW2sFPrgTsxqoISnmoA==}
|
||||
|
||||
streamx@2.23.0:
|
||||
resolution: {integrity: sha512-kn+e44esVfn2Fa/O0CPFcex27fjIL6MkVae0Mm6q+E6f0hWv578YCERbv+4m02cjxvDsPKLnmxral/rR6lBMAg==}
|
||||
|
||||
string-width@4.2.3:
|
||||
resolution: {integrity: sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==}
|
||||
engines: {node: '>=8'}
|
||||
@@ -1992,6 +2139,12 @@ packages:
|
||||
resolution: {integrity: sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
string_decoder@1.1.1:
|
||||
resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==}
|
||||
|
||||
string_decoder@1.3.0:
|
||||
resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==}
|
||||
|
||||
strip-ansi@6.0.1:
|
||||
resolution: {integrity: sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==}
|
||||
engines: {node: '>=8'}
|
||||
@@ -2015,6 +2168,12 @@ packages:
|
||||
resolution: {integrity: sha512-+XZ+r1XGIJGeQk3VvXhT6xx/VpbHsRzsTkGgF6E5RX9TTXD0118l87puaEBZ566FhqblC6U0d4XnubznJDm30A==}
|
||||
engines: {node: ^14.18.0 || >=16.0.0}
|
||||
|
||||
tar-stream@3.1.7:
|
||||
resolution: {integrity: sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==}
|
||||
|
||||
text-decoder@1.2.3:
|
||||
resolution: {integrity: sha512-3/o9z3X0X0fTupwsYvR03pJ/DjWuqqrfwBgTQzdWDiQSm9KitAyz/9WqsT2JQW7KV2m+bC2ol/zqpW37NHxLaA==}
|
||||
|
||||
thread-stream@3.1.0:
|
||||
resolution: {integrity: sha512-OqyPZ9u96VohAyMfJykzmivOrY2wfMSf3C5TtFJVgN+Hm6aj+voFhlK+kZEIv2FBh1X6Xp3DlnCOfEQ3B2J86A==}
|
||||
|
||||
@@ -2073,6 +2232,9 @@ packages:
|
||||
uri-js@4.4.1:
|
||||
resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==}
|
||||
|
||||
util-deprecate@1.0.2:
|
||||
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
|
||||
|
||||
uuid@9.0.1:
|
||||
resolution: {integrity: sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==}
|
||||
hasBin: true
|
||||
@@ -2136,6 +2298,10 @@ packages:
|
||||
resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
zip-stream@6.0.1:
|
||||
resolution: {integrity: sha512-zK7YHHz4ZXpW89AHXUPbQVGKI7uvkd3hzusTdotCg1UxyaVtg0zFJSTfW/Dq5f7OBBVnq6cZIaC8Ti4hb6dtCA==}
|
||||
engines: {node: '>= 14'}
|
||||
|
||||
zod-to-json-schema@3.24.6:
|
||||
resolution: {integrity: sha512-h/z3PKvcTcTetyjl1fkj79MHNEjm+HpD6NXheWjzOekY7kV+lwDYnHw+ivHkijnCSMz1yJaWBD9vu/Fcmk+vEg==}
|
||||
peerDependencies:
|
||||
@@ -3054,6 +3220,9 @@ snapshots:
|
||||
'@nodelib/fs.scandir': 2.1.5
|
||||
fastq: 1.19.1
|
||||
|
||||
'@pkgjs/parseargs@0.11.0':
|
||||
optional: true
|
||||
|
||||
'@pkgr/core@0.2.7': {}
|
||||
|
||||
'@prisma/client@6.11.1(prisma@6.11.1(typescript@5.8.3))(typescript@5.8.3)':
|
||||
@@ -3458,6 +3627,10 @@ snapshots:
|
||||
|
||||
'@tsconfig/node16@1.0.4': {}
|
||||
|
||||
'@types/archiver@6.0.3':
|
||||
dependencies:
|
||||
'@types/readdir-glob': 1.1.5
|
||||
|
||||
'@types/bcryptjs@2.4.6': {}
|
||||
|
||||
'@types/crypto-js@4.2.2': {}
|
||||
@@ -3478,6 +3651,10 @@ snapshots:
|
||||
dependencies:
|
||||
'@types/node': 22.16.0
|
||||
|
||||
'@types/readdir-glob@1.1.5':
|
||||
dependencies:
|
||||
'@types/node': 22.16.0
|
||||
|
||||
'@types/speakeasy@2.0.10':
|
||||
dependencies:
|
||||
'@types/node': 22.16.0
|
||||
@@ -3576,6 +3753,10 @@ snapshots:
|
||||
'@typescript-eslint/types': 8.35.1
|
||||
eslint-visitor-keys: 4.2.1
|
||||
|
||||
abort-controller@3.0.0:
|
||||
dependencies:
|
||||
event-target-shim: 5.0.1
|
||||
|
||||
abstract-logging@2.0.1: {}
|
||||
|
||||
acorn-jsx@5.3.2(acorn@8.15.0):
|
||||
@@ -3620,6 +3801,28 @@ snapshots:
|
||||
|
||||
ansi-styles@6.2.1: {}
|
||||
|
||||
archiver-utils@5.0.2:
|
||||
dependencies:
|
||||
glob: 10.4.5
|
||||
graceful-fs: 4.2.11
|
||||
is-stream: 2.0.1
|
||||
lazystream: 1.0.1
|
||||
lodash: 4.17.21
|
||||
normalize-path: 3.0.0
|
||||
readable-stream: 4.7.0
|
||||
|
||||
archiver@7.0.1:
|
||||
dependencies:
|
||||
archiver-utils: 5.0.2
|
||||
async: 3.2.6
|
||||
buffer-crc32: 1.0.0
|
||||
readable-stream: 4.7.0
|
||||
readdir-glob: 1.1.3
|
||||
tar-stream: 3.1.7
|
||||
zip-stream: 6.0.1
|
||||
transitivePeerDependencies:
|
||||
- react-native-b4a
|
||||
|
||||
arg@4.1.3: {}
|
||||
|
||||
argparse@2.0.1: {}
|
||||
@@ -3631,6 +3834,8 @@ snapshots:
|
||||
minimalistic-assert: 1.0.1
|
||||
safer-buffer: 2.1.2
|
||||
|
||||
async@3.2.6: {}
|
||||
|
||||
atomic-sleep@1.0.0: {}
|
||||
|
||||
avvio@9.1.0:
|
||||
@@ -3638,10 +3843,16 @@ snapshots:
|
||||
'@fastify/error': 4.2.0
|
||||
fastq: 1.19.1
|
||||
|
||||
b4a@1.7.2: {}
|
||||
|
||||
balanced-match@1.0.2: {}
|
||||
|
||||
bare-events@2.7.0: {}
|
||||
|
||||
base32.js@0.0.1: {}
|
||||
|
||||
base64-js@1.5.1: {}
|
||||
|
||||
bcryptjs@2.4.3: {}
|
||||
|
||||
bn.js@4.12.2: {}
|
||||
@@ -3661,6 +3872,13 @@ snapshots:
|
||||
dependencies:
|
||||
fill-range: 7.1.1
|
||||
|
||||
buffer-crc32@1.0.0: {}
|
||||
|
||||
buffer@6.0.3:
|
||||
dependencies:
|
||||
base64-js: 1.5.1
|
||||
ieee754: 1.2.1
|
||||
|
||||
callsites@3.1.0: {}
|
||||
|
||||
camelcase@5.3.1: {}
|
||||
@@ -3692,6 +3910,14 @@ snapshots:
|
||||
color-convert: 2.0.1
|
||||
color-string: 1.9.1
|
||||
|
||||
compress-commons@6.0.2:
|
||||
dependencies:
|
||||
crc-32: 1.2.2
|
||||
crc32-stream: 6.0.0
|
||||
is-stream: 2.0.1
|
||||
normalize-path: 3.0.0
|
||||
readable-stream: 4.7.0
|
||||
|
||||
concat-map@0.0.1: {}
|
||||
|
||||
content-disposition@0.5.4:
|
||||
@@ -3700,6 +3926,15 @@ snapshots:
|
||||
|
||||
cookie@1.0.2: {}
|
||||
|
||||
core-util-is@1.0.3: {}
|
||||
|
||||
crc-32@1.2.2: {}
|
||||
|
||||
crc32-stream@6.0.0:
|
||||
dependencies:
|
||||
crc-32: 1.2.2
|
||||
readable-stream: 4.7.0
|
||||
|
||||
create-require@1.1.1: {}
|
||||
|
||||
cross-spawn@7.0.6:
|
||||
@@ -3854,12 +4089,22 @@ snapshots:
|
||||
|
||||
esutils@2.0.3: {}
|
||||
|
||||
event-target-shim@5.0.1: {}
|
||||
|
||||
events-universal@1.0.1:
|
||||
dependencies:
|
||||
bare-events: 2.7.0
|
||||
|
||||
events@3.3.0: {}
|
||||
|
||||
fast-decode-uri-component@1.0.1: {}
|
||||
|
||||
fast-deep-equal@3.1.3: {}
|
||||
|
||||
fast-diff@1.3.0: {}
|
||||
|
||||
fast-fifo@1.3.2: {}
|
||||
|
||||
fast-glob@3.3.3:
|
||||
dependencies:
|
||||
'@nodelib/fs.stat': 2.0.5
|
||||
@@ -4011,6 +4256,15 @@ snapshots:
|
||||
dependencies:
|
||||
is-glob: 4.0.3
|
||||
|
||||
glob@10.4.5:
|
||||
dependencies:
|
||||
foreground-child: 3.3.1
|
||||
jackspeak: 3.4.3
|
||||
minimatch: 9.0.5
|
||||
minipass: 7.1.2
|
||||
package-json-from-dist: 1.0.1
|
||||
path-scurry: 1.11.1
|
||||
|
||||
glob@11.0.3:
|
||||
dependencies:
|
||||
foreground-child: 3.3.1
|
||||
@@ -4022,6 +4276,8 @@ snapshots:
|
||||
|
||||
globals@14.0.0: {}
|
||||
|
||||
graceful-fs@4.2.11: {}
|
||||
|
||||
graphemer@1.4.0: {}
|
||||
|
||||
has-flag@4.0.0: {}
|
||||
@@ -4034,6 +4290,8 @@ snapshots:
|
||||
statuses: 2.0.1
|
||||
toidentifier: 1.0.1
|
||||
|
||||
ieee754@1.2.1: {}
|
||||
|
||||
ignore@5.3.2: {}
|
||||
|
||||
ignore@7.0.5: {}
|
||||
@@ -4061,8 +4319,18 @@ snapshots:
|
||||
|
||||
is-number@7.0.0: {}
|
||||
|
||||
is-stream@2.0.1: {}
|
||||
|
||||
isarray@1.0.0: {}
|
||||
|
||||
isexe@2.0.0: {}
|
||||
|
||||
jackspeak@3.4.3:
|
||||
dependencies:
|
||||
'@isaacs/cliui': 8.0.2
|
||||
optionalDependencies:
|
||||
'@pkgjs/parseargs': 0.11.0
|
||||
|
||||
jackspeak@4.1.1:
|
||||
dependencies:
|
||||
'@isaacs/cliui': 8.0.2
|
||||
@@ -4107,6 +4375,10 @@ snapshots:
|
||||
dependencies:
|
||||
json-buffer: 3.0.1
|
||||
|
||||
lazystream@1.0.1:
|
||||
dependencies:
|
||||
readable-stream: 2.3.8
|
||||
|
||||
leven@4.0.0: {}
|
||||
|
||||
levn@0.4.1:
|
||||
@@ -4130,6 +4402,10 @@ snapshots:
|
||||
|
||||
lodash.merge@4.6.2: {}
|
||||
|
||||
lodash@4.17.21: {}
|
||||
|
||||
lru-cache@10.4.3: {}
|
||||
|
||||
lru-cache@11.1.0: {}
|
||||
|
||||
make-error@1.3.6: {}
|
||||
@@ -4153,6 +4429,10 @@ snapshots:
|
||||
dependencies:
|
||||
brace-expansion: 1.1.12
|
||||
|
||||
minimatch@5.1.6:
|
||||
dependencies:
|
||||
brace-expansion: 2.0.2
|
||||
|
||||
minimatch@9.0.5:
|
||||
dependencies:
|
||||
brace-expansion: 2.0.2
|
||||
@@ -4183,6 +4463,8 @@ snapshots:
|
||||
|
||||
nodemailer@6.10.1: {}
|
||||
|
||||
normalize-path@3.0.0: {}
|
||||
|
||||
oauth4webapi@3.5.5: {}
|
||||
|
||||
obliterator@2.0.5: {}
|
||||
@@ -4233,6 +4515,11 @@ snapshots:
|
||||
|
||||
path-key@3.1.1: {}
|
||||
|
||||
path-scurry@1.11.1:
|
||||
dependencies:
|
||||
lru-cache: 10.4.3
|
||||
minipass: 7.1.2
|
||||
|
||||
path-scurry@2.0.0:
|
||||
dependencies:
|
||||
lru-cache: 11.1.0
|
||||
@@ -4283,10 +4570,14 @@ snapshots:
|
||||
optionalDependencies:
|
||||
typescript: 5.8.3
|
||||
|
||||
process-nextick-args@2.0.1: {}
|
||||
|
||||
process-warning@4.0.1: {}
|
||||
|
||||
process-warning@5.0.0: {}
|
||||
|
||||
process@0.11.10: {}
|
||||
|
||||
punycode@2.3.1: {}
|
||||
|
||||
qrcode@1.5.4:
|
||||
@@ -4299,6 +4590,28 @@ snapshots:
|
||||
|
||||
quick-format-unescaped@4.0.4: {}
|
||||
|
||||
readable-stream@2.3.8:
|
||||
dependencies:
|
||||
core-util-is: 1.0.3
|
||||
inherits: 2.0.4
|
||||
isarray: 1.0.0
|
||||
process-nextick-args: 2.0.1
|
||||
safe-buffer: 5.1.2
|
||||
string_decoder: 1.1.1
|
||||
util-deprecate: 1.0.2
|
||||
|
||||
readable-stream@4.7.0:
|
||||
dependencies:
|
||||
abort-controller: 3.0.0
|
||||
buffer: 6.0.3
|
||||
events: 3.3.0
|
||||
process: 0.11.10
|
||||
string_decoder: 1.3.0
|
||||
|
||||
readdir-glob@1.1.3:
|
||||
dependencies:
|
||||
minimatch: 5.1.6
|
||||
|
||||
real-require@0.2.0: {}
|
||||
|
||||
require-directory@2.1.1: {}
|
||||
@@ -4321,6 +4634,8 @@ snapshots:
|
||||
dependencies:
|
||||
queue-microtask: 1.2.3
|
||||
|
||||
safe-buffer@5.1.2: {}
|
||||
|
||||
safe-buffer@5.2.1: {}
|
||||
|
||||
safe-regex2@5.0.0:
|
||||
@@ -4403,6 +4718,14 @@ snapshots:
|
||||
fastseries: 1.7.2
|
||||
reusify: 1.1.0
|
||||
|
||||
streamx@2.23.0:
|
||||
dependencies:
|
||||
events-universal: 1.0.1
|
||||
fast-fifo: 1.3.2
|
||||
text-decoder: 1.2.3
|
||||
transitivePeerDependencies:
|
||||
- react-native-b4a
|
||||
|
||||
string-width@4.2.3:
|
||||
dependencies:
|
||||
emoji-regex: 8.0.0
|
||||
@@ -4415,6 +4738,14 @@ snapshots:
|
||||
emoji-regex: 9.2.2
|
||||
strip-ansi: 7.1.0
|
||||
|
||||
string_decoder@1.1.1:
|
||||
dependencies:
|
||||
safe-buffer: 5.1.2
|
||||
|
||||
string_decoder@1.3.0:
|
||||
dependencies:
|
||||
safe-buffer: 5.2.1
|
||||
|
||||
strip-ansi@6.0.1:
|
||||
dependencies:
|
||||
ansi-regex: 5.0.1
|
||||
@@ -4435,6 +4766,20 @@ snapshots:
|
||||
dependencies:
|
||||
'@pkgr/core': 0.2.7
|
||||
|
||||
tar-stream@3.1.7:
|
||||
dependencies:
|
||||
b4a: 1.7.2
|
||||
fast-fifo: 1.3.2
|
||||
streamx: 2.23.0
|
||||
transitivePeerDependencies:
|
||||
- react-native-b4a
|
||||
|
||||
text-decoder@1.2.3:
|
||||
dependencies:
|
||||
b4a: 1.7.2
|
||||
transitivePeerDependencies:
|
||||
- react-native-b4a
|
||||
|
||||
thread-stream@3.1.0:
|
||||
dependencies:
|
||||
real-require: 0.2.0
|
||||
@@ -4490,6 +4835,8 @@ snapshots:
|
||||
dependencies:
|
||||
punycode: 2.3.1
|
||||
|
||||
util-deprecate@1.0.2: {}
|
||||
|
||||
uuid@9.0.1: {}
|
||||
|
||||
v8-compile-cache-lib@3.0.1: {}
|
||||
@@ -4551,6 +4898,12 @@ snapshots:
|
||||
|
||||
yocto-queue@0.1.0: {}
|
||||
|
||||
zip-stream@6.0.1:
|
||||
dependencies:
|
||||
archiver-utils: 5.0.2
|
||||
compress-commons: 6.0.2
|
||||
readable-stream: 4.7.0
|
||||
|
||||
zod-to-json-schema@3.24.6(zod@3.25.74):
|
||||
dependencies:
|
||||
zod: 3.25.74
|
||||
|
@@ -1,287 +1,319 @@
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
firstName String
|
||||
lastName String
|
||||
username String @unique
|
||||
email String @unique
|
||||
password String?
|
||||
image String?
|
||||
isAdmin Boolean @default(false)
|
||||
isActive Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
twoFactorEnabled Boolean @default(false)
|
||||
twoFactorSecret String?
|
||||
twoFactorBackupCodes String?
|
||||
twoFactorVerified Boolean @default(false)
|
||||
|
||||
files File[]
|
||||
shares Share[]
|
||||
reverseShares ReverseShare[]
|
||||
|
||||
loginAttempts LoginAttempt?
|
||||
|
||||
passwordResets PasswordReset[]
|
||||
authProviders UserAuthProvider[]
|
||||
trustedDevices TrustedDevice[]
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
|
||||
model File {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
description String?
|
||||
extension String
|
||||
size BigInt
|
||||
objectName String
|
||||
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
shares Share[] @relation("ShareFiles")
|
||||
|
||||
@@map("files")
|
||||
}
|
||||
|
||||
model Share {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
views Int @default(0)
|
||||
expiration DateTime?
|
||||
description String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
creatorId String?
|
||||
creator User? @relation(fields: [creatorId], references: [id], onDelete: SetNull)
|
||||
|
||||
securityId String @unique
|
||||
security ShareSecurity @relation(fields: [securityId], references: [id])
|
||||
|
||||
files File[] @relation("ShareFiles")
|
||||
recipients ShareRecipient[]
|
||||
|
||||
alias ShareAlias?
|
||||
|
||||
@@map("shares")
|
||||
}
|
||||
|
||||
model ShareSecurity {
|
||||
id String @id @default(cuid())
|
||||
password String?
|
||||
maxViews Int?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
share Share?
|
||||
|
||||
@@map("share_security")
|
||||
}
|
||||
|
||||
model ShareRecipient {
|
||||
id String @id @default(cuid())
|
||||
email String
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
shareId String
|
||||
share Share @relation(fields: [shareId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("share_recipients")
|
||||
}
|
||||
|
||||
model AppConfig {
|
||||
id String @id @default(cuid())
|
||||
key String @unique
|
||||
value String
|
||||
type String
|
||||
group String
|
||||
isSystem Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("app_configs")
|
||||
}
|
||||
|
||||
model LoginAttempt {
|
||||
id String @id @default(cuid())
|
||||
userId String @unique
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
attempts Int @default(1)
|
||||
lastAttempt DateTime @default(now())
|
||||
|
||||
@@map("login_attempts")
|
||||
}
|
||||
|
||||
model PasswordReset {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
token String @unique
|
||||
expiresAt DateTime
|
||||
used Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("password_resets")
|
||||
}
|
||||
|
||||
model ShareAlias {
|
||||
id String @id @default(cuid())
|
||||
alias String @unique
|
||||
shareId String @unique
|
||||
share Share @relation(fields: [shareId], references: [id], onDelete: Cascade)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("share_aliases")
|
||||
}
|
||||
|
||||
model AuthProvider {
|
||||
id String @id @default(cuid())
|
||||
name String @unique
|
||||
displayName String
|
||||
type String
|
||||
icon String?
|
||||
enabled Boolean @default(false)
|
||||
|
||||
issuerUrl String?
|
||||
clientId String?
|
||||
clientSecret String?
|
||||
redirectUri String?
|
||||
scope String? @default("openid profile email")
|
||||
|
||||
authorizationEndpoint String?
|
||||
tokenEndpoint String?
|
||||
userInfoEndpoint String?
|
||||
|
||||
metadata String?
|
||||
|
||||
autoRegister Boolean @default(true)
|
||||
adminEmailDomains String?
|
||||
|
||||
sortOrder Int @default(0)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
userAuthProviders UserAuthProvider[]
|
||||
|
||||
@@map("auth_providers")
|
||||
}
|
||||
|
||||
model UserAuthProvider {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
providerId String
|
||||
authProvider AuthProvider @relation(fields: [providerId], references: [id], onDelete: Cascade)
|
||||
|
||||
provider String?
|
||||
|
||||
externalId String
|
||||
metadata String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([userId, providerId])
|
||||
@@unique([providerId, externalId])
|
||||
@@map("user_auth_providers")
|
||||
}
|
||||
|
||||
model ReverseShare {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
description String?
|
||||
expiration DateTime?
|
||||
maxFiles Int?
|
||||
maxFileSize BigInt?
|
||||
allowedFileTypes String?
|
||||
password String?
|
||||
pageLayout PageLayout @default(DEFAULT)
|
||||
isActive Boolean @default(true)
|
||||
nameFieldRequired FieldRequirement @default(OPTIONAL)
|
||||
emailFieldRequired FieldRequirement @default(OPTIONAL)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
creatorId String
|
||||
creator User @relation(fields: [creatorId], references: [id], onDelete: Cascade)
|
||||
|
||||
files ReverseShareFile[]
|
||||
alias ReverseShareAlias?
|
||||
|
||||
@@map("reverse_shares")
|
||||
}
|
||||
|
||||
model ReverseShareFile {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
description String?
|
||||
extension String
|
||||
size BigInt
|
||||
objectName String
|
||||
uploaderEmail String?
|
||||
uploaderName String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
reverseShareId String
|
||||
reverseShare ReverseShare @relation(fields: [reverseShareId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("reverse_share_files")
|
||||
}
|
||||
|
||||
model ReverseShareAlias {
|
||||
id String @id @default(cuid())
|
||||
alias String @unique
|
||||
reverseShareId String @unique
|
||||
reverseShare ReverseShare @relation(fields: [reverseShareId], references: [id], onDelete: Cascade)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("reverse_share_aliases")
|
||||
}
|
||||
|
||||
enum FieldRequirement {
|
||||
HIDDEN
|
||||
OPTIONAL
|
||||
REQUIRED
|
||||
}
|
||||
|
||||
enum PageLayout {
|
||||
DEFAULT
|
||||
WETRANSFER
|
||||
}
|
||||
|
||||
model TrustedDevice {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
deviceHash String @unique
|
||||
deviceName String?
|
||||
userAgent String?
|
||||
ipAddress String?
|
||||
lastUsedAt DateTime @default(now())
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("trusted_devices")
|
||||
}
|
||||
generator client {
|
||||
provider = "prisma-client-js"
|
||||
}
|
||||
|
||||
datasource db {
|
||||
provider = "sqlite"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id @default(cuid())
|
||||
firstName String
|
||||
lastName String
|
||||
username String @unique
|
||||
email String @unique
|
||||
password String?
|
||||
image String?
|
||||
isAdmin Boolean @default(false)
|
||||
isActive Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
twoFactorEnabled Boolean @default(false)
|
||||
twoFactorSecret String?
|
||||
twoFactorBackupCodes String?
|
||||
twoFactorVerified Boolean @default(false)
|
||||
|
||||
files File[]
|
||||
folders Folder[]
|
||||
shares Share[]
|
||||
reverseShares ReverseShare[]
|
||||
|
||||
loginAttempts LoginAttempt?
|
||||
|
||||
passwordResets PasswordReset[]
|
||||
authProviders UserAuthProvider[]
|
||||
trustedDevices TrustedDevice[]
|
||||
|
||||
@@map("users")
|
||||
}
|
||||
|
||||
model File {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
description String?
|
||||
extension String
|
||||
size BigInt
|
||||
objectName String
|
||||
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
folderId String?
|
||||
folder Folder? @relation(fields: [folderId], references: [id], onDelete: Cascade)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
shares Share[] @relation("ShareFiles")
|
||||
|
||||
@@index([folderId])
|
||||
|
||||
@@map("files")
|
||||
}
|
||||
|
||||
model Share {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
views Int @default(0)
|
||||
expiration DateTime?
|
||||
description String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
creatorId String?
|
||||
creator User? @relation(fields: [creatorId], references: [id], onDelete: SetNull)
|
||||
|
||||
securityId String @unique
|
||||
security ShareSecurity @relation(fields: [securityId], references: [id])
|
||||
|
||||
files File[] @relation("ShareFiles")
|
||||
folders Folder[] @relation("ShareFolders")
|
||||
recipients ShareRecipient[]
|
||||
|
||||
alias ShareAlias?
|
||||
|
||||
@@map("shares")
|
||||
}
|
||||
|
||||
model ShareSecurity {
|
||||
id String @id @default(cuid())
|
||||
password String?
|
||||
maxViews Int?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
share Share?
|
||||
|
||||
@@map("share_security")
|
||||
}
|
||||
|
||||
model ShareRecipient {
|
||||
id String @id @default(cuid())
|
||||
email String
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
shareId String
|
||||
share Share @relation(fields: [shareId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("share_recipients")
|
||||
}
|
||||
|
||||
model AppConfig {
|
||||
id String @id @default(cuid())
|
||||
key String @unique
|
||||
value String
|
||||
type String
|
||||
group String
|
||||
isSystem Boolean @default(true)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("app_configs")
|
||||
}
|
||||
|
||||
model LoginAttempt {
|
||||
id String @id @default(cuid())
|
||||
userId String @unique
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
attempts Int @default(1)
|
||||
lastAttempt DateTime @default(now())
|
||||
|
||||
@@map("login_attempts")
|
||||
}
|
||||
|
||||
model PasswordReset {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
token String @unique
|
||||
expiresAt DateTime
|
||||
used Boolean @default(false)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("password_resets")
|
||||
}
|
||||
|
||||
model ShareAlias {
|
||||
id String @id @default(cuid())
|
||||
alias String @unique
|
||||
shareId String @unique
|
||||
share Share @relation(fields: [shareId], references: [id], onDelete: Cascade)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("share_aliases")
|
||||
}
|
||||
|
||||
model AuthProvider {
|
||||
id String @id @default(cuid())
|
||||
name String @unique
|
||||
displayName String
|
||||
type String
|
||||
icon String?
|
||||
enabled Boolean @default(false)
|
||||
|
||||
issuerUrl String?
|
||||
clientId String?
|
||||
clientSecret String?
|
||||
redirectUri String?
|
||||
scope String? @default("openid profile email")
|
||||
|
||||
authorizationEndpoint String?
|
||||
tokenEndpoint String?
|
||||
userInfoEndpoint String?
|
||||
|
||||
metadata String?
|
||||
|
||||
autoRegister Boolean @default(true)
|
||||
adminEmailDomains String?
|
||||
|
||||
sortOrder Int @default(0)
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
userAuthProviders UserAuthProvider[]
|
||||
|
||||
@@map("auth_providers")
|
||||
}
|
||||
|
||||
model UserAuthProvider {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
providerId String
|
||||
authProvider AuthProvider @relation(fields: [providerId], references: [id], onDelete: Cascade)
|
||||
|
||||
provider String?
|
||||
|
||||
externalId String
|
||||
metadata String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@unique([userId, providerId])
|
||||
@@unique([providerId, externalId])
|
||||
@@map("user_auth_providers")
|
||||
}
|
||||
|
||||
model ReverseShare {
|
||||
id String @id @default(cuid())
|
||||
name String?
|
||||
description String?
|
||||
expiration DateTime?
|
||||
maxFiles Int?
|
||||
maxFileSize BigInt?
|
||||
allowedFileTypes String?
|
||||
password String?
|
||||
pageLayout PageLayout @default(DEFAULT)
|
||||
isActive Boolean @default(true)
|
||||
nameFieldRequired FieldRequirement @default(OPTIONAL)
|
||||
emailFieldRequired FieldRequirement @default(OPTIONAL)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
creatorId String
|
||||
creator User @relation(fields: [creatorId], references: [id], onDelete: Cascade)
|
||||
|
||||
files ReverseShareFile[]
|
||||
alias ReverseShareAlias?
|
||||
|
||||
@@map("reverse_shares")
|
||||
}
|
||||
|
||||
model ReverseShareFile {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
description String?
|
||||
extension String
|
||||
size BigInt
|
||||
objectName String
|
||||
uploaderEmail String?
|
||||
uploaderName String?
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
reverseShareId String
|
||||
reverseShare ReverseShare @relation(fields: [reverseShareId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@map("reverse_share_files")
|
||||
}
|
||||
|
||||
model ReverseShareAlias {
|
||||
id String @id @default(cuid())
|
||||
alias String @unique
|
||||
reverseShareId String @unique
|
||||
reverseShare ReverseShare @relation(fields: [reverseShareId], references: [id], onDelete: Cascade)
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("reverse_share_aliases")
|
||||
}
|
||||
|
||||
enum FieldRequirement {
|
||||
HIDDEN
|
||||
OPTIONAL
|
||||
REQUIRED
|
||||
}
|
||||
|
||||
enum PageLayout {
|
||||
DEFAULT
|
||||
WETRANSFER
|
||||
}
|
||||
|
||||
model TrustedDevice {
|
||||
id String @id @default(cuid())
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
deviceHash String @unique
|
||||
deviceName String?
|
||||
userAgent String?
|
||||
ipAddress String?
|
||||
lastUsedAt DateTime @default(now())
|
||||
expiresAt DateTime
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@map("trusted_devices")
|
||||
}
|
||||
|
||||
model Folder {
|
||||
id String @id @default(cuid())
|
||||
name String
|
||||
description String?
|
||||
objectName String
|
||||
|
||||
parentId String?
|
||||
parent Folder? @relation("FolderHierarchy", fields: [parentId], references: [id], onDelete: Cascade)
|
||||
children Folder[] @relation("FolderHierarchy")
|
||||
|
||||
userId String
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
files File[]
|
||||
|
||||
shares Share[] @relation("ShareFolders")
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
@@index([userId])
|
||||
@@index([parentId])
|
||||
@@map("folders")
|
||||
}
|
||||
|
@@ -147,6 +147,12 @@ const defaultConfigs = [
|
||||
type: "boolean",
|
||||
group: "auth-providers",
|
||||
},
|
||||
{
|
||||
key: "passwordAuthEnabled",
|
||||
value: "true",
|
||||
type: "boolean",
|
||||
group: "security",
|
||||
},
|
||||
{
|
||||
key: "serverUrl",
|
||||
value: "http://localhost:3333",
|
||||
|
@@ -6,7 +6,7 @@
|
||||
echo "🔐 Palmr Password Reset Tool"
|
||||
echo "============================="
|
||||
|
||||
# Check if we're in the right directory
|
||||
# Check if we're in the right directory and set DATABASE_URL
|
||||
if [ ! -f "package.json" ]; then
|
||||
echo "❌ Error: This script must be run from the server directory (/app/server)"
|
||||
echo " Current directory: $(pwd)"
|
||||
@@ -14,18 +14,26 @@ if [ ! -f "package.json" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Set DATABASE_URL if not already set
|
||||
if [ -z "$DATABASE_URL" ]; then
|
||||
export DATABASE_URL="file:/app/server/prisma/palmr.db"
|
||||
fi
|
||||
|
||||
# Ensure database directory exists
|
||||
mkdir -p /app/server/prisma
|
||||
|
||||
# Function to check if tsx is available
|
||||
check_tsx() {
|
||||
# Check if tsx binary exists in node_modules
|
||||
if [ -f "node_modules/.bin/tsx" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
# Fallback: try npx
|
||||
if npx tsx --version >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -39,7 +47,7 @@ install_tsx_only() {
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
return $?
|
||||
}
|
||||
|
||||
@@ -62,7 +70,7 @@ ensure_prisma() {
|
||||
if [ -d "node_modules/@prisma/client" ] && [ -f "node_modules/@prisma/client/index.js" ]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
||||
echo "📦 Generating Prisma client..."
|
||||
if npx prisma generate --silent >/dev/null 2>&1; then
|
||||
echo "✅ Prisma client ready"
|
||||
@@ -81,14 +89,14 @@ if check_tsx; then
|
||||
echo "✅ tsx is ready"
|
||||
else
|
||||
echo "📦 tsx not found, installing..."
|
||||
|
||||
|
||||
# Try quick tsx-only install first
|
||||
if install_tsx_only && check_tsx; then
|
||||
echo "✅ tsx installed successfully"
|
||||
else
|
||||
echo "⚠️ Quick install failed, installing all dependencies..."
|
||||
install_all_deps
|
||||
|
||||
|
||||
# Final check
|
||||
if ! check_tsx; then
|
||||
echo "❌ Error: tsx is still not available after full installation"
|
||||
@@ -119,4 +127,4 @@ if [ -f "node_modules/.bin/tsx" ]; then
|
||||
node_modules/.bin/tsx src/scripts/reset-password.ts "$@"
|
||||
else
|
||||
npx tsx src/scripts/reset-password.ts "$@"
|
||||
fi
|
||||
fi
|
@@ -1,4 +1,5 @@
|
||||
import crypto from "node:crypto";
|
||||
import * as http from "node:http";
|
||||
import fastifyCookie from "@fastify/cookie";
|
||||
import { fastifyCors } from "@fastify/cors";
|
||||
import fastifyJwt from "@fastify/jwt";
|
||||
@@ -24,13 +25,38 @@ export async function buildApp() {
|
||||
},
|
||||
},
|
||||
logger: {
|
||||
level: "info",
|
||||
level: "warn",
|
||||
},
|
||||
bodyLimit: 1024 * 1024 * 1024 * 1024 * 1024,
|
||||
connectionTimeout: 0,
|
||||
keepAliveTimeout: envTimeoutOverrides.keepAliveTimeout,
|
||||
requestTimeout: envTimeoutOverrides.requestTimeout,
|
||||
trustProxy: true,
|
||||
maxParamLength: 500,
|
||||
onProtoPoisoning: "ignore",
|
||||
onConstructorPoisoning: "ignore",
|
||||
ignoreTrailingSlash: true,
|
||||
serverFactory: (handler: (req: any, res: any) => void) => {
|
||||
const server = http.createServer((req: http.IncomingMessage, res: http.ServerResponse) => {
|
||||
res.setTimeout(0);
|
||||
req.setTimeout(0);
|
||||
|
||||
req.on("close", () => {
|
||||
if (typeof global !== "undefined" && global.gc) {
|
||||
setImmediate(() => global.gc!());
|
||||
}
|
||||
});
|
||||
|
||||
handler(req, res);
|
||||
});
|
||||
|
||||
server.maxHeadersCount = 0;
|
||||
server.timeout = 0;
|
||||
server.keepAliveTimeout = envTimeoutOverrides.keepAliveTimeout;
|
||||
server.headersTimeout = envTimeoutOverrides.keepAliveTimeout + 1000;
|
||||
|
||||
return server;
|
||||
},
|
||||
}).withTypeProvider<ZodTypeProvider>();
|
||||
|
||||
app.setValidatorCompiler(validatorCompiler);
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import process from "node:process";
|
||||
import { S3Client } from "@aws-sdk/client-s3";
|
||||
|
||||
import { env } from "../env";
|
||||
@@ -14,21 +15,26 @@ export const storageConfig: StorageConfig = {
|
||||
forcePathStyle: env.S3_FORCE_PATH_STYLE === "true",
|
||||
};
|
||||
|
||||
export const s3Client =
|
||||
env.ENABLE_S3 === "true"
|
||||
? new S3Client({
|
||||
endpoint: storageConfig.useSSL
|
||||
? `https://${storageConfig.endpoint}${storageConfig.port ? `:${storageConfig.port}` : ""}`
|
||||
: `http://${storageConfig.endpoint}${storageConfig.port ? `:${storageConfig.port}` : ""}`,
|
||||
region: storageConfig.region,
|
||||
credentials: {
|
||||
accessKeyId: storageConfig.accessKey,
|
||||
secretAccessKey: storageConfig.secretKey,
|
||||
},
|
||||
forcePathStyle: storageConfig.forcePathStyle,
|
||||
})
|
||||
: null;
|
||||
if (storageConfig.useSSL && env.S3_REJECT_UNAUTHORIZED === "false") {
|
||||
const originalRejectUnauthorized = process.env.NODE_TLS_REJECT_UNAUTHORIZED;
|
||||
if (!originalRejectUnauthorized) {
|
||||
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
||||
(global as any).PALMR_ORIGINAL_TLS_SETTING = originalRejectUnauthorized;
|
||||
}
|
||||
}
|
||||
|
||||
export const s3Client = new S3Client({
|
||||
endpoint: storageConfig.useSSL
|
||||
? `https://${storageConfig.endpoint}${storageConfig.port ? `:${storageConfig.port}` : ""}`
|
||||
: `http://${storageConfig.endpoint}${storageConfig.port ? `:${storageConfig.port}` : ""}`,
|
||||
region: storageConfig.region,
|
||||
credentials: {
|
||||
accessKeyId: storageConfig.accessKey,
|
||||
secretAccessKey: storageConfig.secretKey,
|
||||
},
|
||||
forcePathStyle: storageConfig.forcePathStyle,
|
||||
});
|
||||
|
||||
export const bucketName = storageConfig.bucketName;
|
||||
|
||||
export const isS3Enabled = env.ENABLE_S3 === "true";
|
||||
export const isS3Enabled = true;
|
||||
|
@@ -18,6 +18,7 @@ export function registerSwagger(app: any) {
|
||||
{ name: "Auth Providers", description: "External authentication providers management" },
|
||||
{ name: "User", description: "User management endpoints" },
|
||||
{ name: "File", description: "File management endpoints" },
|
||||
{ name: "Folder", description: "Folder management endpoints" },
|
||||
{ name: "Share", description: "File sharing endpoints" },
|
||||
{ name: "Storage", description: "Storage management endpoints" },
|
||||
{ name: "App", description: "Application configuration endpoints" },
|
||||
|
@@ -1,18 +1,19 @@
|
||||
import { z } from "zod";
|
||||
|
||||
const envSchema = z.object({
|
||||
ENABLE_S3: z.union([z.literal("true"), z.literal("false")]).default("false"),
|
||||
ENCRYPTION_KEY: z.string().optional().default("palmr-default-encryption-key-2025"),
|
||||
S3_ENDPOINT: z.string().optional(),
|
||||
S3_ENDPOINT: z.string().min(1, "S3_ENDPOINT is required"),
|
||||
S3_PORT: z.string().optional(),
|
||||
S3_USE_SSL: z.string().optional(),
|
||||
S3_ACCESS_KEY: z.string().optional(),
|
||||
S3_SECRET_KEY: z.string().optional(),
|
||||
S3_REGION: z.string().optional(),
|
||||
S3_BUCKET_NAME: z.string().optional(),
|
||||
S3_ACCESS_KEY: z.string().min(1, "S3_ACCESS_KEY is required"),
|
||||
S3_SECRET_KEY: z.string().min(1, "S3_SECRET_KEY is required"),
|
||||
S3_REGION: z.string().min(1, "S3_REGION is required"),
|
||||
S3_BUCKET_NAME: z.string().min(1, "S3_BUCKET_NAME is required"),
|
||||
S3_FORCE_PATH_STYLE: z.union([z.literal("true"), z.literal("false")]).default("false"),
|
||||
S3_REJECT_UNAUTHORIZED: z.union([z.literal("true"), z.literal("false")]).default("true"),
|
||||
PRESIGNED_URL_EXPIRATION: z.string().optional().default("3600"),
|
||||
SECURE_SITE: z.union([z.literal("true"), z.literal("false")]).default("false"),
|
||||
DATABASE_URL: z.string().optional().default("file:/app/server/prisma/palmr.db"),
|
||||
CUSTOM_PATH: z.string().optional(),
|
||||
});
|
||||
|
||||
export const env = envSchema.parse(process.env);
|
||||
|
@@ -9,7 +9,7 @@ export class AppController {
|
||||
private logoService = new LogoService();
|
||||
private emailService = new EmailService();
|
||||
|
||||
async getAppInfo(request: FastifyRequest, reply: FastifyReply) {
|
||||
async getAppInfo(_request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const appInfo = await this.appService.getAppInfo();
|
||||
return reply.send(appInfo);
|
||||
@@ -18,7 +18,16 @@ export class AppController {
|
||||
}
|
||||
}
|
||||
|
||||
async getAllConfigs(request: FastifyRequest, reply: FastifyReply) {
|
||||
async getSystemInfo(_request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const systemInfo = await this.appService.getSystemInfo();
|
||||
return reply.send(systemInfo);
|
||||
} catch (error: any) {
|
||||
return reply.status(400).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async getAllConfigs(_request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const configs = await this.appService.getAllConfigs();
|
||||
return reply.send({ configs });
|
||||
@@ -27,6 +36,15 @@ export class AppController {
|
||||
}
|
||||
}
|
||||
|
||||
async getPublicConfigs(_request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const configs = await this.appService.getPublicConfigs();
|
||||
return reply.send({ configs });
|
||||
} catch (error: any) {
|
||||
return reply.status(400).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async updateConfig(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const { key } = request.params as { key: string };
|
||||
@@ -81,9 +99,8 @@ export class AppController {
|
||||
return reply.status(400).send({ error: "Only images are allowed" });
|
||||
}
|
||||
|
||||
// Logo files should be small (max 5MB), so we can safely use streaming to buffer
|
||||
const chunks: Buffer[] = [];
|
||||
const maxLogoSize = 5 * 1024 * 1024; // 5MB
|
||||
const maxLogoSize = 5 * 1024 * 1024;
|
||||
let totalSize = 0;
|
||||
|
||||
for await (const chunk of file.file) {
|
||||
@@ -105,7 +122,7 @@ export class AppController {
|
||||
}
|
||||
}
|
||||
|
||||
async removeLogo(request: FastifyRequest, reply: FastifyReply) {
|
||||
async removeLogo(_request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await this.logoService.deleteLogo();
|
||||
return reply.send({ message: "Logo removed successfully" });
|
||||
|
@@ -53,6 +53,26 @@ export async function appRoutes(app: FastifyInstance) {
|
||||
appController.getAppInfo.bind(appController)
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/app/system-info",
|
||||
{
|
||||
schema: {
|
||||
tags: ["App"],
|
||||
operationId: "getSystemInfo",
|
||||
summary: "Get system information",
|
||||
description: "Get system information including storage provider",
|
||||
response: {
|
||||
200: z.object({
|
||||
storageProvider: z.enum(["s3", "filesystem"]).describe("The active storage provider"),
|
||||
s3Enabled: z.boolean().describe("Whether S3 storage is enabled"),
|
||||
}),
|
||||
400: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
appController.getSystemInfo.bind(appController)
|
||||
);
|
||||
|
||||
app.patch(
|
||||
"/app/configs/:key",
|
||||
{
|
||||
@@ -82,15 +102,34 @@ export async function appRoutes(app: FastifyInstance) {
|
||||
appController.updateConfig.bind(appController)
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/app/configs/public",
|
||||
{
|
||||
schema: {
|
||||
tags: ["App"],
|
||||
operationId: "getPublicConfigs",
|
||||
summary: "List public configurations",
|
||||
description: "List public configurations (excludes sensitive data like SMTP credentials)",
|
||||
response: {
|
||||
200: z.object({
|
||||
configs: z.array(ConfigResponseSchema),
|
||||
}),
|
||||
400: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
appController.getPublicConfigs.bind(appController)
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/app/configs",
|
||||
{
|
||||
// preValidation: adminPreValidation,
|
||||
preValidation: adminPreValidation,
|
||||
schema: {
|
||||
tags: ["App"],
|
||||
operationId: "getAllConfigs",
|
||||
summary: "List all configurations",
|
||||
description: "List all configurations (admin only)",
|
||||
description: "List all configurations including sensitive data (admin only)",
|
||||
response: {
|
||||
200: z.object({
|
||||
configs: z.array(ConfigResponseSchema),
|
||||
|
@@ -1,3 +1,4 @@
|
||||
import { isS3Enabled } from "../../config/storage.config";
|
||||
import { prisma } from "../../shared/prisma";
|
||||
import { ConfigService } from "../config/service";
|
||||
|
||||
@@ -20,6 +21,13 @@ export class AppService {
|
||||
};
|
||||
}
|
||||
|
||||
async getSystemInfo() {
|
||||
return {
|
||||
storageProvider: isS3Enabled ? "s3" : "filesystem",
|
||||
s3Enabled: isS3Enabled,
|
||||
};
|
||||
}
|
||||
|
||||
async getAllConfigs() {
|
||||
return prisma.appConfig.findMany({
|
||||
where: {
|
||||
@@ -33,11 +41,46 @@ export class AppService {
|
||||
});
|
||||
}
|
||||
|
||||
async getPublicConfigs() {
|
||||
const sensitiveKeys = [
|
||||
"smtpHost",
|
||||
"smtpPort",
|
||||
"smtpUser",
|
||||
"smtpPass",
|
||||
"smtpSecure",
|
||||
"smtpNoAuth",
|
||||
"smtpTrustSelfSigned",
|
||||
"jwtSecret",
|
||||
];
|
||||
|
||||
return prisma.appConfig.findMany({
|
||||
where: {
|
||||
key: {
|
||||
notIn: sensitiveKeys,
|
||||
},
|
||||
},
|
||||
orderBy: {
|
||||
group: "asc",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async updateConfig(key: string, value: string) {
|
||||
if (key === "jwtSecret") {
|
||||
throw new Error("JWT Secret cannot be updated through this endpoint");
|
||||
}
|
||||
|
||||
if (key === "passwordAuthEnabled") {
|
||||
if (value === "false") {
|
||||
const canDisable = await this.configService.validatePasswordAuthDisable();
|
||||
if (!canDisable) {
|
||||
throw new Error(
|
||||
"Password authentication cannot be disabled. At least one authentication provider must be active."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const config = await prisma.appConfig.findUnique({
|
||||
where: { key },
|
||||
});
|
||||
@@ -56,6 +99,15 @@ export class AppService {
|
||||
if (updates.some((update) => update.key === "jwtSecret")) {
|
||||
throw new Error("JWT Secret cannot be updated through this endpoint");
|
||||
}
|
||||
const passwordAuthUpdate = updates.find((update) => update.key === "passwordAuthEnabled");
|
||||
if (passwordAuthUpdate && passwordAuthUpdate.value === "false") {
|
||||
const canDisable = await this.configService.validatePasswordAuthDisable();
|
||||
if (!canDisable) {
|
||||
throw new Error(
|
||||
"Password authentication cannot be disabled. At least one authentication provider must be active."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const keys = updates.map((update) => update.key);
|
||||
const existingConfigs = await prisma.appConfig.findMany({
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import { FastifyReply, FastifyRequest } from "fastify";
|
||||
|
||||
import { ConfigService } from "../config/service";
|
||||
import { UpdateAuthProviderSchema } from "./dto";
|
||||
import { AuthProvidersService } from "./service";
|
||||
import {
|
||||
@@ -39,9 +40,11 @@ const ERROR_MESSAGES = {
|
||||
|
||||
export class AuthProvidersController {
|
||||
private authProvidersService: AuthProvidersService;
|
||||
private configService: ConfigService;
|
||||
|
||||
constructor() {
|
||||
this.authProvidersService = new AuthProvidersService();
|
||||
this.configService = new ConfigService();
|
||||
}
|
||||
|
||||
private buildRequestContext(request: FastifyRequest): RequestContext {
|
||||
@@ -223,13 +226,24 @@ export class AuthProvidersController {
|
||||
|
||||
try {
|
||||
const { id } = request.params;
|
||||
const data = request.body;
|
||||
const data = request.body as any;
|
||||
|
||||
const existingProvider = await this.authProvidersService.getProviderById(id);
|
||||
if (!existingProvider) {
|
||||
return this.sendErrorResponse(reply, 404, ERROR_MESSAGES.PROVIDER_NOT_FOUND);
|
||||
}
|
||||
|
||||
if (data.enabled === false && existingProvider.enabled === true) {
|
||||
const canDisable = await this.configService.validateAllProvidersDisable();
|
||||
if (!canDisable) {
|
||||
return this.sendErrorResponse(
|
||||
reply,
|
||||
400,
|
||||
"Cannot disable the last authentication provider when password authentication is disabled"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const isOfficial = this.authProvidersService.isOfficialProvider(existingProvider.name);
|
||||
|
||||
if (isOfficial) {
|
||||
@@ -300,6 +314,17 @@ export class AuthProvidersController {
|
||||
return this.sendErrorResponse(reply, 400, ERROR_MESSAGES.OFFICIAL_CANNOT_DELETE);
|
||||
}
|
||||
|
||||
if (provider.enabled) {
|
||||
const canDisable = await this.configService.validateAllProvidersDisable();
|
||||
if (!canDisable) {
|
||||
return this.sendErrorResponse(
|
||||
reply,
|
||||
400,
|
||||
"Cannot delete the last authentication provider when password authentication is disabled"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
await this.authProvidersService.deleteProvider(id);
|
||||
return this.sendSuccessResponse(reply, undefined, "Provider deleted successfully");
|
||||
} catch (error) {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { FastifyReply, FastifyRequest } from "fastify";
|
||||
|
||||
import { env } from "../../env";
|
||||
import { ConfigService } from "../config/service";
|
||||
import {
|
||||
CompleteTwoFactorLoginSchema,
|
||||
createResetPasswordSchema,
|
||||
@@ -11,6 +12,7 @@ import { AuthService } from "./service";
|
||||
|
||||
export class AuthController {
|
||||
private authService = new AuthService();
|
||||
private configService = new ConfigService();
|
||||
|
||||
private getClientInfo(request: FastifyRequest) {
|
||||
const realIP = request.headers["x-real-ip"] as string;
|
||||
@@ -111,14 +113,21 @@ export class AuthController {
|
||||
|
||||
async getCurrentUser(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const userId = (request as any).user?.userId;
|
||||
let userId: string | null = null;
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
userId = (request as any).user?.userId;
|
||||
} catch (err) {
|
||||
return reply.send({ user: null });
|
||||
}
|
||||
|
||||
if (!userId) {
|
||||
return reply.status(401).send({ error: "Unauthorized: a valid token is required to access this resource." });
|
||||
return reply.send({ user: null });
|
||||
}
|
||||
|
||||
const user = await this.authService.getUserById(userId);
|
||||
if (!user) {
|
||||
return reply.status(404).send({ error: "User not found" });
|
||||
return reply.send({ user: null });
|
||||
}
|
||||
|
||||
return reply.send({ user });
|
||||
@@ -169,4 +178,15 @@ export class AuthController {
|
||||
return reply.status(400).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async getAuthConfig(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const passwordAuthEnabled = await this.configService.getValue("passwordAuthEnabled");
|
||||
return reply.send({
|
||||
passwordAuthEnabled: passwordAuthEnabled === "true",
|
||||
});
|
||||
} catch (error: any) {
|
||||
return reply.status(400).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -153,33 +153,29 @@ export async function authRoutes(app: FastifyInstance) {
|
||||
tags: ["Authentication"],
|
||||
operationId: "getCurrentUser",
|
||||
summary: "Get Current User",
|
||||
description: "Returns the current authenticated user's information",
|
||||
description: "Returns the current authenticated user's information or null if not authenticated",
|
||||
response: {
|
||||
200: z.object({
|
||||
user: z.object({
|
||||
id: z.string().describe("User ID"),
|
||||
firstName: z.string().describe("User first name"),
|
||||
lastName: z.string().describe("User last name"),
|
||||
username: z.string().describe("User username"),
|
||||
email: z.string().email().describe("User email"),
|
||||
image: z.string().nullable().describe("User profile image URL"),
|
||||
isAdmin: z.boolean().describe("User is admin"),
|
||||
isActive: z.boolean().describe("User is active"),
|
||||
createdAt: z.date().describe("User creation date"),
|
||||
updatedAt: z.date().describe("User last update date"),
|
||||
200: z.union([
|
||||
z.object({
|
||||
user: z.object({
|
||||
id: z.string().describe("User ID"),
|
||||
firstName: z.string().describe("User first name"),
|
||||
lastName: z.string().describe("User last name"),
|
||||
username: z.string().describe("User username"),
|
||||
email: z.string().email().describe("User email"),
|
||||
image: z.string().nullable().describe("User profile image URL"),
|
||||
isAdmin: z.boolean().describe("User is admin"),
|
||||
isActive: z.boolean().describe("User is active"),
|
||||
createdAt: z.date().describe("User creation date"),
|
||||
updatedAt: z.date().describe("User last update date"),
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
401: z.object({ error: z.string().describe("Error message") }),
|
||||
z.object({
|
||||
user: z.null().describe("No user when not authenticated"),
|
||||
}),
|
||||
]),
|
||||
},
|
||||
},
|
||||
preValidation: async (request: FastifyRequest, reply: FastifyReply) => {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
reply.status(401).send({ error: "Unauthorized: a valid token is required to access this resource." });
|
||||
}
|
||||
},
|
||||
},
|
||||
authController.getCurrentUser.bind(authController)
|
||||
);
|
||||
@@ -280,4 +276,23 @@ export async function authRoutes(app: FastifyInstance) {
|
||||
},
|
||||
authController.removeAllTrustedDevices.bind(authController)
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/auth/config",
|
||||
{
|
||||
schema: {
|
||||
tags: ["Authentication"],
|
||||
operationId: "getAuthConfig",
|
||||
summary: "Get Authentication Configuration",
|
||||
description: "Get authentication configuration settings",
|
||||
response: {
|
||||
200: z.object({
|
||||
passwordAuthEnabled: z.boolean().describe("Whether password authentication is enabled"),
|
||||
}),
|
||||
400: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
authController.getAuthConfig.bind(authController)
|
||||
);
|
||||
}
|
||||
|
@@ -18,6 +18,11 @@ export class AuthService {
|
||||
private trustedDeviceService = new TrustedDeviceService();
|
||||
|
||||
async login(data: LoginInput, userAgent?: string, ipAddress?: string) {
|
||||
const passwordAuthEnabled = await this.configService.getValue("passwordAuthEnabled");
|
||||
if (passwordAuthEnabled === "false") {
|
||||
throw new Error("Password authentication is disabled. Please use an external authentication provider.");
|
||||
}
|
||||
|
||||
const user = await this.userRepository.findUserByEmailOrUsername(data.emailOrUsername);
|
||||
if (!user) {
|
||||
throw new Error("Invalid credentials");
|
||||
@@ -146,6 +151,11 @@ export class AuthService {
|
||||
}
|
||||
|
||||
async requestPasswordReset(email: string, origin: string) {
|
||||
const passwordAuthEnabled = await this.configService.getValue("passwordAuthEnabled");
|
||||
if (passwordAuthEnabled === "false") {
|
||||
throw new Error("Password authentication is disabled. Password reset is not available.");
|
||||
}
|
||||
|
||||
const user = await this.userRepository.findUserByEmail(email);
|
||||
if (!user) {
|
||||
return;
|
||||
@@ -171,6 +181,11 @@ export class AuthService {
|
||||
}
|
||||
|
||||
async resetPassword(token: string, newPassword: string) {
|
||||
const passwordAuthEnabled = await this.configService.getValue("passwordAuthEnabled");
|
||||
if (passwordAuthEnabled === "false") {
|
||||
throw new Error("Password authentication is disabled. Password reset is not available.");
|
||||
}
|
||||
|
||||
const resetRequest = await prisma.passwordReset.findFirst({
|
||||
where: {
|
||||
token,
|
||||
|
263
apps/server/src/modules/bulk-download/controller.ts
Normal file
263
apps/server/src/modules/bulk-download/controller.ts
Normal file
@@ -0,0 +1,263 @@
|
||||
import { GetObjectCommand } from "@aws-sdk/client-s3";
|
||||
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
|
||||
import archiver from "archiver";
|
||||
import { FastifyReply, FastifyRequest } from "fastify";
|
||||
|
||||
import { bucketName, s3Client } from "../../config/storage.config";
|
||||
import { prisma } from "../../shared/prisma";
|
||||
import { ReverseShareService } from "../reverse-share/service";
|
||||
|
||||
export class BulkDownloadController {
|
||||
private reverseShareService = new ReverseShareService();
|
||||
|
||||
async downloadFiles(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const { fileIds, folderIds, zipName } = request.body as {
|
||||
fileIds: string[];
|
||||
folderIds: string[];
|
||||
zipName: string;
|
||||
};
|
||||
|
||||
if (!fileIds.length && !folderIds.length) {
|
||||
return reply.status(400).send({ error: "No files or folders to download" });
|
||||
}
|
||||
|
||||
// Get files from database
|
||||
const files = await prisma.file.findMany({
|
||||
where: {
|
||||
id: { in: fileIds },
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
objectName: true,
|
||||
size: true,
|
||||
},
|
||||
});
|
||||
|
||||
// Get folders and their files
|
||||
const folders = await prisma.folder.findMany({
|
||||
where: {
|
||||
id: { in: folderIds },
|
||||
},
|
||||
include: {
|
||||
files: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
objectName: true,
|
||||
size: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
// Create ZIP stream
|
||||
const archive = archiver("zip", {
|
||||
zlib: { level: 9 },
|
||||
});
|
||||
|
||||
reply.raw.setHeader("Content-Type", "application/zip");
|
||||
reply.raw.setHeader("Content-Disposition", `attachment; filename="${zipName}"`);
|
||||
reply.raw.setHeader("Transfer-Encoding", "chunked");
|
||||
|
||||
archive.pipe(reply.raw);
|
||||
|
||||
// Add files to ZIP
|
||||
for (const file of files) {
|
||||
try {
|
||||
const downloadUrl = await getSignedUrl(
|
||||
s3Client,
|
||||
new GetObjectCommand({
|
||||
Bucket: bucketName,
|
||||
Key: file.objectName,
|
||||
}),
|
||||
{ expiresIn: 300 } // 5 minutes
|
||||
);
|
||||
|
||||
const response = await fetch(downloadUrl);
|
||||
if (response.ok) {
|
||||
const buffer = await response.arrayBuffer();
|
||||
archive.append(Buffer.from(buffer), { name: file.name });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error downloading file ${file.name}:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
// Add folder files to ZIP
|
||||
for (const folder of folders) {
|
||||
for (const file of folder.files) {
|
||||
try {
|
||||
const downloadUrl = await getSignedUrl(
|
||||
s3Client,
|
||||
new GetObjectCommand({
|
||||
Bucket: bucketName,
|
||||
Key: file.objectName,
|
||||
}),
|
||||
{ expiresIn: 300 }
|
||||
);
|
||||
|
||||
const response = await fetch(downloadUrl);
|
||||
if (response.ok) {
|
||||
const buffer = await response.arrayBuffer();
|
||||
archive.append(Buffer.from(buffer), {
|
||||
name: `${folder.name}/${file.name}`,
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error downloading file ${file.name}:`, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await archive.finalize();
|
||||
} catch (error) {
|
||||
console.error("Bulk download error:", error);
|
||||
return reply.status(500).send({ error: "Internal server error" });
|
||||
}
|
||||
}
|
||||
|
||||
async downloadFolder(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const { folderId, folderName } = request.params as {
|
||||
folderId: string;
|
||||
folderName: string;
|
||||
};
|
||||
|
||||
// Get folder and all its files recursively
|
||||
const folder = await prisma.folder.findUnique({
|
||||
where: { id: folderId },
|
||||
include: {
|
||||
files: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
objectName: true,
|
||||
size: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!folder) {
|
||||
return reply.status(404).send({ error: "Folder not found" });
|
||||
}
|
||||
|
||||
// Create ZIP stream
|
||||
const archive = archiver("zip", {
|
||||
zlib: { level: 9 },
|
||||
});
|
||||
|
||||
reply.raw.setHeader("Content-Type", "application/zip");
|
||||
reply.raw.setHeader("Content-Disposition", `attachment; filename="${folderName}.zip"`);
|
||||
reply.raw.setHeader("Transfer-Encoding", "chunked");
|
||||
|
||||
archive.pipe(reply.raw);
|
||||
|
||||
// Add all files to ZIP
|
||||
for (const file of folder.files) {
|
||||
try {
|
||||
const downloadUrl = await getSignedUrl(
|
||||
s3Client,
|
||||
new GetObjectCommand({
|
||||
Bucket: bucketName,
|
||||
Key: file.objectName,
|
||||
}),
|
||||
{ expiresIn: 300 }
|
||||
);
|
||||
|
||||
const response = await fetch(downloadUrl);
|
||||
if (response.ok) {
|
||||
const buffer = await response.arrayBuffer();
|
||||
archive.append(Buffer.from(buffer), { name: file.name });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error downloading file ${file.name}:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
await archive.finalize();
|
||||
} catch (error) {
|
||||
console.error("Folder download error:", error);
|
||||
return reply.status(500).send({ error: "Internal server error" });
|
||||
}
|
||||
}
|
||||
|
||||
async downloadReverseShareFiles(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const userId = (request as any).user?.userId;
|
||||
if (!userId) {
|
||||
return reply.status(401).send({ error: "Unauthorized: a valid token is required to access this resource." });
|
||||
}
|
||||
|
||||
const { fileIds, zipName } = request.body as {
|
||||
fileIds: string[];
|
||||
zipName: string;
|
||||
};
|
||||
|
||||
if (!fileIds.length) {
|
||||
return reply.status(400).send({ error: "No files to download" });
|
||||
}
|
||||
|
||||
// Get reverse share files from database
|
||||
const files = await prisma.reverseShareFile.findMany({
|
||||
where: {
|
||||
id: { in: fileIds },
|
||||
reverseShare: {
|
||||
creatorId: userId, // Only allow creator to download
|
||||
},
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
objectName: true,
|
||||
size: true,
|
||||
},
|
||||
});
|
||||
|
||||
if (files.length === 0) {
|
||||
return reply.status(404).send({ error: "No files found or unauthorized" });
|
||||
}
|
||||
|
||||
// Create ZIP stream
|
||||
const archive = archiver("zip", {
|
||||
zlib: { level: 9 },
|
||||
});
|
||||
|
||||
reply.raw.setHeader("Content-Type", "application/zip");
|
||||
reply.raw.setHeader("Content-Disposition", `attachment; filename="${zipName}"`);
|
||||
reply.raw.setHeader("Transfer-Encoding", "chunked");
|
||||
|
||||
archive.pipe(reply.raw);
|
||||
|
||||
// Add files to ZIP
|
||||
for (const file of files) {
|
||||
try {
|
||||
const downloadUrl = await getSignedUrl(
|
||||
s3Client,
|
||||
new GetObjectCommand({
|
||||
Bucket: bucketName,
|
||||
Key: file.objectName,
|
||||
}),
|
||||
{ expiresIn: 300 } // 5 minutes
|
||||
);
|
||||
|
||||
const response = await fetch(downloadUrl);
|
||||
if (response.ok) {
|
||||
const buffer = await response.arrayBuffer();
|
||||
archive.append(Buffer.from(buffer), { name: file.name });
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error downloading reverse share file ${file.name}:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
await archive.finalize();
|
||||
} catch (error) {
|
||||
console.error("Reverse share bulk download error:", error);
|
||||
return reply.status(500).send({ error: "Internal server error" });
|
||||
}
|
||||
}
|
||||
}
|
88
apps/server/src/modules/bulk-download/routes.ts
Normal file
88
apps/server/src/modules/bulk-download/routes.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
||||
import { z } from "zod";
|
||||
|
||||
import { BulkDownloadController } from "./controller";
|
||||
|
||||
export async function bulkDownloadRoutes(app: FastifyInstance) {
|
||||
const bulkDownloadController = new BulkDownloadController();
|
||||
|
||||
const preValidation = async (request: FastifyRequest, reply: FastifyReply) => {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
reply.status(401).send({ error: "Token inválido ou ausente." });
|
||||
}
|
||||
};
|
||||
|
||||
app.post(
|
||||
"/bulk-download",
|
||||
{
|
||||
schema: {
|
||||
tags: ["Bulk Download"],
|
||||
operationId: "bulkDownloadFiles",
|
||||
summary: "Download multiple files as ZIP",
|
||||
description: "Downloads multiple files and folders as a ZIP archive",
|
||||
body: z.object({
|
||||
fileIds: z.array(z.string()).describe("Array of file IDs to download"),
|
||||
folderIds: z.array(z.string()).describe("Array of folder IDs to download"),
|
||||
zipName: z.string().describe("Name of the ZIP file"),
|
||||
}),
|
||||
response: {
|
||||
200: z.string().describe("ZIP file stream"),
|
||||
400: z.object({ error: z.string().describe("Error message") }),
|
||||
500: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
bulkDownloadController.downloadFiles.bind(bulkDownloadController)
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/bulk-download/folder/:folderId/:folderName",
|
||||
{
|
||||
schema: {
|
||||
tags: ["Bulk Download"],
|
||||
operationId: "downloadFolder",
|
||||
summary: "Download folder as ZIP",
|
||||
description: "Downloads a folder and all its files as a ZIP archive",
|
||||
params: z.object({
|
||||
folderId: z.string().describe("Folder ID"),
|
||||
folderName: z.string().describe("Folder name"),
|
||||
}),
|
||||
response: {
|
||||
200: z.string().describe("ZIP file stream"),
|
||||
404: z.object({ error: z.string().describe("Error message") }),
|
||||
500: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
bulkDownloadController.downloadFolder.bind(bulkDownloadController)
|
||||
);
|
||||
|
||||
app.post(
|
||||
"/bulk-download/reverse-share",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["Bulk Download"],
|
||||
operationId: "bulkDownloadReverseShareFiles",
|
||||
summary: "Download multiple reverse share files as ZIP",
|
||||
description:
|
||||
"Downloads multiple reverse share files as a ZIP archive. Only the creator of the reverse share can download files.",
|
||||
body: z.object({
|
||||
fileIds: z.array(z.string()).describe("Array of reverse share file IDs to download"),
|
||||
zipName: z.string().describe("Name of the ZIP file"),
|
||||
}),
|
||||
response: {
|
||||
200: z.string().describe("ZIP file stream"),
|
||||
400: z.object({ error: z.string().describe("Error message") }),
|
||||
401: z.object({ error: z.string().describe("Unauthorized") }),
|
||||
404: z.object({ error: z.string().describe("No files found or unauthorized") }),
|
||||
500: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
bulkDownloadController.downloadReverseShareFiles.bind(bulkDownloadController)
|
||||
);
|
||||
}
|
@@ -13,6 +13,26 @@ export class ConfigService {
|
||||
return config.value;
|
||||
}
|
||||
|
||||
async setValue(key: string, value: string): Promise<void> {
|
||||
await prisma.appConfig.update({
|
||||
where: { key },
|
||||
data: { value },
|
||||
});
|
||||
}
|
||||
|
||||
async validatePasswordAuthDisable(): Promise<boolean> {
|
||||
const enabledProviders = await prisma.authProvider.findMany({
|
||||
where: { enabled: true },
|
||||
});
|
||||
|
||||
return enabledProviders.length > 0;
|
||||
}
|
||||
|
||||
async validateAllProvidersDisable(): Promise<boolean> {
|
||||
const passwordAuthEnabled = await this.getValue("passwordAuthEnabled");
|
||||
return passwordAuthEnabled === "true";
|
||||
}
|
||||
|
||||
async getGroupConfigs(group: string) {
|
||||
const configs = await prisma.appConfig.findMany({
|
||||
where: { group },
|
||||
|
@@ -167,7 +167,7 @@ export class EmailService {
|
||||
});
|
||||
}
|
||||
|
||||
async sendShareNotification(to: string, shareLink: string, shareName?: string) {
|
||||
async sendShareNotification(to: string, shareLink: string, shareName?: string, senderName?: string) {
|
||||
const transporter = await this.createTransporter();
|
||||
if (!transporter) {
|
||||
throw new Error("SMTP is not enabled");
|
||||
@@ -178,19 +178,151 @@ export class EmailService {
|
||||
const appName = await this.configService.getValue("appName");
|
||||
|
||||
const shareTitle = shareName || "Files";
|
||||
const sender = senderName || "Someone";
|
||||
|
||||
await transporter.sendMail({
|
||||
from: `"${fromName}" <${fromEmail}>`,
|
||||
to,
|
||||
subject: `${appName} - ${shareTitle} shared with you`,
|
||||
html: `
|
||||
<h1>${appName} - Shared Files</h1>
|
||||
<p>Someone has shared "${shareTitle}" with you.</p>
|
||||
<p>Click the link below to access the shared files:</p>
|
||||
<a href="${shareLink}">
|
||||
Access Shared Files
|
||||
</a>
|
||||
<p>Note: This share may have an expiration date or view limit.</p>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>${appName} - Shared Files</title>
|
||||
</head>
|
||||
<body style="margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background-color: #f5f5f5; color: #333333;">
|
||||
<div style="max-width: 600px; margin: 0 auto; background-color: #ffffff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); overflow: hidden; margin-top: 40px; margin-bottom: 40px;">
|
||||
<!-- Header -->
|
||||
<div style="background-color: #22B14C; padding: 30px 20px; text-align: center;">
|
||||
<h1 style="margin: 0; color: #ffffff; font-size: 28px; font-weight: 600; letter-spacing: -0.5px;">${appName}</h1>
|
||||
<p style="margin: 2px 0 0 0; color: #ffffff; font-size: 16px; opacity: 0.9;">Shared Files</p>
|
||||
</div>
|
||||
|
||||
<!-- Content -->
|
||||
<div style="padding: 40px 30px;">
|
||||
<div style="text-align: center; margin-bottom: 32px;">
|
||||
<h2 style="margin: 0 0 12px 0; color: #1f2937; font-size: 24px; font-weight: 600;">Files Shared With You</h2>
|
||||
<p style="margin: 0; color: #6b7280; font-size: 16px; line-height: 1.6;">
|
||||
<strong style="color: #374151;">${sender}</strong> has shared <strong style="color: #374151;">"${shareTitle}"</strong> with you.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- CTA Button -->
|
||||
<div style="text-align: center; margin: 32px 0;">
|
||||
<a href="${shareLink}" style="display: inline-block; background-color: #22B14C; color: #ffffff; text-decoration: none; padding: 12px 24px; font-weight: 600; font-size: 16px; border: 2px solid #22B14C; border-radius: 8px; transition: all 0.3s ease;">
|
||||
Access Shared Files
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- Info Box -->
|
||||
<div style="background-color: #f9fafb; border-left: 4px solid #22B14C; padding: 16px 20px; margin-top: 32px;">
|
||||
<p style="margin: 0; color: #4b5563; font-size: 14px; line-height: 1.5;">
|
||||
<strong>Important:</strong> This share may have an expiration date or view limit. Access it as soon as possible to ensure availability.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<div style="background-color: #f9fafb; padding: 24px 30px; text-align: center; border-top: 1px solid #e5e7eb;">
|
||||
<p style="margin: 0; color: #6b7280; font-size: 14px;">
|
||||
This email was sent by <strong>${appName}</strong>
|
||||
</p>
|
||||
<p style="margin: 8px 0 0 0; color: #9ca3af; font-size: 12px;">
|
||||
If you didn't expect this email, you can safely ignore it.
|
||||
</p>
|
||||
<p style="margin: 4px 0 0 0; color: #9ca3af; font-size: 10px;">
|
||||
Powered by <a href="https://kyantech.com.br" style="color: #9ca3af; text-decoration: none;">Kyantech Solutions</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
`,
|
||||
});
|
||||
}
|
||||
|
||||
async sendReverseShareBatchFileNotification(
|
||||
recipientEmail: string,
|
||||
reverseShareName: string,
|
||||
fileCount: number,
|
||||
fileList: string,
|
||||
uploaderName: string
|
||||
) {
|
||||
const transporter = await this.createTransporter();
|
||||
if (!transporter) {
|
||||
throw new Error("SMTP is not enabled");
|
||||
}
|
||||
|
||||
const fromName = await this.configService.getValue("smtpFromName");
|
||||
const fromEmail = await this.configService.getValue("smtpFromEmail");
|
||||
const appName = await this.configService.getValue("appName");
|
||||
|
||||
await transporter.sendMail({
|
||||
from: `"${fromName}" <${fromEmail}>`,
|
||||
to: recipientEmail,
|
||||
subject: `${appName} - ${fileCount} file${fileCount > 1 ? "s" : ""} uploaded to "${reverseShareName}"`,
|
||||
html: `
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>${appName} - File Upload Notification</title>
|
||||
</head>
|
||||
<body style="margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; background-color: #f5f5f5; color: #333333;">
|
||||
<div style="max-width: 600px; margin: 0 auto; background-color: #ffffff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1); overflow: hidden; margin-top: 40px; margin-bottom: 40px;">
|
||||
<!-- Header -->
|
||||
<div style="background-color: #22B14C; padding: 30px 20px; text-align: center;">
|
||||
<h1 style="margin: 0; color: #ffffff; font-size: 28px; font-weight: 600; letter-spacing: -0.5px;">${appName}</h1>
|
||||
<p style="margin: 2px 0 0 0; color: #ffffff; font-size: 16px; opacity: 0.9;">File Upload Notification</p>
|
||||
</div>
|
||||
|
||||
<!-- Content -->
|
||||
<div style="padding: 40px 30px;">
|
||||
<div style="text-align: center; margin-bottom: 32px;">
|
||||
<h2 style="margin: 0 0 12px 0; color: #1f2937; font-size: 24px; font-weight: 600;">New File Uploaded</h2>
|
||||
<p style="margin: 0; color: #6b7280; font-size: 16px; line-height: 1.6;">
|
||||
<strong style="color: #374151;">${uploaderName}</strong> has uploaded <strong style="color: #374151;">${fileCount} file${fileCount > 1 ? "s" : ""}</strong> to your reverse share <strong style="color: #374151;">"${reverseShareName}"</strong>.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- File List -->
|
||||
<div style="background-color: #f9fafb; border-radius: 8px; padding: 16px; margin: 32px 0; border-left: 4px solid #22B14C;">
|
||||
<p style="margin: 0 0 8px 0; color: #374151; font-size: 14px;"><strong>Files (${fileCount}):</strong></p>
|
||||
<ul style="margin: 0; padding-left: 20px; color: #6b7280; font-size: 14px; line-height: 1.5;">
|
||||
${fileList
|
||||
.split(", ")
|
||||
.map((file) => `<li style="margin: 4px 0;">${file}</li>`)
|
||||
.join("")}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- Info Text -->
|
||||
<div style="text-align: center; margin-top: 32px;">
|
||||
<p style="margin: 0; color: #9ca3af; font-size: 12px;">
|
||||
You can now access and manage these files through your dashboard.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<div style="background-color: #f9fafb; padding: 24px 30px; text-align: center; border-top: 1px solid #e5e7eb;">
|
||||
<p style="margin: 0; color: #6b7280; font-size: 14px;">
|
||||
This email was sent by <strong>${appName}</strong>
|
||||
</p>
|
||||
<p style="margin: 8px 0 0 0; color: #9ca3af; font-size: 12px;">
|
||||
If you didn't expect this email, you can safely ignore it.
|
||||
</p>
|
||||
<p style="margin: 4px 0 0 0; color: #9ca3af; font-size: 10px;">
|
||||
Powered by <a href="https://kyantech.com.br" style="color: #9ca3af; text-decoration: none;">Kyantech Solutions</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
`,
|
||||
});
|
||||
}
|
||||
|
@@ -1,8 +1,21 @@
|
||||
import bcrypt from "bcryptjs";
|
||||
import { FastifyReply, FastifyRequest } from "fastify";
|
||||
|
||||
import { env } from "../../env";
|
||||
import { prisma } from "../../shared/prisma";
|
||||
import { ConfigService } from "../config/service";
|
||||
import { CheckFileInput, CheckFileSchema, RegisterFileInput, RegisterFileSchema, UpdateFileSchema } from "./dto";
|
||||
import {
|
||||
CheckFileInput,
|
||||
CheckFileSchema,
|
||||
ListFilesInput,
|
||||
ListFilesSchema,
|
||||
MoveFileInput,
|
||||
MoveFileSchema,
|
||||
RegisterFileInput,
|
||||
RegisterFileSchema,
|
||||
UpdateFileInput,
|
||||
UpdateFileSchema,
|
||||
} from "./dto";
|
||||
import { FileService } from "./service";
|
||||
|
||||
export class FileController {
|
||||
@@ -27,7 +40,7 @@ export class FileController {
|
||||
}
|
||||
|
||||
const objectName = `${userId}/${Date.now()}-${filename}.${extension}`;
|
||||
const expires = 3600;
|
||||
const expires = parseInt(env.PRESIGNED_URL_EXPIRATION);
|
||||
|
||||
const url = await this.fileService.getPresignedPutUrl(objectName, expires);
|
||||
return reply.send({ url, objectName });
|
||||
@@ -71,6 +84,15 @@ export class FileController {
|
||||
});
|
||||
}
|
||||
|
||||
if (input.folderId) {
|
||||
const folder = await prisma.folder.findFirst({
|
||||
where: { id: input.folderId, userId },
|
||||
});
|
||||
if (!folder) {
|
||||
return reply.status(400).send({ error: "Folder not found or access denied." });
|
||||
}
|
||||
}
|
||||
|
||||
const fileRecord = await prisma.file.create({
|
||||
data: {
|
||||
name: input.name,
|
||||
@@ -79,6 +101,7 @@ export class FileController {
|
||||
size: BigInt(input.size),
|
||||
objectName: input.objectName,
|
||||
userId,
|
||||
folderId: input.folderId,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -90,6 +113,7 @@ export class FileController {
|
||||
size: fileRecord.size.toString(),
|
||||
objectName: fileRecord.objectName,
|
||||
userId: fileRecord.userId,
|
||||
folderId: fileRecord.folderId,
|
||||
createdAt: fileRecord.createdAt,
|
||||
updatedAt: fileRecord.updatedAt,
|
||||
};
|
||||
@@ -160,6 +184,7 @@ export class FileController {
|
||||
objectName: string;
|
||||
};
|
||||
const objectName = decodeURIComponent(encodedObjectName);
|
||||
const { password } = request.query as { password?: string };
|
||||
|
||||
if (!objectName) {
|
||||
return reply.status(400).send({ error: "The 'objectName' parameter is required." });
|
||||
@@ -170,8 +195,53 @@ export class FileController {
|
||||
if (!fileRecord) {
|
||||
return reply.status(404).send({ error: "File not found." });
|
||||
}
|
||||
|
||||
let hasAccess = false;
|
||||
|
||||
console.log("Requested file with password " + password);
|
||||
|
||||
const shares = await prisma.share.findMany({
|
||||
where: {
|
||||
files: {
|
||||
some: {
|
||||
id: fileRecord.id,
|
||||
},
|
||||
},
|
||||
},
|
||||
include: {
|
||||
security: true,
|
||||
},
|
||||
});
|
||||
|
||||
for (const share of shares) {
|
||||
if (!share.security.password) {
|
||||
hasAccess = true;
|
||||
break;
|
||||
} else if (password) {
|
||||
const isPasswordValid = await bcrypt.compare(password, share.security.password);
|
||||
if (isPasswordValid) {
|
||||
hasAccess = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasAccess) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const userId = (request as any).user?.userId;
|
||||
if (userId && fileRecord.userId === userId) {
|
||||
hasAccess = true;
|
||||
}
|
||||
} catch (err) {}
|
||||
}
|
||||
|
||||
if (!hasAccess) {
|
||||
return reply.status(401).send({ error: "Unauthorized access to file." });
|
||||
}
|
||||
|
||||
const fileName = fileRecord.name;
|
||||
const expires = 3600;
|
||||
const expires = parseInt(env.PRESIGNED_URL_EXPIRATION);
|
||||
const url = await this.fileService.getPresignedGetUrl(objectName, expires, fileName);
|
||||
return reply.send({ url, expiresIn: expires });
|
||||
} catch (error) {
|
||||
@@ -188,18 +258,43 @@ export class FileController {
|
||||
return reply.status(401).send({ error: "Unauthorized: a valid token is required to access this resource." });
|
||||
}
|
||||
|
||||
const files = await prisma.file.findMany({
|
||||
where: { userId },
|
||||
});
|
||||
const input: ListFilesInput = ListFilesSchema.parse(request.query);
|
||||
const { folderId, recursive: recursiveStr } = input;
|
||||
const recursive = recursiveStr === "false" ? false : true;
|
||||
|
||||
const filesResponse = files.map((file) => ({
|
||||
let files: any[];
|
||||
|
||||
let targetFolderId: string | null;
|
||||
if (folderId === "null" || folderId === "" || !folderId) {
|
||||
targetFolderId = null; // Root folder
|
||||
} else {
|
||||
targetFolderId = folderId;
|
||||
}
|
||||
|
||||
if (recursive) {
|
||||
if (targetFolderId === null) {
|
||||
files = await this.getAllUserFilesRecursively(userId);
|
||||
} else {
|
||||
const { FolderService } = await import("../folder/service.js");
|
||||
const folderService = new FolderService();
|
||||
files = await folderService.getAllFilesInFolder(targetFolderId, userId);
|
||||
}
|
||||
} else {
|
||||
files = await prisma.file.findMany({
|
||||
where: { userId, folderId: targetFolderId },
|
||||
});
|
||||
}
|
||||
|
||||
const filesResponse = files.map((file: any) => ({
|
||||
id: file.id,
|
||||
name: file.name,
|
||||
description: file.description,
|
||||
extension: file.extension,
|
||||
size: file.size.toString(),
|
||||
size: typeof file.size === "bigint" ? file.size.toString() : file.size,
|
||||
objectName: file.objectName,
|
||||
userId: file.userId,
|
||||
folderId: file.folderId,
|
||||
relativePath: file.relativePath || null,
|
||||
createdAt: file.createdAt,
|
||||
updatedAt: file.updatedAt,
|
||||
}));
|
||||
@@ -277,6 +372,7 @@ export class FileController {
|
||||
size: updatedFile.size.toString(),
|
||||
objectName: updatedFile.objectName,
|
||||
userId: updatedFile.userId,
|
||||
folderId: updatedFile.folderId,
|
||||
createdAt: updatedFile.createdAt,
|
||||
updatedAt: updatedFile.updatedAt,
|
||||
};
|
||||
@@ -290,4 +386,86 @@ export class FileController {
|
||||
return reply.status(400).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async moveFile(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const userId = (request as any).user?.userId;
|
||||
|
||||
if (!userId) {
|
||||
return reply.status(401).send({ error: "Unauthorized: a valid token is required to access this resource." });
|
||||
}
|
||||
|
||||
const { id } = request.params as { id: string };
|
||||
const input: MoveFileInput = MoveFileSchema.parse(request.body);
|
||||
|
||||
const existingFile = await prisma.file.findFirst({
|
||||
where: { id, userId },
|
||||
});
|
||||
|
||||
if (!existingFile) {
|
||||
return reply.status(404).send({ error: "File not found." });
|
||||
}
|
||||
|
||||
if (input.folderId) {
|
||||
const targetFolder = await prisma.folder.findFirst({
|
||||
where: { id: input.folderId, userId },
|
||||
});
|
||||
if (!targetFolder) {
|
||||
return reply.status(400).send({ error: "Target folder not found." });
|
||||
}
|
||||
}
|
||||
|
||||
const updatedFile = await prisma.file.update({
|
||||
where: { id },
|
||||
data: { folderId: input.folderId },
|
||||
});
|
||||
|
||||
const fileResponse = {
|
||||
id: updatedFile.id,
|
||||
name: updatedFile.name,
|
||||
description: updatedFile.description,
|
||||
extension: updatedFile.extension,
|
||||
size: updatedFile.size.toString(),
|
||||
objectName: updatedFile.objectName,
|
||||
userId: updatedFile.userId,
|
||||
folderId: updatedFile.folderId,
|
||||
createdAt: updatedFile.createdAt,
|
||||
updatedAt: updatedFile.updatedAt,
|
||||
};
|
||||
|
||||
return reply.send({
|
||||
file: fileResponse,
|
||||
message: "File moved successfully.",
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.error("Error moving file:", error);
|
||||
return reply.status(400).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
private async getAllUserFilesRecursively(userId: string): Promise<any[]> {
|
||||
const rootFiles = await prisma.file.findMany({
|
||||
where: { userId, folderId: null },
|
||||
});
|
||||
|
||||
const rootFolders = await prisma.folder.findMany({
|
||||
where: { userId, parentId: null },
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
let allFiles = [...rootFiles];
|
||||
|
||||
if (rootFolders.length > 0) {
|
||||
const { FolderService } = await import("../folder/service.js");
|
||||
const folderService = new FolderService();
|
||||
|
||||
for (const folder of rootFolders) {
|
||||
const folderFiles = await folderService.getAllFilesInFolder(folder.id, userId);
|
||||
allFiles = [...allFiles, ...folderFiles];
|
||||
}
|
||||
}
|
||||
|
||||
return allFiles;
|
||||
}
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@ export const RegisterFileSchema = z.object({
|
||||
invalid_type_error: "O tamanho deve ser um número",
|
||||
}),
|
||||
objectName: z.string().min(1, "O objectName é obrigatório"),
|
||||
folderId: z.string().optional(),
|
||||
});
|
||||
|
||||
export const CheckFileSchema = z.object({
|
||||
@@ -20,6 +21,7 @@ export const CheckFileSchema = z.object({
|
||||
invalid_type_error: "O tamanho deve ser um número",
|
||||
}),
|
||||
objectName: z.string().min(1, "O objectName é obrigatório"),
|
||||
folderId: z.string().optional(),
|
||||
});
|
||||
|
||||
export type RegisterFileInput = z.infer<typeof RegisterFileSchema>;
|
||||
@@ -30,4 +32,15 @@ export const UpdateFileSchema = z.object({
|
||||
description: z.string().optional().nullable().describe("The file description"),
|
||||
});
|
||||
|
||||
export const MoveFileSchema = z.object({
|
||||
folderId: z.string().nullable(),
|
||||
});
|
||||
|
||||
export const ListFilesSchema = z.object({
|
||||
folderId: z.string().optional().describe("The folder ID"),
|
||||
recursive: z.string().optional().default("true").describe("Include files from subfolders"),
|
||||
});
|
||||
|
||||
export type UpdateFileInput = z.infer<typeof UpdateFileSchema>;
|
||||
export type MoveFileInput = z.infer<typeof MoveFileSchema>;
|
||||
export type ListFilesInput = z.infer<typeof ListFilesSchema>;
|
||||
|
@@ -2,7 +2,7 @@ import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
||||
import { z } from "zod";
|
||||
|
||||
import { FileController } from "./controller";
|
||||
import { CheckFileSchema, RegisterFileSchema, UpdateFileSchema } from "./dto";
|
||||
import { CheckFileSchema, ListFilesSchema, MoveFileSchema, RegisterFileSchema, UpdateFileSchema } from "./dto";
|
||||
|
||||
export async function fileRoutes(app: FastifyInstance) {
|
||||
const fileController = new FileController();
|
||||
@@ -62,6 +62,7 @@ export async function fileRoutes(app: FastifyInstance) {
|
||||
size: z.string().describe("The file size"),
|
||||
objectName: z.string().describe("The object name of the file"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
folderId: z.string().nullable().describe("The folder ID"),
|
||||
createdAt: z.date().describe("The file creation date"),
|
||||
updatedAt: z.date().describe("The file last update date"),
|
||||
}),
|
||||
@@ -78,6 +79,7 @@ export async function fileRoutes(app: FastifyInstance) {
|
||||
app.post(
|
||||
"/files/check",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["File"],
|
||||
operationId: "checkFile",
|
||||
@@ -110,10 +112,13 @@ export async function fileRoutes(app: FastifyInstance) {
|
||||
tags: ["File"],
|
||||
operationId: "getDownloadUrl",
|
||||
summary: "Get Download URL",
|
||||
description: "Generates a pre-signed URL for downloading a private file",
|
||||
description: "Generates a pre-signed URL for downloading a file",
|
||||
params: z.object({
|
||||
objectName: z.string().min(1, "The objectName is required"),
|
||||
}),
|
||||
querystring: z.object({
|
||||
password: z.string().optional().describe("Share password if required"),
|
||||
}),
|
||||
response: {
|
||||
200: z.object({
|
||||
url: z.string().describe("The download URL"),
|
||||
@@ -136,7 +141,8 @@ export async function fileRoutes(app: FastifyInstance) {
|
||||
tags: ["File"],
|
||||
operationId: "listFiles",
|
||||
summary: "List Files",
|
||||
description: "Lists user files",
|
||||
description: "Lists user files recursively by default, optionally filtered by folder",
|
||||
querystring: ListFilesSchema,
|
||||
response: {
|
||||
200: z.object({
|
||||
files: z.array(
|
||||
@@ -148,6 +154,8 @@ export async function fileRoutes(app: FastifyInstance) {
|
||||
size: z.string().describe("The file size"),
|
||||
objectName: z.string().describe("The object name of the file"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
folderId: z.string().nullable().describe("The folder ID"),
|
||||
relativePath: z.string().nullable().describe("The relative path (only for recursive listing)"),
|
||||
createdAt: z.date().describe("The file creation date"),
|
||||
updatedAt: z.date().describe("The file last update date"),
|
||||
})
|
||||
@@ -160,6 +168,84 @@ export async function fileRoutes(app: FastifyInstance) {
|
||||
fileController.listFiles.bind(fileController)
|
||||
);
|
||||
|
||||
app.patch(
|
||||
"/files/:id",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["File"],
|
||||
operationId: "updateFile",
|
||||
summary: "Update File Metadata",
|
||||
description: "Updates file metadata in the database",
|
||||
params: z.object({
|
||||
id: z.string().min(1, "The file id is required").describe("The file ID"),
|
||||
}),
|
||||
body: UpdateFileSchema,
|
||||
response: {
|
||||
200: z.object({
|
||||
file: z.object({
|
||||
id: z.string().describe("The file ID"),
|
||||
name: z.string().describe("The file name"),
|
||||
description: z.string().nullable().describe("The file description"),
|
||||
extension: z.string().describe("The file extension"),
|
||||
size: z.string().describe("The file size"),
|
||||
objectName: z.string().describe("The object name of the file"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
folderId: z.string().nullable().describe("The folder ID"),
|
||||
createdAt: z.date().describe("The file creation date"),
|
||||
updatedAt: z.date().describe("The file last update date"),
|
||||
}),
|
||||
message: z.string().describe("Success message"),
|
||||
}),
|
||||
400: z.object({ error: z.string().describe("Error message") }),
|
||||
401: z.object({ error: z.string().describe("Error message") }),
|
||||
403: z.object({ error: z.string().describe("Error message") }),
|
||||
404: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
fileController.updateFile.bind(fileController)
|
||||
);
|
||||
|
||||
app.put(
|
||||
"/files/:id/move",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["File"],
|
||||
operationId: "moveFile",
|
||||
summary: "Move File",
|
||||
description: "Moves a file to a different folder",
|
||||
params: z.object({
|
||||
id: z.string().min(1, "The file id is required").describe("The file ID"),
|
||||
}),
|
||||
body: MoveFileSchema,
|
||||
response: {
|
||||
200: z.object({
|
||||
file: z.object({
|
||||
id: z.string().describe("The file ID"),
|
||||
name: z.string().describe("The file name"),
|
||||
description: z.string().nullable().describe("The file description"),
|
||||
extension: z.string().describe("The file extension"),
|
||||
size: z.string().describe("The file size"),
|
||||
objectName: z.string().describe("The object name of the file"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
folderId: z.string().nullable().describe("The folder ID"),
|
||||
createdAt: z.date().describe("The file creation date"),
|
||||
updatedAt: z.date().describe("The file last update date"),
|
||||
}),
|
||||
message: z.string().describe("Success message"),
|
||||
}),
|
||||
400: z.object({ error: z.string().describe("Error message") }),
|
||||
401: z.object({ error: z.string().describe("Error message") }),
|
||||
403: z.object({ error: z.string().describe("Error message") }),
|
||||
404: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
fileController.moveFile.bind(fileController)
|
||||
);
|
||||
|
||||
app.delete(
|
||||
"/files/:id",
|
||||
{
|
||||
@@ -185,42 +271,4 @@ export async function fileRoutes(app: FastifyInstance) {
|
||||
},
|
||||
fileController.deleteFile.bind(fileController)
|
||||
);
|
||||
|
||||
app.patch(
|
||||
"/files/:id",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["File"],
|
||||
operationId: "updateFile",
|
||||
summary: "Update File Metadata",
|
||||
description: "Updates file metadata in the database",
|
||||
params: z.object({
|
||||
id: z.string().min(1, "The file id is required").describe("The file ID"),
|
||||
}),
|
||||
body: UpdateFileSchema,
|
||||
response: {
|
||||
200: z.object({
|
||||
file: z.object({
|
||||
id: z.string().describe("The file ID"),
|
||||
name: z.string().describe("The file name"),
|
||||
description: z.string().nullable().describe("The file description"),
|
||||
extension: z.string().describe("The file extension"),
|
||||
size: z.string().describe("The file size"),
|
||||
objectName: z.string().describe("The object name of the file"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
createdAt: z.date().describe("The file creation date"),
|
||||
updatedAt: z.date().describe("The file last update date"),
|
||||
}),
|
||||
message: z.string().describe("Success message"),
|
||||
}),
|
||||
400: z.object({ error: z.string().describe("Error message") }),
|
||||
401: z.object({ error: z.string().describe("Error message") }),
|
||||
403: z.object({ error: z.string().describe("Error message") }),
|
||||
404: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
fileController.updateFile.bind(fileController)
|
||||
);
|
||||
}
|
||||
|
@@ -1,5 +1,3 @@
|
||||
import { isS3Enabled } from "../../config/storage.config";
|
||||
import { FilesystemStorageProvider } from "../../providers/filesystem-storage.provider";
|
||||
import { S3StorageProvider } from "../../providers/s3-storage.provider";
|
||||
import { StorageProvider } from "../../types/storage";
|
||||
|
||||
@@ -7,11 +5,7 @@ export class FileService {
|
||||
private storageProvider: StorageProvider;
|
||||
|
||||
constructor() {
|
||||
if (isS3Enabled) {
|
||||
this.storageProvider = new S3StorageProvider();
|
||||
} else {
|
||||
this.storageProvider = FilesystemStorageProvider.getInstance();
|
||||
}
|
||||
this.storageProvider = new S3StorageProvider();
|
||||
}
|
||||
|
||||
async getPresignedPutUrl(objectName: string, expires: number): Promise<string> {
|
||||
@@ -40,8 +34,4 @@ export class FileService {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
isFilesystemMode(): boolean {
|
||||
return !isS3Enabled;
|
||||
}
|
||||
}
|
||||
|
@@ -1,349 +0,0 @@
|
||||
import * as fs from "fs";
|
||||
import * as path from "path";
|
||||
|
||||
import { getTempFilePath } from "../../config/directories.config";
|
||||
import { FilesystemStorageProvider } from "../../providers/filesystem-storage.provider";
|
||||
|
||||
export interface ChunkMetadata {
|
||||
fileId: string;
|
||||
chunkIndex: number;
|
||||
totalChunks: number;
|
||||
chunkSize: number;
|
||||
totalSize: number;
|
||||
fileName: string;
|
||||
isLastChunk: boolean;
|
||||
}
|
||||
|
||||
export interface ChunkInfo {
|
||||
fileId: string;
|
||||
fileName: string;
|
||||
totalSize: number;
|
||||
totalChunks: number;
|
||||
uploadedChunks: Set<number>;
|
||||
tempPath: string;
|
||||
createdAt: number;
|
||||
}
|
||||
|
||||
export class ChunkManager {
|
||||
private static instance: ChunkManager;
|
||||
private activeUploads = new Map<string, ChunkInfo>();
|
||||
private finalizingUploads = new Set<string>(); // Track uploads currently being finalized
|
||||
private cleanupInterval: NodeJS.Timeout;
|
||||
|
||||
private constructor() {
|
||||
// Cleanup expired uploads every 30 minutes
|
||||
this.cleanupInterval = setInterval(
|
||||
() => {
|
||||
this.cleanupExpiredUploads();
|
||||
},
|
||||
30 * 60 * 1000
|
||||
);
|
||||
}
|
||||
|
||||
public static getInstance(): ChunkManager {
|
||||
if (!ChunkManager.instance) {
|
||||
ChunkManager.instance = new ChunkManager();
|
||||
}
|
||||
return ChunkManager.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Process a chunk upload with streaming
|
||||
*/
|
||||
async processChunk(
|
||||
metadata: ChunkMetadata,
|
||||
inputStream: NodeJS.ReadableStream,
|
||||
originalObjectName: string
|
||||
): Promise<{ isComplete: boolean; finalPath?: string }> {
|
||||
const startTime = Date.now();
|
||||
const { fileId, chunkIndex, totalChunks, fileName, totalSize, isLastChunk } = metadata;
|
||||
|
||||
console.log(`Processing chunk ${chunkIndex + 1}/${totalChunks} for file ${fileName} (${fileId})`);
|
||||
|
||||
let chunkInfo = this.activeUploads.get(fileId);
|
||||
if (!chunkInfo) {
|
||||
if (chunkIndex !== 0) {
|
||||
throw new Error("First chunk must be chunk 0");
|
||||
}
|
||||
|
||||
const tempPath = getTempFilePath(fileId);
|
||||
chunkInfo = {
|
||||
fileId,
|
||||
fileName,
|
||||
totalSize,
|
||||
totalChunks,
|
||||
uploadedChunks: new Set(),
|
||||
tempPath,
|
||||
createdAt: Date.now(),
|
||||
};
|
||||
this.activeUploads.set(fileId, chunkInfo);
|
||||
console.log(`Created new upload session for ${fileName} at ${tempPath}`);
|
||||
}
|
||||
|
||||
console.log(
|
||||
`Validating chunk ${chunkIndex} (total: ${totalChunks}, uploaded: ${Array.from(chunkInfo.uploadedChunks).join(",")})`
|
||||
);
|
||||
|
||||
if (chunkIndex < 0 || chunkIndex >= totalChunks) {
|
||||
throw new Error(`Invalid chunk index: ${chunkIndex} (must be 0-${totalChunks - 1})`);
|
||||
}
|
||||
|
||||
if (chunkInfo.uploadedChunks.has(chunkIndex)) {
|
||||
console.log(`Chunk ${chunkIndex} already uploaded, treating as success`);
|
||||
|
||||
if (isLastChunk && chunkInfo.uploadedChunks.size === totalChunks) {
|
||||
// Check if already finalizing to prevent race condition
|
||||
if (this.finalizingUploads.has(fileId)) {
|
||||
console.log(`Upload ${fileId} is already being finalized, waiting...`);
|
||||
return { isComplete: false };
|
||||
}
|
||||
|
||||
console.log(`All chunks uploaded, finalizing ${fileName}`);
|
||||
return await this.finalizeUpload(chunkInfo, metadata, originalObjectName);
|
||||
}
|
||||
|
||||
return { isComplete: false };
|
||||
}
|
||||
|
||||
const tempDir = path.dirname(chunkInfo.tempPath);
|
||||
await fs.promises.mkdir(tempDir, { recursive: true });
|
||||
console.log(`Temp directory ensured: ${tempDir}`);
|
||||
|
||||
await this.writeChunkToFile(chunkInfo.tempPath, inputStream, chunkIndex === 0);
|
||||
|
||||
chunkInfo.uploadedChunks.add(chunkIndex);
|
||||
|
||||
try {
|
||||
const stats = await fs.promises.stat(chunkInfo.tempPath);
|
||||
const processingTime = Date.now() - startTime;
|
||||
console.log(
|
||||
`Chunk ${chunkIndex + 1}/${totalChunks} uploaded successfully in ${processingTime}ms. Temp file size: ${stats.size} bytes`
|
||||
);
|
||||
} catch (error) {
|
||||
console.warn(`Could not get temp file stats:`, error);
|
||||
}
|
||||
|
||||
console.log(
|
||||
`Checking completion: isLastChunk=${isLastChunk}, uploadedChunks.size=${chunkInfo.uploadedChunks.size}, totalChunks=${totalChunks}`
|
||||
);
|
||||
|
||||
if (isLastChunk && chunkInfo.uploadedChunks.size === totalChunks) {
|
||||
// Check if already finalizing to prevent race condition
|
||||
if (this.finalizingUploads.has(fileId)) {
|
||||
console.log(`Upload ${fileId} is already being finalized, waiting...`);
|
||||
return { isComplete: false };
|
||||
}
|
||||
|
||||
console.log(`All chunks uploaded, finalizing ${fileName}`);
|
||||
|
||||
const uploadedChunksArray = Array.from(chunkInfo.uploadedChunks).sort((a, b) => a - b);
|
||||
console.log(`Uploaded chunks in order: ${uploadedChunksArray.join(", ")}`);
|
||||
|
||||
const expectedChunks = Array.from({ length: totalChunks }, (_, i) => i);
|
||||
const missingChunks = expectedChunks.filter((chunk) => !chunkInfo.uploadedChunks.has(chunk));
|
||||
|
||||
if (missingChunks.length > 0) {
|
||||
throw new Error(`Missing chunks: ${missingChunks.join(", ")}`);
|
||||
}
|
||||
|
||||
return await this.finalizeUpload(chunkInfo, metadata, originalObjectName);
|
||||
} else {
|
||||
console.log(
|
||||
`Not ready for finalization: isLastChunk=${isLastChunk}, uploadedChunks.size=${chunkInfo.uploadedChunks.size}, totalChunks=${totalChunks}`
|
||||
);
|
||||
}
|
||||
|
||||
return { isComplete: false };
|
||||
}
|
||||
|
||||
/**
|
||||
* Write chunk to file using streaming
|
||||
*/
|
||||
private async writeChunkToFile(
|
||||
filePath: string,
|
||||
inputStream: NodeJS.ReadableStream,
|
||||
isFirstChunk: boolean
|
||||
): Promise<void> {
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log(`Writing chunk to ${filePath} (first: ${isFirstChunk})`);
|
||||
|
||||
if (isFirstChunk) {
|
||||
const writeStream = fs.createWriteStream(filePath, {
|
||||
highWaterMark: 64 * 1024 * 1024, // 64MB buffer for better performance
|
||||
});
|
||||
writeStream.on("error", (error) => {
|
||||
console.error("Write stream error:", error);
|
||||
reject(error);
|
||||
});
|
||||
writeStream.on("finish", () => {
|
||||
console.log("Write stream finished successfully");
|
||||
resolve();
|
||||
});
|
||||
inputStream.pipe(writeStream);
|
||||
} else {
|
||||
const writeStream = fs.createWriteStream(filePath, {
|
||||
flags: "a",
|
||||
highWaterMark: 64 * 1024 * 1024, // 64MB buffer for better performance
|
||||
});
|
||||
writeStream.on("error", (error) => {
|
||||
console.error("Write stream error:", error);
|
||||
reject(error);
|
||||
});
|
||||
writeStream.on("finish", () => {
|
||||
console.log("Write stream finished successfully");
|
||||
resolve();
|
||||
});
|
||||
inputStream.pipe(writeStream);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Finalize upload by moving temp file to final location and encrypting
|
||||
*/
|
||||
private async finalizeUpload(
|
||||
chunkInfo: ChunkInfo,
|
||||
metadata: ChunkMetadata,
|
||||
originalObjectName: string
|
||||
): Promise<{ isComplete: boolean; finalPath: string }> {
|
||||
// Mark as finalizing to prevent race conditions
|
||||
this.finalizingUploads.add(chunkInfo.fileId);
|
||||
|
||||
try {
|
||||
console.log(`Finalizing upload for ${chunkInfo.fileName}`);
|
||||
|
||||
const tempStats = await fs.promises.stat(chunkInfo.tempPath);
|
||||
console.log(`Temp file size: ${tempStats.size} bytes, expected: ${chunkInfo.totalSize} bytes`);
|
||||
|
||||
if (tempStats.size !== chunkInfo.totalSize) {
|
||||
console.warn(`Size mismatch! Temp: ${tempStats.size}, Expected: ${chunkInfo.totalSize}`);
|
||||
}
|
||||
|
||||
const provider = FilesystemStorageProvider.getInstance();
|
||||
const finalObjectName = originalObjectName;
|
||||
const filePath = provider.getFilePath(finalObjectName);
|
||||
const dir = path.dirname(filePath);
|
||||
|
||||
console.log(`Starting encryption and finalization: ${finalObjectName}`);
|
||||
|
||||
await fs.promises.mkdir(dir, { recursive: true });
|
||||
|
||||
const tempReadStream = fs.createReadStream(chunkInfo.tempPath, {
|
||||
highWaterMark: 64 * 1024 * 1024, // 64MB buffer for better performance
|
||||
});
|
||||
const writeStream = fs.createWriteStream(filePath, {
|
||||
highWaterMark: 64 * 1024 * 1024,
|
||||
});
|
||||
const encryptStream = provider.createEncryptStream();
|
||||
|
||||
// Wait for encryption to complete BEFORE cleaning up temp file
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
const startTime = Date.now();
|
||||
|
||||
tempReadStream
|
||||
.pipe(encryptStream)
|
||||
.pipe(writeStream)
|
||||
.on("finish", () => {
|
||||
const duration = Date.now() - startTime;
|
||||
console.log(`File encrypted and saved to: ${filePath} in ${duration}ms`);
|
||||
resolve();
|
||||
})
|
||||
.on("error", (error) => {
|
||||
console.error("Error during encryption:", error);
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
|
||||
console.log(`File successfully uploaded and encrypted: ${finalObjectName}`);
|
||||
|
||||
// Clean up temp file AFTER encryption is complete
|
||||
await this.cleanupTempFile(chunkInfo.tempPath);
|
||||
|
||||
this.activeUploads.delete(chunkInfo.fileId);
|
||||
this.finalizingUploads.delete(chunkInfo.fileId);
|
||||
|
||||
return { isComplete: true, finalPath: finalObjectName };
|
||||
} catch (error) {
|
||||
console.error("Error during finalization:", error);
|
||||
await this.cleanupTempFile(chunkInfo.tempPath);
|
||||
this.activeUploads.delete(chunkInfo.fileId);
|
||||
this.finalizingUploads.delete(chunkInfo.fileId);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup temporary file
|
||||
*/
|
||||
private async cleanupTempFile(tempPath: string): Promise<void> {
|
||||
try {
|
||||
await fs.promises.access(tempPath);
|
||||
await fs.promises.unlink(tempPath);
|
||||
console.log(`Temp file cleaned up: ${tempPath}`);
|
||||
} catch (error: any) {
|
||||
if (error.code === "ENOENT") {
|
||||
console.log(`Temp file already cleaned up: ${tempPath}`);
|
||||
} else {
|
||||
console.warn(`Failed to cleanup temp file ${tempPath}:`, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup expired uploads (older than 2 hours)
|
||||
*/
|
||||
private async cleanupExpiredUploads(): Promise<void> {
|
||||
const now = Date.now();
|
||||
const maxAge = 2 * 60 * 60 * 1000; // 2 hours
|
||||
|
||||
for (const [fileId, chunkInfo] of this.activeUploads.entries()) {
|
||||
if (now - chunkInfo.createdAt > maxAge) {
|
||||
console.log(`Cleaning up expired upload: ${fileId}`);
|
||||
await this.cleanupTempFile(chunkInfo.tempPath);
|
||||
this.activeUploads.delete(fileId);
|
||||
this.finalizingUploads.delete(fileId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get upload progress
|
||||
*/
|
||||
getUploadProgress(fileId: string): { uploaded: number; total: number; percentage: number } | null {
|
||||
const chunkInfo = this.activeUploads.get(fileId);
|
||||
if (!chunkInfo) return null;
|
||||
|
||||
return {
|
||||
uploaded: chunkInfo.uploadedChunks.size,
|
||||
total: chunkInfo.totalChunks,
|
||||
percentage: Math.round((chunkInfo.uploadedChunks.size / chunkInfo.totalChunks) * 100),
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel upload
|
||||
*/
|
||||
async cancelUpload(fileId: string): Promise<void> {
|
||||
const chunkInfo = this.activeUploads.get(fileId);
|
||||
if (chunkInfo) {
|
||||
await this.cleanupTempFile(chunkInfo.tempPath);
|
||||
this.activeUploads.delete(fileId);
|
||||
this.finalizingUploads.delete(fileId);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup on shutdown
|
||||
*/
|
||||
destroy(): void {
|
||||
if (this.cleanupInterval) {
|
||||
clearInterval(this.cleanupInterval);
|
||||
}
|
||||
|
||||
for (const [fileId, chunkInfo] of this.activeUploads.entries()) {
|
||||
this.cleanupTempFile(chunkInfo.tempPath);
|
||||
}
|
||||
this.activeUploads.clear();
|
||||
this.finalizingUploads.clear();
|
||||
}
|
||||
}
|
@@ -1,262 +0,0 @@
|
||||
import * as fs from "fs";
|
||||
import { pipeline } from "stream/promises";
|
||||
import { FastifyReply, FastifyRequest } from "fastify";
|
||||
|
||||
import { FilesystemStorageProvider } from "../../providers/filesystem-storage.provider";
|
||||
import { ChunkManager, ChunkMetadata } from "./chunk-manager";
|
||||
|
||||
export class FilesystemController {
|
||||
private chunkManager = ChunkManager.getInstance();
|
||||
|
||||
/**
|
||||
* Safely encode filename for Content-Disposition header
|
||||
*/
|
||||
private encodeFilenameForHeader(filename: string): string {
|
||||
if (!filename || filename.trim() === "") {
|
||||
return 'attachment; filename="download"';
|
||||
}
|
||||
|
||||
let sanitized = filename
|
||||
.replace(/"/g, "'")
|
||||
.replace(/[\r\n\t\v\f]/g, "")
|
||||
.replace(/[\\|/]/g, "-")
|
||||
.replace(/[<>:|*?]/g, "");
|
||||
|
||||
sanitized = sanitized
|
||||
.split("")
|
||||
.filter((char) => {
|
||||
const code = char.charCodeAt(0);
|
||||
return code >= 32 && !(code >= 127 && code <= 159);
|
||||
})
|
||||
.join("")
|
||||
.trim();
|
||||
|
||||
if (!sanitized) {
|
||||
return 'attachment; filename="download"';
|
||||
}
|
||||
|
||||
const asciiSafe = sanitized
|
||||
.split("")
|
||||
.filter((char) => {
|
||||
const code = char.charCodeAt(0);
|
||||
return code >= 32 && code <= 126;
|
||||
})
|
||||
.join("");
|
||||
|
||||
if (asciiSafe && asciiSafe.trim()) {
|
||||
const encoded = encodeURIComponent(sanitized);
|
||||
return `attachment; filename="${asciiSafe}"; filename*=UTF-8''${encoded}`;
|
||||
} else {
|
||||
const encoded = encodeURIComponent(sanitized);
|
||||
return `attachment; filename*=UTF-8''${encoded}`;
|
||||
}
|
||||
}
|
||||
|
||||
async upload(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const { token } = request.params as { token: string };
|
||||
|
||||
const provider = FilesystemStorageProvider.getInstance();
|
||||
|
||||
const tokenData = provider.validateUploadToken(token);
|
||||
|
||||
if (!tokenData) {
|
||||
return reply.status(400).send({ error: "Invalid or expired upload token" });
|
||||
}
|
||||
|
||||
const chunkMetadata = this.extractChunkMetadata(request);
|
||||
|
||||
if (chunkMetadata) {
|
||||
try {
|
||||
const result = await this.handleChunkedUpload(request, chunkMetadata, tokenData.objectName);
|
||||
|
||||
if (result.isComplete) {
|
||||
provider.consumeUploadToken(token);
|
||||
reply.status(200).send({
|
||||
message: "File uploaded successfully",
|
||||
objectName: result.finalPath,
|
||||
finalObjectName: result.finalPath,
|
||||
});
|
||||
} else {
|
||||
reply.status(200).send({
|
||||
message: "Chunk uploaded successfully",
|
||||
progress: this.chunkManager.getUploadProgress(chunkMetadata.fileId),
|
||||
});
|
||||
}
|
||||
} catch (chunkError: any) {
|
||||
return reply.status(400).send({
|
||||
error: chunkError.message || "Chunked upload failed",
|
||||
details: chunkError.toString(),
|
||||
});
|
||||
}
|
||||
} else {
|
||||
await this.uploadFileStream(request, provider, tokenData.objectName);
|
||||
provider.consumeUploadToken(token);
|
||||
reply.status(200).send({ message: "File uploaded successfully" });
|
||||
}
|
||||
} catch (error) {
|
||||
return reply.status(500).send({ error: "Internal server error" });
|
||||
}
|
||||
}
|
||||
|
||||
private async uploadFileStream(request: FastifyRequest, provider: FilesystemStorageProvider, objectName: string) {
|
||||
await provider.uploadFileFromStream(objectName, request.raw);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract chunk metadata from request headers
|
||||
*/
|
||||
private extractChunkMetadata(request: FastifyRequest): ChunkMetadata | null {
|
||||
const fileId = request.headers["x-file-id"] as string;
|
||||
const chunkIndex = request.headers["x-chunk-index"] as string;
|
||||
const totalChunks = request.headers["x-total-chunks"] as string;
|
||||
const chunkSize = request.headers["x-chunk-size"] as string;
|
||||
const totalSize = request.headers["x-total-size"] as string;
|
||||
const fileName = request.headers["x-file-name"] as string;
|
||||
const isLastChunk = request.headers["x-is-last-chunk"] as string;
|
||||
|
||||
if (!fileId || !chunkIndex || !totalChunks || !chunkSize || !totalSize || !fileName) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const metadata = {
|
||||
fileId,
|
||||
chunkIndex: parseInt(chunkIndex, 10),
|
||||
totalChunks: parseInt(totalChunks, 10),
|
||||
chunkSize: parseInt(chunkSize, 10),
|
||||
totalSize: parseInt(totalSize, 10),
|
||||
fileName,
|
||||
isLastChunk: isLastChunk === "true",
|
||||
};
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle chunked upload with streaming
|
||||
*/
|
||||
private async handleChunkedUpload(request: FastifyRequest, metadata: ChunkMetadata, originalObjectName: string) {
|
||||
const stream = request.raw;
|
||||
|
||||
stream.on("error", (error) => {
|
||||
console.error("Request stream error:", error);
|
||||
});
|
||||
|
||||
return await this.chunkManager.processChunk(metadata, stream, originalObjectName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get upload progress for chunked uploads
|
||||
*/
|
||||
async getUploadProgress(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const { fileId } = request.params as { fileId: string };
|
||||
|
||||
const progress = this.chunkManager.getUploadProgress(fileId);
|
||||
|
||||
if (!progress) {
|
||||
return reply.status(404).send({ error: "Upload not found" });
|
||||
}
|
||||
|
||||
reply.status(200).send(progress);
|
||||
} catch (error) {
|
||||
return reply.status(500).send({ error: "Internal server error" });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel chunked upload
|
||||
*/
|
||||
async cancelUpload(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const { fileId } = request.params as { fileId: string };
|
||||
|
||||
await this.chunkManager.cancelUpload(fileId);
|
||||
|
||||
reply.status(200).send({ message: "Upload cancelled successfully" });
|
||||
} catch (error) {
|
||||
return reply.status(500).send({ error: "Internal server error" });
|
||||
}
|
||||
}
|
||||
|
||||
async download(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
const { token } = request.params as { token: string };
|
||||
|
||||
const provider = FilesystemStorageProvider.getInstance();
|
||||
|
||||
const tokenData = provider.validateDownloadToken(token);
|
||||
|
||||
if (!tokenData) {
|
||||
return reply.status(400).send({ error: "Invalid or expired download token" });
|
||||
}
|
||||
|
||||
const filePath = provider.getFilePath(tokenData.objectName);
|
||||
const stats = await fs.promises.stat(filePath);
|
||||
const fileSize = stats.size;
|
||||
const isLargeFile = fileSize > 50 * 1024 * 1024;
|
||||
|
||||
const fileName = tokenData.fileName || "download";
|
||||
const range = request.headers.range;
|
||||
|
||||
reply.header("Content-Disposition", this.encodeFilenameForHeader(fileName));
|
||||
reply.header("Content-Type", "application/octet-stream");
|
||||
reply.header("Accept-Ranges", "bytes");
|
||||
|
||||
if (range) {
|
||||
const parts = range.replace(/bytes=/, "").split("-");
|
||||
const start = parseInt(parts[0], 10);
|
||||
const end = parts[1] ? parseInt(parts[1], 10) : fileSize - 1;
|
||||
const chunkSize = end - start + 1;
|
||||
|
||||
reply.status(206);
|
||||
reply.header("Content-Range", `bytes ${start}-${end}/${fileSize}`);
|
||||
reply.header("Content-Length", chunkSize);
|
||||
|
||||
if (isLargeFile) {
|
||||
await this.downloadLargeFileRange(reply, provider, tokenData.objectName, start, end);
|
||||
} else {
|
||||
const buffer = await provider.downloadFile(tokenData.objectName);
|
||||
const chunk = buffer.slice(start, end + 1);
|
||||
reply.send(chunk);
|
||||
}
|
||||
} else {
|
||||
reply.header("Content-Length", fileSize);
|
||||
|
||||
if (isLargeFile) {
|
||||
await this.downloadLargeFile(reply, provider, filePath);
|
||||
} else {
|
||||
const buffer = await provider.downloadFile(tokenData.objectName);
|
||||
reply.send(buffer);
|
||||
}
|
||||
}
|
||||
|
||||
provider.consumeDownloadToken(token);
|
||||
} catch (error) {
|
||||
return reply.status(500).send({ error: "Internal server error" });
|
||||
}
|
||||
}
|
||||
|
||||
private async downloadLargeFile(reply: FastifyReply, provider: FilesystemStorageProvider, filePath: string) {
|
||||
const readStream = fs.createReadStream(filePath);
|
||||
const decryptStream = provider.createDecryptStream();
|
||||
|
||||
try {
|
||||
await pipeline(readStream, decryptStream, reply.raw);
|
||||
} catch (error) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
private async downloadLargeFileRange(
|
||||
reply: FastifyReply,
|
||||
provider: FilesystemStorageProvider,
|
||||
objectName: string,
|
||||
start: number,
|
||||
end: number
|
||||
) {
|
||||
const buffer = await provider.downloadFile(objectName);
|
||||
const chunk = buffer.slice(start, end + 1);
|
||||
reply.send(chunk);
|
||||
}
|
||||
}
|
@@ -1,123 +0,0 @@
|
||||
import { FastifyInstance, FastifyRequest } from "fastify";
|
||||
import { z } from "zod";
|
||||
|
||||
import { FilesystemController } from "./controller";
|
||||
|
||||
export async function filesystemRoutes(app: FastifyInstance) {
|
||||
const filesystemController = new FilesystemController();
|
||||
|
||||
app.addContentTypeParser("*", async (request: FastifyRequest, payload: any) => {
|
||||
return payload;
|
||||
});
|
||||
|
||||
app.addContentTypeParser("application/json", async (request: FastifyRequest, payload: any) => {
|
||||
return payload;
|
||||
});
|
||||
|
||||
app.put(
|
||||
"/filesystem/upload/:token",
|
||||
{
|
||||
bodyLimit: 1024 * 1024 * 1024 * 1024 * 1024, // 1PB limit
|
||||
schema: {
|
||||
tags: ["Filesystem"],
|
||||
operationId: "uploadToFilesystem",
|
||||
summary: "Upload file to filesystem storage",
|
||||
description: "Upload a file directly to the encrypted filesystem storage",
|
||||
params: z.object({
|
||||
token: z.string().describe("Upload token"),
|
||||
}),
|
||||
response: {
|
||||
200: z.object({
|
||||
message: z.string(),
|
||||
}),
|
||||
400: z.object({
|
||||
error: z.string(),
|
||||
}),
|
||||
500: z.object({
|
||||
error: z.string(),
|
||||
}),
|
||||
},
|
||||
},
|
||||
},
|
||||
filesystemController.upload.bind(filesystemController)
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/filesystem/download/:token",
|
||||
{
|
||||
bodyLimit: 1024 * 1024 * 1024 * 1024 * 1024, // 1PB limit
|
||||
schema: {
|
||||
tags: ["Filesystem"],
|
||||
operationId: "downloadFromFilesystem",
|
||||
summary: "Download file from filesystem storage",
|
||||
description: "Download a file directly from the encrypted filesystem storage",
|
||||
params: z.object({
|
||||
token: z.string().describe("Download token"),
|
||||
}),
|
||||
response: {
|
||||
200: z.string().describe("File content"),
|
||||
400: z.object({
|
||||
error: z.string(),
|
||||
}),
|
||||
500: z.object({
|
||||
error: z.string(),
|
||||
}),
|
||||
},
|
||||
},
|
||||
},
|
||||
filesystemController.download.bind(filesystemController)
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/filesystem/upload-progress/:fileId",
|
||||
{
|
||||
schema: {
|
||||
tags: ["Filesystem"],
|
||||
operationId: "getUploadProgress",
|
||||
summary: "Get chunked upload progress",
|
||||
description: "Get the progress of a chunked upload",
|
||||
params: z.object({
|
||||
fileId: z.string().describe("File ID"),
|
||||
}),
|
||||
response: {
|
||||
200: z.object({
|
||||
uploaded: z.number(),
|
||||
total: z.number(),
|
||||
percentage: z.number(),
|
||||
}),
|
||||
404: z.object({
|
||||
error: z.string(),
|
||||
}),
|
||||
500: z.object({
|
||||
error: z.string(),
|
||||
}),
|
||||
},
|
||||
},
|
||||
},
|
||||
filesystemController.getUploadProgress.bind(filesystemController)
|
||||
);
|
||||
|
||||
app.delete(
|
||||
"/filesystem/cancel-upload/:fileId",
|
||||
{
|
||||
schema: {
|
||||
tags: ["Filesystem"],
|
||||
operationId: "cancelUpload",
|
||||
summary: "Cancel chunked upload",
|
||||
description: "Cancel an ongoing chunked upload",
|
||||
params: z.object({
|
||||
fileId: z.string().describe("File ID"),
|
||||
}),
|
||||
response: {
|
||||
200: z.object({
|
||||
message: z.string(),
|
||||
}),
|
||||
500: z.object({
|
||||
error: z.string(),
|
||||
}),
|
||||
},
|
||||
},
|
||||
},
|
||||
filesystemController.cancelUpload.bind(filesystemController)
|
||||
);
|
||||
}
|
412
apps/server/src/modules/folder/controller.ts
Normal file
412
apps/server/src/modules/folder/controller.ts
Normal file
@@ -0,0 +1,412 @@
|
||||
import { FastifyReply, FastifyRequest } from "fastify";
|
||||
|
||||
import { env } from "../../env";
|
||||
import { prisma } from "../../shared/prisma";
|
||||
import { ConfigService } from "../config/service";
|
||||
import {
|
||||
CheckFolderSchema,
|
||||
ListFoldersSchema,
|
||||
MoveFolderSchema,
|
||||
RegisterFolderSchema,
|
||||
UpdateFolderSchema,
|
||||
} from "./dto";
|
||||
import { FolderService } from "./service";
|
||||
|
||||
export class FolderController {
|
||||
private folderService = new FolderService();
|
||||
private configService = new ConfigService();
|
||||
|
||||
async registerFolder(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const userId = (request as any).user?.userId;
|
||||
if (!userId) {
|
||||
return reply.status(401).send({ error: "Unauthorized: a valid token is required to access this resource." });
|
||||
}
|
||||
|
||||
const input = RegisterFolderSchema.parse(request.body);
|
||||
|
||||
if (input.parentId) {
|
||||
const parentFolder = await prisma.folder.findFirst({
|
||||
where: { id: input.parentId, userId },
|
||||
});
|
||||
if (!parentFolder) {
|
||||
return reply.status(400).send({ error: "Parent folder not found or access denied" });
|
||||
}
|
||||
}
|
||||
|
||||
const existingFolder = await prisma.folder.findFirst({
|
||||
where: {
|
||||
name: input.name,
|
||||
parentId: input.parentId || null,
|
||||
userId,
|
||||
},
|
||||
});
|
||||
|
||||
if (existingFolder) {
|
||||
return reply.status(400).send({ error: "A folder with this name already exists in this location" });
|
||||
}
|
||||
|
||||
const folderRecord = await prisma.folder.create({
|
||||
data: {
|
||||
name: input.name,
|
||||
description: input.description,
|
||||
objectName: input.objectName,
|
||||
parentId: input.parentId,
|
||||
userId,
|
||||
},
|
||||
include: {
|
||||
_count: {
|
||||
select: {
|
||||
files: true,
|
||||
children: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const totalSize = await this.folderService.calculateFolderSize(folderRecord.id, userId);
|
||||
|
||||
const folderResponse = {
|
||||
id: folderRecord.id,
|
||||
name: folderRecord.name,
|
||||
description: folderRecord.description,
|
||||
objectName: folderRecord.objectName,
|
||||
parentId: folderRecord.parentId,
|
||||
userId: folderRecord.userId,
|
||||
createdAt: folderRecord.createdAt,
|
||||
updatedAt: folderRecord.updatedAt,
|
||||
totalSize: totalSize.toString(),
|
||||
_count: folderRecord._count,
|
||||
};
|
||||
|
||||
return reply.status(201).send({
|
||||
folder: folderResponse,
|
||||
message: "Folder registered successfully.",
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.error("Error in registerFolder:", error);
|
||||
return reply.status(400).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async checkFolder(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const userId = (request as any).user?.userId;
|
||||
if (!userId) {
|
||||
return reply.status(401).send({
|
||||
error: "Unauthorized: a valid token is required to access this resource.",
|
||||
code: "unauthorized",
|
||||
});
|
||||
}
|
||||
|
||||
const input = CheckFolderSchema.parse(request.body);
|
||||
|
||||
if (input.name.length > 100) {
|
||||
return reply.status(400).send({
|
||||
code: "folderNameTooLong",
|
||||
error: "Folder name exceeds maximum length of 100 characters",
|
||||
details: "100",
|
||||
});
|
||||
}
|
||||
|
||||
const existingFolder = await prisma.folder.findFirst({
|
||||
where: {
|
||||
name: input.name,
|
||||
parentId: input.parentId || null,
|
||||
userId,
|
||||
},
|
||||
});
|
||||
|
||||
if (existingFolder) {
|
||||
return reply.status(400).send({
|
||||
error: "A folder with this name already exists in this location",
|
||||
code: "duplicateFolderName",
|
||||
});
|
||||
}
|
||||
|
||||
return reply.status(201).send({
|
||||
message: "Folder checks succeeded.",
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.error("Error in checkFolder:", error);
|
||||
return reply.status(400).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async listFolders(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const userId = (request as any).user?.userId;
|
||||
if (!userId) {
|
||||
return reply.status(401).send({ error: "Unauthorized: a valid token is required to access this resource." });
|
||||
}
|
||||
|
||||
const input = ListFoldersSchema.parse(request.query);
|
||||
const { parentId, recursive: recursiveStr } = input;
|
||||
const recursive = recursiveStr === "false" ? false : true;
|
||||
|
||||
let folders: any[];
|
||||
|
||||
if (recursive) {
|
||||
folders = await prisma.folder.findMany({
|
||||
where: { userId },
|
||||
include: {
|
||||
_count: {
|
||||
select: {
|
||||
files: true,
|
||||
children: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
orderBy: [{ name: "asc" }],
|
||||
});
|
||||
} else {
|
||||
// Get only direct children of specified parent
|
||||
const targetParentId = parentId === "null" || parentId === "" || !parentId ? null : parentId;
|
||||
folders = await prisma.folder.findMany({
|
||||
where: {
|
||||
userId,
|
||||
parentId: targetParentId,
|
||||
},
|
||||
include: {
|
||||
_count: {
|
||||
select: {
|
||||
files: true,
|
||||
children: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
orderBy: [{ name: "asc" }],
|
||||
});
|
||||
}
|
||||
|
||||
const foldersResponse = await Promise.all(
|
||||
folders.map(async (folder) => {
|
||||
const totalSize = await this.folderService.calculateFolderSize(folder.id, userId);
|
||||
return {
|
||||
id: folder.id,
|
||||
name: folder.name,
|
||||
description: folder.description,
|
||||
objectName: folder.objectName,
|
||||
parentId: folder.parentId,
|
||||
userId: folder.userId,
|
||||
createdAt: folder.createdAt,
|
||||
updatedAt: folder.updatedAt,
|
||||
totalSize: totalSize.toString(),
|
||||
_count: folder._count,
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
return reply.send({ folders: foldersResponse });
|
||||
} catch (error: any) {
|
||||
console.error("Error in listFolders:", error);
|
||||
return reply.status(500).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async updateFolder(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const { id } = request.params as { id: string };
|
||||
const userId = (request as any).user?.userId;
|
||||
|
||||
if (!userId) {
|
||||
return reply.status(401).send({
|
||||
error: "Unauthorized: a valid token is required to access this resource.",
|
||||
});
|
||||
}
|
||||
|
||||
const updateData = UpdateFolderSchema.parse(request.body);
|
||||
|
||||
const folderRecord = await prisma.folder.findUnique({ where: { id } });
|
||||
|
||||
if (!folderRecord) {
|
||||
return reply.status(404).send({ error: "Folder not found." });
|
||||
}
|
||||
|
||||
if (folderRecord.userId !== userId) {
|
||||
return reply.status(403).send({ error: "Access denied." });
|
||||
}
|
||||
|
||||
if (updateData.name && updateData.name !== folderRecord.name) {
|
||||
const duplicateFolder = await prisma.folder.findFirst({
|
||||
where: {
|
||||
name: updateData.name,
|
||||
parentId: folderRecord.parentId,
|
||||
userId,
|
||||
id: { not: id },
|
||||
},
|
||||
});
|
||||
|
||||
if (duplicateFolder) {
|
||||
return reply.status(400).send({ error: "A folder with this name already exists in this location" });
|
||||
}
|
||||
}
|
||||
|
||||
const updatedFolder = await prisma.folder.update({
|
||||
where: { id },
|
||||
data: updateData,
|
||||
include: {
|
||||
_count: {
|
||||
select: {
|
||||
files: true,
|
||||
children: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const totalSize = await this.folderService.calculateFolderSize(updatedFolder.id, userId);
|
||||
|
||||
const folderResponse = {
|
||||
id: updatedFolder.id,
|
||||
name: updatedFolder.name,
|
||||
description: updatedFolder.description,
|
||||
objectName: updatedFolder.objectName,
|
||||
parentId: updatedFolder.parentId,
|
||||
userId: updatedFolder.userId,
|
||||
createdAt: updatedFolder.createdAt,
|
||||
updatedAt: updatedFolder.updatedAt,
|
||||
totalSize: totalSize.toString(),
|
||||
_count: updatedFolder._count,
|
||||
};
|
||||
|
||||
return reply.send({
|
||||
folder: folderResponse,
|
||||
message: "Folder updated successfully.",
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.error("Error in updateFolder:", error);
|
||||
return reply.status(400).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async moveFolder(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const userId = (request as any).user?.userId;
|
||||
|
||||
if (!userId) {
|
||||
return reply.status(401).send({ error: "Unauthorized: a valid token is required to access this resource." });
|
||||
}
|
||||
|
||||
const { id } = request.params as { id: string };
|
||||
const body = request.body as any;
|
||||
|
||||
const input = {
|
||||
parentId: body.parentId === undefined ? null : body.parentId,
|
||||
};
|
||||
|
||||
const validatedInput = MoveFolderSchema.parse(input);
|
||||
|
||||
const existingFolder = await prisma.folder.findFirst({
|
||||
where: { id, userId },
|
||||
});
|
||||
|
||||
if (!existingFolder) {
|
||||
return reply.status(404).send({ error: "Folder not found." });
|
||||
}
|
||||
|
||||
if (validatedInput.parentId) {
|
||||
const parentFolder = await prisma.folder.findFirst({
|
||||
where: { id: validatedInput.parentId, userId },
|
||||
});
|
||||
if (!parentFolder) {
|
||||
return reply.status(400).send({ error: "Parent folder not found or access denied" });
|
||||
}
|
||||
|
||||
if (await this.isDescendantOf(validatedInput.parentId, id, userId)) {
|
||||
return reply.status(400).send({ error: "Cannot move a folder into itself or its subfolders" });
|
||||
}
|
||||
}
|
||||
|
||||
const updatedFolder = await prisma.folder.update({
|
||||
where: { id },
|
||||
data: { parentId: validatedInput.parentId },
|
||||
include: {
|
||||
_count: {
|
||||
select: {
|
||||
files: true,
|
||||
children: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const totalSize = await this.folderService.calculateFolderSize(updatedFolder.id, userId);
|
||||
|
||||
const folderResponse = {
|
||||
id: updatedFolder.id,
|
||||
name: updatedFolder.name,
|
||||
description: updatedFolder.description,
|
||||
objectName: updatedFolder.objectName,
|
||||
parentId: updatedFolder.parentId,
|
||||
userId: updatedFolder.userId,
|
||||
createdAt: updatedFolder.createdAt,
|
||||
updatedAt: updatedFolder.updatedAt,
|
||||
totalSize: totalSize.toString(),
|
||||
_count: updatedFolder._count,
|
||||
};
|
||||
|
||||
return reply.send({
|
||||
folder: folderResponse,
|
||||
message: "Folder moved successfully.",
|
||||
});
|
||||
} catch (error: any) {
|
||||
console.error("Error in moveFolder:", error);
|
||||
const statusCode = error.message === "Folder not found" ? 404 : 400;
|
||||
return reply.status(statusCode).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async deleteFolder(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const { id } = request.params as { id: string };
|
||||
if (!id) {
|
||||
return reply.status(400).send({ error: "The 'id' parameter is required." });
|
||||
}
|
||||
|
||||
const folderRecord = await prisma.folder.findUnique({ where: { id } });
|
||||
if (!folderRecord) {
|
||||
return reply.status(404).send({ error: "Folder not found." });
|
||||
}
|
||||
|
||||
const userId = (request as any).user?.userId;
|
||||
if (folderRecord.userId !== userId) {
|
||||
return reply.status(403).send({ error: "Access denied." });
|
||||
}
|
||||
|
||||
await this.folderService.deleteObject(folderRecord.objectName);
|
||||
|
||||
await prisma.folder.delete({ where: { id } });
|
||||
|
||||
return reply.send({ message: "Folder deleted successfully." });
|
||||
} catch (error) {
|
||||
console.error("Error in deleteFolder:", error);
|
||||
return reply.status(500).send({ error: "Internal server error." });
|
||||
}
|
||||
}
|
||||
|
||||
private async isDescendantOf(potentialDescendantId: string, ancestorId: string, userId: string): Promise<boolean> {
|
||||
let currentId: string | null = potentialDescendantId;
|
||||
|
||||
while (currentId) {
|
||||
if (currentId === ancestorId) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const folder: { parentId: string | null } | null = await prisma.folder.findFirst({
|
||||
where: { id: currentId, userId },
|
||||
});
|
||||
|
||||
if (!folder) break;
|
||||
currentId = folder.parentId;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
56
apps/server/src/modules/folder/dto.ts
Normal file
56
apps/server/src/modules/folder/dto.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const RegisterFolderSchema = z.object({
|
||||
name: z.string().min(1, "O nome da pasta é obrigatório"),
|
||||
description: z.string().optional(),
|
||||
objectName: z.string().min(1, "O objectName é obrigatório"),
|
||||
parentId: z.string().optional(),
|
||||
});
|
||||
|
||||
export const UpdateFolderSchema = z.object({
|
||||
name: z.string().optional(),
|
||||
description: z.string().optional().nullable(),
|
||||
});
|
||||
|
||||
export const MoveFolderSchema = z.object({
|
||||
parentId: z.string().nullable(),
|
||||
});
|
||||
|
||||
export const FolderResponseSchema = z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
description: z.string().nullable(),
|
||||
parentId: z.string().nullable(),
|
||||
userId: z.string(),
|
||||
createdAt: z.date(),
|
||||
updatedAt: z.date(),
|
||||
totalSize: z
|
||||
.bigint()
|
||||
.transform((val) => val.toString())
|
||||
.optional(),
|
||||
_count: z
|
||||
.object({
|
||||
files: z.number(),
|
||||
children: z.number(),
|
||||
})
|
||||
.optional(),
|
||||
});
|
||||
|
||||
export const CheckFolderSchema = z.object({
|
||||
name: z.string().min(1, "O nome da pasta é obrigatório"),
|
||||
description: z.string().optional(),
|
||||
objectName: z.string().min(1, "O objectName é obrigatório"),
|
||||
parentId: z.string().optional(),
|
||||
});
|
||||
|
||||
export const ListFoldersSchema = z.object({
|
||||
parentId: z.string().optional(),
|
||||
recursive: z.string().optional().default("true"),
|
||||
});
|
||||
|
||||
export type RegisterFolderInput = z.infer<typeof RegisterFolderSchema>;
|
||||
export type UpdateFolderInput = z.infer<typeof UpdateFolderSchema>;
|
||||
export type MoveFolderInput = z.infer<typeof MoveFolderSchema>;
|
||||
export type CheckFolderInput = z.infer<typeof CheckFolderSchema>;
|
||||
export type ListFoldersInput = z.infer<typeof ListFoldersSchema>;
|
||||
export type FolderResponse = z.infer<typeof FolderResponseSchema>;
|
245
apps/server/src/modules/folder/routes.ts
Normal file
245
apps/server/src/modules/folder/routes.ts
Normal file
@@ -0,0 +1,245 @@
|
||||
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
|
||||
import { z } from "zod";
|
||||
|
||||
import { FolderController } from "./controller";
|
||||
import {
|
||||
CheckFolderSchema,
|
||||
FolderResponseSchema,
|
||||
ListFoldersSchema,
|
||||
MoveFolderSchema,
|
||||
RegisterFolderSchema,
|
||||
UpdateFolderSchema,
|
||||
} from "./dto";
|
||||
|
||||
export async function folderRoutes(app: FastifyInstance) {
|
||||
const folderController = new FolderController();
|
||||
|
||||
const preValidation = async (request: FastifyRequest, reply: FastifyReply) => {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
reply.status(401).send({ error: "Token inválido ou ausente." });
|
||||
}
|
||||
};
|
||||
|
||||
app.post(
|
||||
"/folders",
|
||||
{
|
||||
schema: {
|
||||
tags: ["Folder"],
|
||||
operationId: "registerFolder",
|
||||
summary: "Register Folder Metadata",
|
||||
description: "Registers folder metadata in the database",
|
||||
body: RegisterFolderSchema,
|
||||
response: {
|
||||
201: z.object({
|
||||
folder: z.object({
|
||||
id: z.string().describe("The folder ID"),
|
||||
name: z.string().describe("The folder name"),
|
||||
description: z.string().nullable().describe("The folder description"),
|
||||
parentId: z.string().nullable().describe("The parent folder ID"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
createdAt: z.date().describe("The folder creation date"),
|
||||
updatedAt: z.date().describe("The folder last update date"),
|
||||
totalSize: z.string().optional().describe("The total size of the folder"),
|
||||
_count: z
|
||||
.object({
|
||||
files: z.number().describe("Number of files in folder"),
|
||||
children: z.number().describe("Number of subfolders"),
|
||||
})
|
||||
.optional()
|
||||
.describe("Count statistics"),
|
||||
}),
|
||||
message: z.string().describe("The folder registration message"),
|
||||
}),
|
||||
400: z.object({ error: z.string().describe("Error message") }),
|
||||
401: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
folderController.registerFolder.bind(folderController)
|
||||
);
|
||||
|
||||
app.post(
|
||||
"/folders/check",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["Folder"],
|
||||
operationId: "checkFolder",
|
||||
summary: "Check Folder validity",
|
||||
description: "Checks if the folder meets all requirements",
|
||||
body: CheckFolderSchema,
|
||||
response: {
|
||||
201: z.object({
|
||||
message: z.string().describe("The folder check success message"),
|
||||
}),
|
||||
400: z.object({
|
||||
error: z.string().describe("Error message"),
|
||||
code: z.string().optional().describe("Error code"),
|
||||
details: z.string().optional().describe("Error details"),
|
||||
}),
|
||||
401: z.object({
|
||||
error: z.string().describe("Error message"),
|
||||
code: z.string().optional().describe("Error code"),
|
||||
}),
|
||||
},
|
||||
},
|
||||
},
|
||||
folderController.checkFolder.bind(folderController)
|
||||
);
|
||||
|
||||
app.get(
|
||||
"/folders",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["Folder"],
|
||||
operationId: "listFolders",
|
||||
summary: "List Folders",
|
||||
description: "Lists user folders recursively by default, optionally filtered by folder",
|
||||
querystring: ListFoldersSchema,
|
||||
response: {
|
||||
200: z.object({
|
||||
folders: z.array(
|
||||
z.object({
|
||||
id: z.string().describe("The folder ID"),
|
||||
name: z.string().describe("The folder name"),
|
||||
description: z.string().nullable().describe("The folder description"),
|
||||
parentId: z.string().nullable().describe("The parent folder ID"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
createdAt: z.date().describe("The folder creation date"),
|
||||
updatedAt: z.date().describe("The folder last update date"),
|
||||
totalSize: z.string().optional().describe("The total size of the folder"),
|
||||
_count: z
|
||||
.object({
|
||||
files: z.number().describe("Number of files in folder"),
|
||||
children: z.number().describe("Number of subfolders"),
|
||||
})
|
||||
.optional()
|
||||
.describe("Count statistics"),
|
||||
})
|
||||
),
|
||||
}),
|
||||
500: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
folderController.listFolders.bind(folderController)
|
||||
);
|
||||
|
||||
app.patch(
|
||||
"/folders/:id",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["Folder"],
|
||||
operationId: "updateFolder",
|
||||
summary: "Update Folder Metadata",
|
||||
description: "Updates folder metadata in the database",
|
||||
params: z.object({
|
||||
id: z.string().min(1, "The folder id is required").describe("The folder ID"),
|
||||
}),
|
||||
body: UpdateFolderSchema,
|
||||
response: {
|
||||
200: z.object({
|
||||
folder: z.object({
|
||||
id: z.string().describe("The folder ID"),
|
||||
name: z.string().describe("The folder name"),
|
||||
description: z.string().nullable().describe("The folder description"),
|
||||
parentId: z.string().nullable().describe("The parent folder ID"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
createdAt: z.date().describe("The folder creation date"),
|
||||
updatedAt: z.date().describe("The folder last update date"),
|
||||
totalSize: z.string().optional().describe("The total size of the folder"),
|
||||
_count: z
|
||||
.object({
|
||||
files: z.number().describe("Number of files in folder"),
|
||||
children: z.number().describe("Number of subfolders"),
|
||||
})
|
||||
.optional()
|
||||
.describe("Count statistics"),
|
||||
}),
|
||||
message: z.string().describe("Success message"),
|
||||
}),
|
||||
400: z.object({ error: z.string().describe("Error message") }),
|
||||
401: z.object({ error: z.string().describe("Error message") }),
|
||||
403: z.object({ error: z.string().describe("Error message") }),
|
||||
404: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
folderController.updateFolder.bind(folderController)
|
||||
);
|
||||
|
||||
app.put(
|
||||
"/folders/:id/move",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["Folder"],
|
||||
operationId: "moveFolder",
|
||||
summary: "Move Folder",
|
||||
description: "Moves a folder to a different parent folder",
|
||||
params: z.object({
|
||||
id: z.string().min(1, "The folder id is required").describe("The folder ID"),
|
||||
}),
|
||||
body: MoveFolderSchema,
|
||||
response: {
|
||||
200: z.object({
|
||||
folder: z.object({
|
||||
id: z.string().describe("The folder ID"),
|
||||
name: z.string().describe("The folder name"),
|
||||
description: z.string().nullable().describe("The folder description"),
|
||||
parentId: z.string().nullable().describe("The parent folder ID"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
createdAt: z.date().describe("The folder creation date"),
|
||||
updatedAt: z.date().describe("The folder last update date"),
|
||||
totalSize: z.string().optional().describe("The total size of the folder"),
|
||||
_count: z
|
||||
.object({
|
||||
files: z.number().describe("Number of files in folder"),
|
||||
children: z.number().describe("Number of subfolders"),
|
||||
})
|
||||
.optional()
|
||||
.describe("Count statistics"),
|
||||
}),
|
||||
message: z.string().describe("Success message"),
|
||||
}),
|
||||
400: z.object({ error: z.string().describe("Error message") }),
|
||||
401: z.object({ error: z.string().describe("Error message") }),
|
||||
403: z.object({ error: z.string().describe("Error message") }),
|
||||
404: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
folderController.moveFolder.bind(folderController)
|
||||
);
|
||||
|
||||
app.delete(
|
||||
"/folders/:id",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["Folder"],
|
||||
operationId: "deleteFolder",
|
||||
summary: "Delete Folder",
|
||||
description: "Deletes a folder and all its contents",
|
||||
params: z.object({
|
||||
id: z.string().min(1, "The folder id is required").describe("The folder ID"),
|
||||
}),
|
||||
response: {
|
||||
200: z.object({
|
||||
message: z.string().describe("The folder deletion message"),
|
||||
}),
|
||||
400: z.object({ error: z.string().describe("Error message") }),
|
||||
401: z.object({ error: z.string().describe("Error message") }),
|
||||
404: z.object({ error: z.string().describe("Error message") }),
|
||||
500: z.object({ error: z.string().describe("Error message") }),
|
||||
},
|
||||
},
|
||||
},
|
||||
folderController.deleteFolder.bind(folderController)
|
||||
);
|
||||
}
|
83
apps/server/src/modules/folder/service.ts
Normal file
83
apps/server/src/modules/folder/service.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import { S3StorageProvider } from "../../providers/s3-storage.provider";
|
||||
import { prisma } from "../../shared/prisma";
|
||||
import { StorageProvider } from "../../types/storage";
|
||||
|
||||
export class FolderService {
|
||||
private storageProvider: StorageProvider;
|
||||
|
||||
constructor() {
|
||||
this.storageProvider = new S3StorageProvider();
|
||||
}
|
||||
|
||||
async getPresignedPutUrl(objectName: string, expires: number): Promise<string> {
|
||||
try {
|
||||
return await this.storageProvider.getPresignedPutUrl(objectName, expires);
|
||||
} catch (err) {
|
||||
console.error("Erro no presignedPutObject:", err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
async getPresignedGetUrl(objectName: string, expires: number, folderName?: string): Promise<string> {
|
||||
try {
|
||||
return await this.storageProvider.getPresignedGetUrl(objectName, expires, folderName);
|
||||
} catch (err) {
|
||||
console.error("Erro no presignedGetObject:", err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
async deleteObject(objectName: string): Promise<void> {
|
||||
try {
|
||||
await this.storageProvider.deleteObject(objectName);
|
||||
} catch (err) {
|
||||
console.error("Erro no removeObject:", err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
async getAllFilesInFolder(folderId: string, userId: string, basePath: string = ""): Promise<any[]> {
|
||||
const files = await prisma.file.findMany({
|
||||
where: { folderId, userId },
|
||||
});
|
||||
|
||||
const subfolders = await prisma.folder.findMany({
|
||||
where: { parentId: folderId, userId },
|
||||
select: { id: true, name: true },
|
||||
});
|
||||
|
||||
let allFiles = files.map((file: any) => ({
|
||||
...file,
|
||||
relativePath: basePath + file.name,
|
||||
}));
|
||||
|
||||
for (const subfolder of subfolders) {
|
||||
const subfolderPath = basePath + subfolder.name + "/";
|
||||
const subfolderFiles = await this.getAllFilesInFolder(subfolder.id, userId, subfolderPath);
|
||||
allFiles = [...allFiles, ...subfolderFiles];
|
||||
}
|
||||
|
||||
return allFiles;
|
||||
}
|
||||
|
||||
async calculateFolderSize(folderId: string, userId: string): Promise<bigint> {
|
||||
const files = await prisma.file.findMany({
|
||||
where: { folderId, userId },
|
||||
select: { size: true },
|
||||
});
|
||||
|
||||
const subfolders = await prisma.folder.findMany({
|
||||
where: { parentId: folderId, userId },
|
||||
select: { id: true },
|
||||
});
|
||||
|
||||
let totalSize = files.reduce((sum, file) => sum + file.size, BigInt(0));
|
||||
|
||||
for (const subfolder of subfolders) {
|
||||
const subfolderSize = await this.calculateFolderSize(subfolder.id, userId);
|
||||
totalSize += subfolderSize;
|
||||
}
|
||||
|
||||
return totalSize;
|
||||
}
|
||||
}
|
@@ -318,8 +318,21 @@ export class ReverseShareController {
|
||||
}
|
||||
|
||||
const { fileId } = request.params as { fileId: string };
|
||||
const result = await this.reverseShareService.downloadReverseShareFile(fileId, userId);
|
||||
return reply.send(result);
|
||||
|
||||
const fileInfo = await this.reverseShareService.getFileInfo(fileId, userId);
|
||||
const downloadId = `reverse-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
||||
|
||||
const fileSizeMB = Number(fileInfo.size) / (1024 * 1024);
|
||||
console.log(`[REVERSE-DOWNLOAD] Starting ${downloadId}: ${fileInfo.name} (${fileSizeMB.toFixed(1)}MB)`);
|
||||
|
||||
try {
|
||||
const result = await this.reverseShareService.downloadReverseShareFile(fileId, userId);
|
||||
reply.header("X-Download-ID", downloadId);
|
||||
|
||||
return reply.send(result);
|
||||
} catch (downloadError) {
|
||||
throw downloadError;
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (error.message === "File not found") {
|
||||
return reply.status(404).send({ error: error.message });
|
||||
|
@@ -401,6 +401,12 @@ export async function reverseShareRoutes(app: FastifyInstance) {
|
||||
url: z.string().describe("Presigned download URL - expires after 1 hour"),
|
||||
expiresIn: z.number().describe("URL expiration time in seconds (3600 = 1 hour)"),
|
||||
}),
|
||||
202: z.object({
|
||||
queued: z.boolean().describe("Download was queued due to memory constraints"),
|
||||
downloadId: z.string().describe("Download identifier for tracking"),
|
||||
message: z.string().describe("Queue status message"),
|
||||
estimatedWaitTime: z.number().describe("Estimated wait time in seconds"),
|
||||
}),
|
||||
401: z.object({ error: z.string() }),
|
||||
404: z.object({ error: z.string() }),
|
||||
},
|
||||
|
@@ -1,6 +1,9 @@
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
|
||||
import { env } from "../../env";
|
||||
import { EmailService } from "../email/service";
|
||||
import { FileService } from "../file/service";
|
||||
import { UserService } from "../user/service";
|
||||
import {
|
||||
CreateReverseShareInput,
|
||||
ReverseShareResponseSchema,
|
||||
@@ -40,6 +43,19 @@ const prisma = new PrismaClient();
|
||||
export class ReverseShareService {
|
||||
private reverseShareRepository = new ReverseShareRepository();
|
||||
private fileService = new FileService();
|
||||
private emailService = new EmailService();
|
||||
private userService = new UserService();
|
||||
|
||||
private uploadSessions = new Map<
|
||||
string,
|
||||
{
|
||||
reverseShareId: string;
|
||||
uploaderName: string;
|
||||
uploaderEmail?: string;
|
||||
files: string[];
|
||||
timeout: NodeJS.Timeout;
|
||||
}
|
||||
>();
|
||||
|
||||
async createReverseShare(data: CreateReverseShareInput, creatorId: string) {
|
||||
const reverseShare = await this.reverseShareRepository.create(data, creatorId);
|
||||
@@ -211,7 +227,7 @@ export class ReverseShareService {
|
||||
}
|
||||
}
|
||||
|
||||
const expires = 3600; // 1 hour
|
||||
const expires = parseInt(env.PRESIGNED_URL_EXPIRATION);
|
||||
const url = await this.fileService.getPresignedPutUrl(objectName, expires);
|
||||
|
||||
return { url, expiresIn: expires };
|
||||
@@ -241,7 +257,7 @@ export class ReverseShareService {
|
||||
}
|
||||
}
|
||||
|
||||
const expires = 3600; // 1 hour
|
||||
const expires = parseInt(env.PRESIGNED_URL_EXPIRATION);
|
||||
const url = await this.fileService.getPresignedPutUrl(objectName, expires);
|
||||
|
||||
return { url, expiresIn: expires };
|
||||
@@ -294,6 +310,8 @@ export class ReverseShareService {
|
||||
size: BigInt(fileData.size),
|
||||
});
|
||||
|
||||
this.addFileToUploadSession(reverseShare, fileData);
|
||||
|
||||
return this.formatFileResponse(file);
|
||||
}
|
||||
|
||||
@@ -344,9 +362,30 @@ export class ReverseShareService {
|
||||
size: BigInt(fileData.size),
|
||||
});
|
||||
|
||||
this.addFileToUploadSession(reverseShare, fileData);
|
||||
|
||||
return this.formatFileResponse(file);
|
||||
}
|
||||
|
||||
async getFileInfo(fileId: string, creatorId: string) {
|
||||
const file = await this.reverseShareRepository.findFileById(fileId);
|
||||
if (!file) {
|
||||
throw new Error("File not found");
|
||||
}
|
||||
|
||||
if (file.reverseShare.creatorId !== creatorId) {
|
||||
throw new Error("Unauthorized to access this file");
|
||||
}
|
||||
|
||||
return {
|
||||
id: file.id,
|
||||
name: file.name,
|
||||
size: file.size,
|
||||
objectName: file.objectName,
|
||||
extension: file.extension,
|
||||
};
|
||||
}
|
||||
|
||||
async downloadReverseShareFile(fileId: string, creatorId: string) {
|
||||
const file = await this.reverseShareRepository.findFileById(fileId);
|
||||
if (!file) {
|
||||
@@ -358,7 +397,7 @@ export class ReverseShareService {
|
||||
}
|
||||
|
||||
const fileName = file.name;
|
||||
const expires = 3600; // 1 hour
|
||||
const expires = parseInt(env.PRESIGNED_URL_EXPIRATION);
|
||||
const url = await this.fileService.getPresignedGetUrl(file.objectName, expires, fileName);
|
||||
return { url, expiresIn: expires };
|
||||
}
|
||||
@@ -514,6 +553,7 @@ export class ReverseShareService {
|
||||
}
|
||||
|
||||
const maxTotalStorage = BigInt(await configService.getValue("maxTotalStoragePerUser"));
|
||||
|
||||
const userFiles = await prisma.file.findMany({
|
||||
where: { userId: creatorId },
|
||||
select: { size: true },
|
||||
@@ -528,76 +568,57 @@ export class ReverseShareService {
|
||||
|
||||
const newObjectName = `${creatorId}/${Date.now()}-${file.name}`;
|
||||
|
||||
if (this.fileService.isFilesystemMode()) {
|
||||
const { FilesystemStorageProvider } = await import("../../providers/filesystem-storage.provider.js");
|
||||
const provider = FilesystemStorageProvider.getInstance();
|
||||
const fileSizeMB = Number(file.size) / (1024 * 1024);
|
||||
const needsStreaming = fileSizeMB > 100;
|
||||
|
||||
const sourcePath = provider.getFilePath(file.objectName);
|
||||
const fs = await import("fs");
|
||||
const downloadUrl = await this.fileService.getPresignedGetUrl(file.objectName, 300);
|
||||
const uploadUrl = await this.fileService.getPresignedPutUrl(newObjectName, 300);
|
||||
|
||||
const targetPath = provider.getFilePath(newObjectName);
|
||||
let retries = 0;
|
||||
const maxRetries = 3;
|
||||
let success = false;
|
||||
|
||||
const path = await import("path");
|
||||
const targetDir = path.dirname(targetPath);
|
||||
if (!fs.existsSync(targetDir)) {
|
||||
fs.mkdirSync(targetDir, { recursive: true });
|
||||
}
|
||||
while (retries < maxRetries && !success) {
|
||||
try {
|
||||
const response = await fetch(downloadUrl, {
|
||||
signal: AbortSignal.timeout(600000), // 10 minutes timeout
|
||||
});
|
||||
|
||||
const { copyFile } = await import("fs/promises");
|
||||
await copyFile(sourcePath, targetPath);
|
||||
} else {
|
||||
const fileSizeMB = Number(file.size) / (1024 * 1024);
|
||||
const needsStreaming = fileSizeMB > 100;
|
||||
|
||||
const downloadUrl = await this.fileService.getPresignedGetUrl(file.objectName, 300);
|
||||
const uploadUrl = await this.fileService.getPresignedPutUrl(newObjectName, 300);
|
||||
|
||||
let retries = 0;
|
||||
const maxRetries = 3;
|
||||
let success = false;
|
||||
|
||||
while (retries < maxRetries && !success) {
|
||||
try {
|
||||
const response = await fetch(downloadUrl, {
|
||||
signal: AbortSignal.timeout(600000), // 10 minutes timeout
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to download file: ${response.statusText}`);
|
||||
}
|
||||
|
||||
if (!response.body) {
|
||||
throw new Error("No response body received");
|
||||
}
|
||||
|
||||
const uploadOptions: any = {
|
||||
method: "PUT",
|
||||
body: response.body,
|
||||
headers: {
|
||||
"Content-Type": "application/octet-stream",
|
||||
"Content-Length": file.size.toString(),
|
||||
},
|
||||
signal: AbortSignal.timeout(600000), // 10 minutes timeout
|
||||
};
|
||||
|
||||
const uploadResponse = await fetch(uploadUrl, uploadOptions);
|
||||
|
||||
if (!uploadResponse.ok) {
|
||||
const errorText = await uploadResponse.text();
|
||||
throw new Error(`Failed to upload file: ${uploadResponse.statusText} - ${errorText}`);
|
||||
}
|
||||
|
||||
success = true;
|
||||
} catch (error: any) {
|
||||
retries++;
|
||||
|
||||
if (retries >= maxRetries) {
|
||||
throw new Error(`Failed to copy file after ${maxRetries} attempts: ${error.message}`);
|
||||
}
|
||||
|
||||
const delay = Math.min(1000 * Math.pow(2, retries - 1), 10000);
|
||||
await new Promise((resolve) => setTimeout(resolve, delay));
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to download file: ${response.statusText}`);
|
||||
}
|
||||
|
||||
if (!response.body) {
|
||||
throw new Error("No response body received");
|
||||
}
|
||||
|
||||
const uploadOptions: any = {
|
||||
method: "PUT",
|
||||
body: response.body,
|
||||
headers: {
|
||||
"Content-Type": "application/octet-stream",
|
||||
"Content-Length": file.size.toString(),
|
||||
},
|
||||
signal: AbortSignal.timeout(600000), // 10 minutes timeout
|
||||
};
|
||||
|
||||
const uploadResponse = await fetch(uploadUrl, uploadOptions);
|
||||
|
||||
if (!uploadResponse.ok) {
|
||||
const errorText = await uploadResponse.text();
|
||||
throw new Error(`Failed to upload file: ${uploadResponse.statusText} - ${errorText}`);
|
||||
}
|
||||
|
||||
success = true;
|
||||
} catch (error: any) {
|
||||
retries++;
|
||||
|
||||
if (retries >= maxRetries) {
|
||||
throw new Error(`Failed to copy file after ${maxRetries} attempts: ${error.message}`);
|
||||
}
|
||||
|
||||
const delay = Math.min(1000 * Math.pow(2, retries - 1), 10000);
|
||||
await new Promise((resolve) => setTimeout(resolve, delay));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -625,6 +646,55 @@ export class ReverseShareService {
|
||||
};
|
||||
}
|
||||
|
||||
private generateSessionKey(reverseShareId: string, uploaderIdentifier: string): string {
|
||||
return `${reverseShareId}-${uploaderIdentifier}`;
|
||||
}
|
||||
|
||||
private async sendBatchFileUploadNotification(reverseShare: any, uploaderName: string, fileNames: string[]) {
|
||||
try {
|
||||
const creator = await this.userService.getUserById(reverseShare.creatorId);
|
||||
const reverseShareName = reverseShare.name || "Unnamed Reverse Share";
|
||||
const fileCount = fileNames.length;
|
||||
const fileList = fileNames.join(", ");
|
||||
|
||||
await this.emailService.sendReverseShareBatchFileNotification(
|
||||
creator.email,
|
||||
reverseShareName,
|
||||
fileCount,
|
||||
fileList,
|
||||
uploaderName
|
||||
);
|
||||
} catch (error) {
|
||||
console.error("Failed to send reverse share batch file notification:", error);
|
||||
}
|
||||
}
|
||||
|
||||
private addFileToUploadSession(reverseShare: any, fileData: UploadToReverseShareInput) {
|
||||
const uploaderIdentifier = fileData.uploaderEmail || fileData.uploaderName || "anonymous";
|
||||
const sessionKey = this.generateSessionKey(reverseShare.id, uploaderIdentifier);
|
||||
const uploaderName = fileData.uploaderName || "Someone";
|
||||
|
||||
const existingSession = this.uploadSessions.get(sessionKey);
|
||||
if (existingSession) {
|
||||
clearTimeout(existingSession.timeout);
|
||||
existingSession.files.push(fileData.name);
|
||||
} else {
|
||||
this.uploadSessions.set(sessionKey, {
|
||||
reverseShareId: reverseShare.id,
|
||||
uploaderName,
|
||||
uploaderEmail: fileData.uploaderEmail,
|
||||
files: [fileData.name],
|
||||
timeout: null as any,
|
||||
});
|
||||
}
|
||||
|
||||
const session = this.uploadSessions.get(sessionKey)!;
|
||||
session.timeout = setTimeout(async () => {
|
||||
await this.sendBatchFileUploadNotification(reverseShare, session.uploaderName, session.files);
|
||||
this.uploadSessions.delete(sessionKey);
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
private formatReverseShareResponse(reverseShare: ReverseShareData) {
|
||||
const result = {
|
||||
id: reverseShare.id,
|
||||
|
@@ -2,7 +2,7 @@ import { FastifyReply, FastifyRequest } from "fastify";
|
||||
|
||||
import {
|
||||
CreateShareSchema,
|
||||
UpdateShareFilesSchema,
|
||||
UpdateShareItemsSchema,
|
||||
UpdateSharePasswordSchema,
|
||||
UpdateShareRecipientsSchema,
|
||||
UpdateShareSchema,
|
||||
@@ -116,7 +116,7 @@ export class ShareController {
|
||||
}
|
||||
}
|
||||
|
||||
async addFiles(request: FastifyRequest, reply: FastifyReply) {
|
||||
async addItems(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const userId = (request as any).user?.userId;
|
||||
@@ -125,9 +125,9 @@ export class ShareController {
|
||||
}
|
||||
|
||||
const { shareId } = request.params as { shareId: string };
|
||||
const { files } = UpdateShareFilesSchema.parse(request.body);
|
||||
const { files, folders } = UpdateShareItemsSchema.parse(request.body);
|
||||
|
||||
const share = await this.shareService.addFilesToShare(shareId, userId, files);
|
||||
const share = await this.shareService.addItemsToShare(shareId, userId, files || [], folders || []);
|
||||
return reply.send({ share });
|
||||
} catch (error: any) {
|
||||
if (error.message === "Share not found") {
|
||||
@@ -136,14 +136,14 @@ export class ShareController {
|
||||
if (error.message === "Unauthorized to update this share") {
|
||||
return reply.status(401).send({ error: error.message });
|
||||
}
|
||||
if (error.message.startsWith("Files not found:")) {
|
||||
if (error.message.startsWith("Files not found:") || error.message.startsWith("Folders not found:")) {
|
||||
return reply.status(404).send({ error: error.message });
|
||||
}
|
||||
return reply.status(400).send({ error: error.message });
|
||||
}
|
||||
}
|
||||
|
||||
async removeFiles(request: FastifyRequest, reply: FastifyReply) {
|
||||
async removeItems(request: FastifyRequest, reply: FastifyReply) {
|
||||
try {
|
||||
await request.jwtVerify();
|
||||
const userId = (request as any).user?.userId;
|
||||
@@ -152,9 +152,9 @@ export class ShareController {
|
||||
}
|
||||
|
||||
const { shareId } = request.params as { shareId: string };
|
||||
const { files } = UpdateShareFilesSchema.parse(request.body);
|
||||
const { files, folders } = UpdateShareItemsSchema.parse(request.body);
|
||||
|
||||
const share = await this.shareService.removeFilesFromShare(shareId, userId, files);
|
||||
const share = await this.shareService.removeItemsFromShare(shareId, userId, files || [], folders || []);
|
||||
return reply.send({ share });
|
||||
} catch (error: any) {
|
||||
if (error.message === "Share not found") {
|
||||
|
@@ -1,19 +1,31 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const CreateShareSchema = z.object({
|
||||
name: z.string().optional().describe("The share name"),
|
||||
description: z.string().optional().describe("The share description"),
|
||||
expiration: z
|
||||
.string()
|
||||
.datetime({
|
||||
message: "Data de expiração deve estar no formato ISO 8601 (ex: 2025-02-06T13:20:49Z)",
|
||||
})
|
||||
.optional(),
|
||||
files: z.array(z.string()).describe("The file IDs"),
|
||||
password: z.string().optional().describe("The share password"),
|
||||
maxViews: z.number().optional().nullable().describe("The maximum number of views"),
|
||||
recipients: z.array(z.string().email()).optional().describe("The recipient emails"),
|
||||
});
|
||||
export const CreateShareSchema = z
|
||||
.object({
|
||||
name: z.string().optional().describe("The share name"),
|
||||
description: z.string().optional().describe("The share description"),
|
||||
expiration: z
|
||||
.string()
|
||||
.datetime({
|
||||
message: "Data de expiração deve estar no formato ISO 8601 (ex: 2025-02-06T13:20:49Z)",
|
||||
})
|
||||
.optional(),
|
||||
files: z.array(z.string()).optional().describe("The file IDs"),
|
||||
folders: z.array(z.string()).optional().describe("The folder IDs"),
|
||||
password: z.string().optional().describe("The share password"),
|
||||
maxViews: z.number().optional().nullable().describe("The maximum number of views"),
|
||||
recipients: z.array(z.string().email()).optional().describe("The recipient emails"),
|
||||
})
|
||||
.refine(
|
||||
(data) => {
|
||||
const hasFiles = data.files && data.files.length > 0;
|
||||
const hasFolders = data.folders && data.folders.length > 0;
|
||||
return hasFiles || hasFolders;
|
||||
},
|
||||
{
|
||||
message: "At least one file or folder must be selected to create a share",
|
||||
}
|
||||
);
|
||||
|
||||
export const UpdateShareSchema = z.object({
|
||||
id: z.string(),
|
||||
@@ -55,10 +67,30 @@ export const ShareResponseSchema = z.object({
|
||||
size: z.string().describe("The file size"),
|
||||
objectName: z.string().describe("The file object name"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
folderId: z.string().nullable().describe("The folder ID containing this file"),
|
||||
createdAt: z.string().describe("The file creation date"),
|
||||
updatedAt: z.string().describe("The file update date"),
|
||||
})
|
||||
),
|
||||
folders: z.array(
|
||||
z.object({
|
||||
id: z.string().describe("The folder ID"),
|
||||
name: z.string().describe("The folder name"),
|
||||
description: z.string().nullable().describe("The folder description"),
|
||||
objectName: z.string().describe("The folder object name"),
|
||||
parentId: z.string().nullable().describe("The parent folder ID"),
|
||||
userId: z.string().describe("The user ID"),
|
||||
totalSize: z.string().nullable().describe("The total size of folder contents"),
|
||||
createdAt: z.string().describe("The folder creation date"),
|
||||
updatedAt: z.string().describe("The folder update date"),
|
||||
_count: z
|
||||
.object({
|
||||
files: z.number().describe("Number of files in folder"),
|
||||
children: z.number().describe("Number of subfolders"),
|
||||
})
|
||||
.optional(),
|
||||
})
|
||||
),
|
||||
recipients: z.array(
|
||||
z.object({
|
||||
id: z.string().describe("The recipient ID"),
|
||||
@@ -74,9 +106,21 @@ export const UpdateSharePasswordSchema = z.object({
|
||||
password: z.string().nullable().describe("The new password. Send null to remove password"),
|
||||
});
|
||||
|
||||
export const UpdateShareFilesSchema = z.object({
|
||||
files: z.array(z.string().min(1, "File ID is required").describe("The file IDs")),
|
||||
});
|
||||
export const UpdateShareItemsSchema = z
|
||||
.object({
|
||||
files: z.array(z.string().min(1, "File ID is required").describe("The file IDs")).optional(),
|
||||
folders: z.array(z.string().min(1, "Folder ID is required").describe("The folder IDs")).optional(),
|
||||
})
|
||||
.refine(
|
||||
(data) => {
|
||||
const hasFiles = data.files && data.files.length > 0;
|
||||
const hasFolders = data.folders && data.folders.length > 0;
|
||||
return hasFiles || hasFolders;
|
||||
},
|
||||
{
|
||||
message: "At least one file or folder must be provided",
|
||||
}
|
||||
);
|
||||
|
||||
export const UpdateShareRecipientsSchema = z.object({
|
||||
emails: z.array(z.string().email("Invalid email format").describe("The recipient emails")),
|
||||
|
@@ -9,30 +9,39 @@ export interface IShareRepository {
|
||||
| (Share & {
|
||||
security: ShareSecurity;
|
||||
files: any[];
|
||||
folders: any[];
|
||||
recipients: { email: string }[];
|
||||
})
|
||||
| null
|
||||
>;
|
||||
findShareBySecurityId(securityId: string): Promise<(Share & { security: ShareSecurity; files: any[] }) | null>;
|
||||
findShareBySecurityId(
|
||||
securityId: string
|
||||
): Promise<(Share & { security: ShareSecurity; files: any[]; folders: any[] }) | null>;
|
||||
updateShare(id: string, data: Partial<Share>): Promise<Share>;
|
||||
updateShareSecurity(id: string, data: Partial<ShareSecurity>): Promise<ShareSecurity>;
|
||||
deleteShare(id: string): Promise<Share>;
|
||||
incrementViews(id: string): Promise<Share>;
|
||||
addFilesToShare(shareId: string, fileIds: string[]): Promise<void>;
|
||||
removeFilesFromShare(shareId: string, fileIds: string[]): Promise<void>;
|
||||
addFoldersToShare(shareId: string, folderIds: string[]): Promise<void>;
|
||||
removeFoldersFromShare(shareId: string, folderIds: string[]): Promise<void>;
|
||||
findFilesByIds(fileIds: string[]): Promise<any[]>;
|
||||
findFoldersByIds(folderIds: string[]): Promise<any[]>;
|
||||
addRecipients(shareId: string, emails: string[]): Promise<void>;
|
||||
removeRecipients(shareId: string, emails: string[]): Promise<void>;
|
||||
findSharesByUserId(userId: string): Promise<Share[]>;
|
||||
findSharesByUserId(
|
||||
userId: string
|
||||
): Promise<(Share & { security: ShareSecurity; files: any[]; folders: any[]; recipients: any[]; alias: any })[]>;
|
||||
}
|
||||
|
||||
export class PrismaShareRepository implements IShareRepository {
|
||||
async createShare(
|
||||
data: Omit<CreateShareInput, "password" | "maxViews"> & { securityId: string; creatorId: string }
|
||||
): Promise<Share> {
|
||||
const { files, recipients, expiration, ...shareData } = data;
|
||||
const { files, folders, recipients, expiration, ...shareData } = data;
|
||||
|
||||
const validFiles = (files ?? []).filter((id) => id && id.trim().length > 0);
|
||||
const validFolders = (folders ?? []).filter((id) => id && id.trim().length > 0);
|
||||
const validRecipients = (recipients ?? []).filter((email) => email && email.trim().length > 0);
|
||||
|
||||
return prisma.share.create({
|
||||
@@ -45,6 +54,12 @@ export class PrismaShareRepository implements IShareRepository {
|
||||
connect: validFiles.map((id) => ({ id })),
|
||||
}
|
||||
: undefined,
|
||||
folders:
|
||||
validFolders.length > 0
|
||||
? {
|
||||
connect: validFolders.map((id) => ({ id })),
|
||||
}
|
||||
: undefined,
|
||||
recipients:
|
||||
validRecipients?.length > 0
|
||||
? {
|
||||
@@ -61,10 +76,28 @@ export class PrismaShareRepository implements IShareRepository {
|
||||
return prisma.share.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
alias: true,
|
||||
security: true,
|
||||
files: true,
|
||||
folders: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
description: true,
|
||||
objectName: true,
|
||||
parentId: true,
|
||||
userId: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
_count: {
|
||||
select: {
|
||||
files: true,
|
||||
children: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
recipients: true,
|
||||
alias: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -75,6 +108,24 @@ export class PrismaShareRepository implements IShareRepository {
|
||||
include: {
|
||||
security: true,
|
||||
files: true,
|
||||
folders: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
description: true,
|
||||
objectName: true,
|
||||
parentId: true,
|
||||
userId: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
_count: {
|
||||
select: {
|
||||
files: true,
|
||||
children: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -121,6 +172,17 @@ export class PrismaShareRepository implements IShareRepository {
|
||||
});
|
||||
}
|
||||
|
||||
async addFoldersToShare(shareId: string, folderIds: string[]): Promise<void> {
|
||||
await prisma.share.update({
|
||||
where: { id: shareId },
|
||||
data: {
|
||||
folders: {
|
||||
connect: folderIds.map((id) => ({ id })),
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async removeFilesFromShare(shareId: string, fileIds: string[]): Promise<void> {
|
||||
await prisma.share.update({
|
||||
where: { id: shareId },
|
||||
@@ -132,6 +194,17 @@ export class PrismaShareRepository implements IShareRepository {
|
||||
});
|
||||
}
|
||||
|
||||
async removeFoldersFromShare(shareId: string, folderIds: string[]): Promise<void> {
|
||||
await prisma.share.update({
|
||||
where: { id: shareId },
|
||||
data: {
|
||||
folders: {
|
||||
disconnect: folderIds.map((id) => ({ id })),
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async findFilesByIds(fileIds: string[]): Promise<any[]> {
|
||||
return prisma.file.findMany({
|
||||
where: {
|
||||
@@ -142,6 +215,16 @@ export class PrismaShareRepository implements IShareRepository {
|
||||
});
|
||||
}
|
||||
|
||||
async findFoldersByIds(folderIds: string[]): Promise<any[]> {
|
||||
return prisma.folder.findMany({
|
||||
where: {
|
||||
id: {
|
||||
in: folderIds,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async addRecipients(shareId: string, emails: string[]): Promise<void> {
|
||||
await prisma.share.update({
|
||||
where: { id: shareId },
|
||||
@@ -178,6 +261,24 @@ export class PrismaShareRepository implements IShareRepository {
|
||||
include: {
|
||||
security: true,
|
||||
files: true,
|
||||
folders: {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
description: true,
|
||||
objectName: true,
|
||||
parentId: true,
|
||||
userId: true,
|
||||
createdAt: true,
|
||||
updatedAt: true,
|
||||
_count: {
|
||||
select: {
|
||||
files: true,
|
||||
children: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
recipients: true,
|
||||
alias: true,
|
||||
},
|
||||
|
@@ -6,7 +6,7 @@ import {
|
||||
CreateShareSchema,
|
||||
ShareAliasResponseSchema,
|
||||
ShareResponseSchema,
|
||||
UpdateShareFilesSchema,
|
||||
UpdateShareItemsSchema,
|
||||
UpdateSharePasswordSchema,
|
||||
UpdateShareRecipientsSchema,
|
||||
UpdateShareSchema,
|
||||
@@ -32,7 +32,7 @@ export async function shareRoutes(app: FastifyInstance) {
|
||||
tags: ["Share"],
|
||||
operationId: "createShare",
|
||||
summary: "Create a new share",
|
||||
description: "Create a new share",
|
||||
description: "Create a new share with files and/or folders",
|
||||
body: CreateShareSchema,
|
||||
response: {
|
||||
201: z.object({
|
||||
@@ -164,17 +164,17 @@ export async function shareRoutes(app: FastifyInstance) {
|
||||
);
|
||||
|
||||
app.post(
|
||||
"/shares/:shareId/files",
|
||||
"/shares/:shareId/items",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["Share"],
|
||||
operationId: "addFiles",
|
||||
summary: "Add files to share",
|
||||
operationId: "addItems",
|
||||
summary: "Add files and/or folders to share",
|
||||
params: z.object({
|
||||
shareId: z.string().describe("The share ID"),
|
||||
}),
|
||||
body: UpdateShareFilesSchema,
|
||||
body: UpdateShareItemsSchema,
|
||||
response: {
|
||||
200: z.object({
|
||||
share: ShareResponseSchema,
|
||||
@@ -185,21 +185,21 @@ export async function shareRoutes(app: FastifyInstance) {
|
||||
},
|
||||
},
|
||||
},
|
||||
shareController.addFiles.bind(shareController)
|
||||
shareController.addItems.bind(shareController)
|
||||
);
|
||||
|
||||
app.delete(
|
||||
"/shares/:shareId/files",
|
||||
"/shares/:shareId/items",
|
||||
{
|
||||
preValidation,
|
||||
schema: {
|
||||
tags: ["Share"],
|
||||
operationId: "removeFiles",
|
||||
summary: "Remove files from share",
|
||||
operationId: "removeItems",
|
||||
summary: "Remove files and/or folders from share",
|
||||
params: z.object({
|
||||
shareId: z.string().describe("The share ID"),
|
||||
}),
|
||||
body: UpdateShareFilesSchema,
|
||||
body: UpdateShareItemsSchema,
|
||||
response: {
|
||||
200: z.object({
|
||||
share: ShareResponseSchema,
|
||||
@@ -210,7 +210,7 @@ export async function shareRoutes(app: FastifyInstance) {
|
||||
},
|
||||
},
|
||||
},
|
||||
shareController.removeFiles.bind(shareController)
|
||||
shareController.removeItems.bind(shareController)
|
||||
);
|
||||
|
||||
app.post(
|
||||
|
@@ -2,6 +2,8 @@ import bcrypt from "bcryptjs";
|
||||
|
||||
import { prisma } from "../../shared/prisma";
|
||||
import { EmailService } from "../email/service";
|
||||
import { FolderService } from "../folder/service";
|
||||
import { UserService } from "../user/service";
|
||||
import { CreateShareInput, ShareResponseSchema, UpdateShareInput } from "./dto";
|
||||
import { IShareRepository, PrismaShareRepository } from "./repository";
|
||||
|
||||
@@ -9,8 +11,10 @@ export class ShareService {
|
||||
constructor(private readonly shareRepository: IShareRepository = new PrismaShareRepository()) {}
|
||||
|
||||
private emailService = new EmailService();
|
||||
private userService = new UserService();
|
||||
private folderService = new FolderService();
|
||||
|
||||
private formatShareResponse(share: any) {
|
||||
private async formatShareResponse(share: any) {
|
||||
return {
|
||||
...share,
|
||||
createdAt: share.createdAt.toISOString(),
|
||||
@@ -34,6 +38,20 @@ export class ShareService {
|
||||
createdAt: file.createdAt.toISOString(),
|
||||
updatedAt: file.updatedAt.toISOString(),
|
||||
})) || [],
|
||||
folders:
|
||||
share.folders && share.folders.length > 0
|
||||
? await Promise.all(
|
||||
share.folders.map(async (folder: any) => {
|
||||
const totalSize = await this.folderService.calculateFolderSize(folder.id, folder.userId);
|
||||
return {
|
||||
...folder,
|
||||
totalSize: totalSize.toString(),
|
||||
createdAt: folder.createdAt.toISOString(),
|
||||
updatedAt: folder.updatedAt.toISOString(),
|
||||
};
|
||||
})
|
||||
)
|
||||
: [],
|
||||
recipients:
|
||||
share.recipients?.map((recipient: any) => ({
|
||||
...recipient,
|
||||
@@ -44,7 +62,37 @@ export class ShareService {
|
||||
}
|
||||
|
||||
async createShare(data: CreateShareInput, userId: string) {
|
||||
const { password, maxViews, ...shareData } = data;
|
||||
const { password, maxViews, files, folders, ...shareData } = data;
|
||||
|
||||
if (files && files.length > 0) {
|
||||
const existingFiles = await prisma.file.findMany({
|
||||
where: {
|
||||
id: { in: files },
|
||||
userId: userId,
|
||||
},
|
||||
});
|
||||
const notFoundFiles = files.filter((id) => !existingFiles.some((file) => file.id === id));
|
||||
if (notFoundFiles.length > 0) {
|
||||
throw new Error(`Files not found or access denied: ${notFoundFiles.join(", ")}`);
|
||||
}
|
||||
}
|
||||
|
||||
if (folders && folders.length > 0) {
|
||||
const existingFolders = await prisma.folder.findMany({
|
||||
where: {
|
||||
id: { in: folders },
|
||||
userId: userId,
|
||||
},
|
||||
});
|
||||
const notFoundFolders = folders.filter((id) => !existingFolders.some((folder) => folder.id === id));
|
||||
if (notFoundFolders.length > 0) {
|
||||
throw new Error(`Folders not found or access denied: ${notFoundFolders.join(", ")}`);
|
||||
}
|
||||
}
|
||||
|
||||
if ((!files || files.length === 0) && (!folders || folders.length === 0)) {
|
||||
throw new Error("At least one file or folder must be selected to create a share");
|
||||
}
|
||||
|
||||
const security = await prisma.shareSecurity.create({
|
||||
data: {
|
||||
@@ -55,12 +103,14 @@ export class ShareService {
|
||||
|
||||
const share = await this.shareRepository.createShare({
|
||||
...shareData,
|
||||
files,
|
||||
folders,
|
||||
securityId: security.id,
|
||||
creatorId: userId,
|
||||
});
|
||||
|
||||
const shareWithRelations = await this.shareRepository.findShareById(share.id);
|
||||
return ShareResponseSchema.parse(this.formatShareResponse(shareWithRelations));
|
||||
return ShareResponseSchema.parse(await this.formatShareResponse(shareWithRelations));
|
||||
}
|
||||
|
||||
async getShare(shareId: string, password?: string, userId?: string) {
|
||||
@@ -71,7 +121,7 @@ export class ShareService {
|
||||
}
|
||||
|
||||
if (userId && share.creatorId === userId) {
|
||||
return ShareResponseSchema.parse(this.formatShareResponse(share));
|
||||
return ShareResponseSchema.parse(await this.formatShareResponse(share));
|
||||
}
|
||||
|
||||
if (share.expiration && new Date() > new Date(share.expiration)) {
|
||||
@@ -96,7 +146,7 @@ export class ShareService {
|
||||
await this.shareRepository.incrementViews(shareId);
|
||||
|
||||
const updatedShare = await this.shareRepository.findShareById(shareId);
|
||||
return ShareResponseSchema.parse(this.formatShareResponse(updatedShare));
|
||||
return ShareResponseSchema.parse(await this.formatShareResponse(updatedShare));
|
||||
}
|
||||
|
||||
async updateShare(shareId: string, data: Omit<UpdateShareInput, "id">, userId: string) {
|
||||
@@ -134,7 +184,7 @@ export class ShareService {
|
||||
});
|
||||
const shareWithRelations = await this.shareRepository.findShareById(shareId);
|
||||
|
||||
return this.formatShareResponse(shareWithRelations);
|
||||
return await this.formatShareResponse(shareWithRelations);
|
||||
}
|
||||
|
||||
async deleteShare(id: string) {
|
||||
@@ -170,12 +220,12 @@ export class ShareService {
|
||||
return deletedShare;
|
||||
});
|
||||
|
||||
return ShareResponseSchema.parse(this.formatShareResponse(deleted));
|
||||
return ShareResponseSchema.parse(await this.formatShareResponse(deleted));
|
||||
}
|
||||
|
||||
async listUserShares(userId: string) {
|
||||
const shares = await this.shareRepository.findSharesByUserId(userId);
|
||||
return shares.map((share) => this.formatShareResponse(share));
|
||||
return await Promise.all(shares.map(async (share) => await this.formatShareResponse(share)));
|
||||
}
|
||||
|
||||
async updateSharePassword(shareId: string, userId: string, password: string | null) {
|
||||
@@ -193,10 +243,10 @@ export class ShareService {
|
||||
});
|
||||
|
||||
const updated = await this.shareRepository.findShareById(shareId);
|
||||
return ShareResponseSchema.parse(this.formatShareResponse(updated));
|
||||
return ShareResponseSchema.parse(await this.formatShareResponse(updated));
|
||||
}
|
||||
|
||||
async addFilesToShare(shareId: string, userId: string, fileIds: string[]) {
|
||||
async addItemsToShare(shareId: string, userId: string, fileIds: string[], folderIds: string[]) {
|
||||
const share = await this.shareRepository.findShareById(shareId);
|
||||
if (!share) {
|
||||
throw new Error("Share not found");
|
||||
@@ -206,19 +256,33 @@ export class ShareService {
|
||||
throw new Error("Unauthorized to update this share");
|
||||
}
|
||||
|
||||
const existingFiles = await this.shareRepository.findFilesByIds(fileIds);
|
||||
const notFoundFiles = fileIds.filter((id) => !existingFiles.some((file) => file.id === id));
|
||||
if (fileIds.length > 0) {
|
||||
const existingFiles = await this.shareRepository.findFilesByIds(fileIds);
|
||||
const notFoundFiles = fileIds.filter((id) => !existingFiles.some((file) => file.id === id));
|
||||
|
||||
if (notFoundFiles.length > 0) {
|
||||
throw new Error(`Files not found: ${notFoundFiles.join(", ")}`);
|
||||
if (notFoundFiles.length > 0) {
|
||||
throw new Error(`Files not found: ${notFoundFiles.join(", ")}`);
|
||||
}
|
||||
|
||||
await this.shareRepository.addFilesToShare(shareId, fileIds);
|
||||
}
|
||||
|
||||
if (folderIds.length > 0) {
|
||||
const existingFolders = await this.shareRepository.findFoldersByIds(folderIds);
|
||||
const notFoundFolders = folderIds.filter((id) => !existingFolders.some((folder) => folder.id === id));
|
||||
|
||||
if (notFoundFolders.length > 0) {
|
||||
throw new Error(`Folders not found: ${notFoundFolders.join(", ")}`);
|
||||
}
|
||||
|
||||
await this.shareRepository.addFoldersToShare(shareId, folderIds);
|
||||
}
|
||||
|
||||
await this.shareRepository.addFilesToShare(shareId, fileIds);
|
||||
const updated = await this.shareRepository.findShareById(shareId);
|
||||
return ShareResponseSchema.parse(this.formatShareResponse(updated));
|
||||
return ShareResponseSchema.parse(await this.formatShareResponse(updated));
|
||||
}
|
||||
|
||||
async removeFilesFromShare(shareId: string, userId: string, fileIds: string[]) {
|
||||
async removeItemsFromShare(shareId: string, userId: string, fileIds: string[], folderIds: string[]) {
|
||||
const share = await this.shareRepository.findShareById(shareId);
|
||||
if (!share) {
|
||||
throw new Error("Share not found");
|
||||
@@ -228,9 +292,16 @@ export class ShareService {
|
||||
throw new Error("Unauthorized to update this share");
|
||||
}
|
||||
|
||||
await this.shareRepository.removeFilesFromShare(shareId, fileIds);
|
||||
if (fileIds.length > 0) {
|
||||
await this.shareRepository.removeFilesFromShare(shareId, fileIds);
|
||||
}
|
||||
|
||||
if (folderIds.length > 0) {
|
||||
await this.shareRepository.removeFoldersFromShare(shareId, folderIds);
|
||||
}
|
||||
|
||||
const updated = await this.shareRepository.findShareById(shareId);
|
||||
return ShareResponseSchema.parse(this.formatShareResponse(updated));
|
||||
return ShareResponseSchema.parse(await this.formatShareResponse(updated));
|
||||
}
|
||||
|
||||
async findShareById(id: string) {
|
||||
@@ -253,7 +324,7 @@ export class ShareService {
|
||||
|
||||
await this.shareRepository.addRecipients(shareId, emails);
|
||||
const updated = await this.shareRepository.findShareById(shareId);
|
||||
return ShareResponseSchema.parse(this.formatShareResponse(updated));
|
||||
return ShareResponseSchema.parse(await this.formatShareResponse(updated));
|
||||
}
|
||||
|
||||
async removeRecipients(shareId: string, userId: string, emails: string[]) {
|
||||
@@ -268,7 +339,7 @@ export class ShareService {
|
||||
|
||||
await this.shareRepository.removeRecipients(shareId, emails);
|
||||
const updated = await this.shareRepository.findShareById(shareId);
|
||||
return ShareResponseSchema.parse(this.formatShareResponse(updated));
|
||||
return ShareResponseSchema.parse(await this.formatShareResponse(updated));
|
||||
}
|
||||
|
||||
async createOrUpdateAlias(shareId: string, alias: string, userId: string) {
|
||||
@@ -339,11 +410,25 @@ export class ShareService {
|
||||
throw new Error("No recipients found for this share");
|
||||
}
|
||||
|
||||
let senderName = "Someone";
|
||||
try {
|
||||
const sender = await this.userService.getUserById(userId);
|
||||
if (sender.firstName && sender.lastName) {
|
||||
senderName = `${sender.firstName} ${sender.lastName}`;
|
||||
} else if (sender.firstName) {
|
||||
senderName = sender.firstName;
|
||||
} else if (sender.username) {
|
||||
senderName = sender.username;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Failed to get sender information for user ${userId}:`, error);
|
||||
}
|
||||
|
||||
const notifiedRecipients: string[] = [];
|
||||
|
||||
for (const recipient of share.recipients) {
|
||||
try {
|
||||
await this.emailService.sendShareNotification(recipient.email, shareLink, share.name || undefined);
|
||||
await this.emailService.sendShareNotification(recipient.email, shareLink, share.name || undefined, senderName);
|
||||
notifiedRecipients.push(recipient.email);
|
||||
} catch (error) {
|
||||
console.error(`Failed to send email to ${recipient.email}:`, error);
|
||||
|
@@ -3,6 +3,7 @@ import fs from "node:fs";
|
||||
import { promisify } from "util";
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
|
||||
import { env } from "../../env";
|
||||
import { IS_RUNNING_IN_CONTAINER } from "../../utils/container-detection";
|
||||
import { ConfigService } from "../config/service";
|
||||
|
||||
@@ -21,6 +22,30 @@ export class StorageService {
|
||||
return Number.isNaN(parsed) ? 0 : parsed;
|
||||
}
|
||||
|
||||
private _parseSize(value: string): number {
|
||||
if (!value) return 0;
|
||||
|
||||
const cleanValue = value.trim().toLowerCase();
|
||||
|
||||
const numericMatch = cleanValue.match(/^(\d+(?:\.\d+)?)/);
|
||||
if (!numericMatch) return 0;
|
||||
|
||||
const numericValue = parseFloat(numericMatch[1]);
|
||||
if (Number.isNaN(numericValue)) return 0;
|
||||
|
||||
if (cleanValue.includes("t")) {
|
||||
return Math.round(numericValue * 1024 * 1024 * 1024 * 1024);
|
||||
} else if (cleanValue.includes("g")) {
|
||||
return Math.round(numericValue * 1024 * 1024 * 1024);
|
||||
} else if (cleanValue.includes("m")) {
|
||||
return Math.round(numericValue * 1024 * 1024);
|
||||
} else if (cleanValue.includes("k")) {
|
||||
return Math.round(numericValue * 1024);
|
||||
} else {
|
||||
return Math.round(numericValue);
|
||||
}
|
||||
}
|
||||
|
||||
private async _tryDiskSpaceCommand(command: string): Promise<{ total: number; available: number } | null> {
|
||||
try {
|
||||
const { stdout, stderr } = await execAsync(command);
|
||||
@@ -54,16 +79,61 @@ export class StorageService {
|
||||
}
|
||||
} else {
|
||||
const lines = stdout.trim().split("\n");
|
||||
if (lines.length >= 2) {
|
||||
const parts = lines[1].trim().split(/\s+/);
|
||||
if (parts.length >= 4) {
|
||||
const [, size, , avail] = parts;
|
||||
if (command.includes("-B1")) {
|
||||
total = this._safeParseInt(size);
|
||||
available = this._safeParseInt(avail);
|
||||
} else {
|
||||
total = this._safeParseInt(size) * 1024;
|
||||
available = this._safeParseInt(avail) * 1024;
|
||||
|
||||
if (command.includes("findmnt")) {
|
||||
if (lines.length >= 1) {
|
||||
const parts = lines[0].trim().split(/\s+/);
|
||||
if (parts.length >= 2) {
|
||||
const [availStr, sizeStr] = parts;
|
||||
available = this._parseSize(availStr);
|
||||
total = this._parseSize(sizeStr);
|
||||
}
|
||||
}
|
||||
} else if (command.includes("stat -f")) {
|
||||
let blockSize = 0;
|
||||
let totalBlocks = 0;
|
||||
let freeBlocks = 0;
|
||||
|
||||
for (const line of lines) {
|
||||
if (line.includes("Block size:")) {
|
||||
blockSize = this._safeParseInt(line.split(":")[1].trim());
|
||||
} else if (line.includes("Total blocks:")) {
|
||||
totalBlocks = this._safeParseInt(line.split(":")[1].trim());
|
||||
} else if (line.includes("Free blocks:")) {
|
||||
freeBlocks = this._safeParseInt(line.split(":")[1].trim());
|
||||
}
|
||||
}
|
||||
|
||||
if (blockSize > 0 && totalBlocks > 0) {
|
||||
total = totalBlocks * blockSize;
|
||||
available = freeBlocks * blockSize;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else if (command.includes("--output=")) {
|
||||
if (lines.length >= 2) {
|
||||
const parts = lines[1].trim().split(/\s+/);
|
||||
if (parts.length >= 2) {
|
||||
const [availStr, sizeStr] = parts;
|
||||
available = this._safeParseInt(availStr) * 1024;
|
||||
total = this._safeParseInt(sizeStr) * 1024;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (lines.length >= 2) {
|
||||
const parts = lines[1].trim().split(/\s+/);
|
||||
if (parts.length >= 4) {
|
||||
const [, size, , avail] = parts;
|
||||
if (command.includes("-B1")) {
|
||||
total = this._safeParseInt(size);
|
||||
available = this._safeParseInt(avail);
|
||||
} else if (command.includes("-h")) {
|
||||
total = this._parseSize(size);
|
||||
available = this._parseSize(avail);
|
||||
} else {
|
||||
total = this._safeParseInt(size) * 1024;
|
||||
available = this._safeParseInt(avail) * 1024;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,18 +142,13 @@ export class StorageService {
|
||||
if (total > 0 && available >= 0) {
|
||||
return { total, available };
|
||||
} else {
|
||||
console.warn(`Invalid values parsed: total=${total}, available=${available}`);
|
||||
return null;
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(`Command failed: ${command}`, error);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets detailed mount information for debugging
|
||||
*/
|
||||
private async _getMountInfo(path: string): Promise<{ filesystem: string; mountPoint: string; type: string } | null> {
|
||||
try {
|
||||
if (!fs.existsSync("/proc/mounts")) {
|
||||
@@ -109,16 +174,11 @@ export class StorageService {
|
||||
}
|
||||
|
||||
return bestMatch;
|
||||
} catch (error) {
|
||||
console.warn(`Could not get mount info for ${path}:`, error);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Detects if a path is a bind mount or mount point by checking /proc/mounts
|
||||
* Returns the actual filesystem path for bind mounts
|
||||
*/
|
||||
private async _detectMountPoint(path: string): Promise<string | null> {
|
||||
try {
|
||||
if (!fs.existsSync("/proc/mounts")) {
|
||||
@@ -133,9 +193,8 @@ export class StorageService {
|
||||
|
||||
for (const line of lines) {
|
||||
const parts = line.split(/\s+/);
|
||||
if (parts.length >= 2) {
|
||||
const [, mountPoint] = parts;
|
||||
|
||||
if (parts.length >= 3) {
|
||||
const [device, mountPoint, filesystem] = parts;
|
||||
if (path.startsWith(mountPoint) && mountPoint.length > bestMatchLength) {
|
||||
bestMatch = mountPoint;
|
||||
bestMatchLength = mountPoint.length;
|
||||
@@ -148,24 +207,16 @@ export class StorageService {
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (error) {
|
||||
console.warn(`Could not detect mount point for ${path}:`, error);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets filesystem information for a specific path, with bind mount detection
|
||||
*/
|
||||
private async _getFileSystemInfo(
|
||||
path: string
|
||||
): Promise<{ total: number; available: number; mountPoint?: string } | null> {
|
||||
try {
|
||||
const mountInfo = await this._getMountInfo(path);
|
||||
if (mountInfo && mountInfo.mountPoint !== "/") {
|
||||
console.log(`📁 Bind mount detected: ${path} → ${mountInfo.filesystem} (${mountInfo.type})`);
|
||||
}
|
||||
|
||||
const mountPoint = await this._detectMountPoint(path);
|
||||
const targetPath = mountPoint || path;
|
||||
|
||||
@@ -174,7 +225,18 @@ export class StorageService {
|
||||
? ["wmic logicaldisk get size,freespace,caption"]
|
||||
: process.platform === "darwin"
|
||||
? [`df -k "${targetPath}"`, `df "${targetPath}"`]
|
||||
: [`df -B1 "${targetPath}"`, `df -k "${targetPath}"`, `df "${targetPath}"`];
|
||||
: [
|
||||
`df -B1 "${targetPath}"`,
|
||||
`df -k "${targetPath}"`,
|
||||
`df "${targetPath}"`,
|
||||
`df -h "${targetPath}"`,
|
||||
`df -T "${targetPath}"`,
|
||||
`stat -f "${targetPath}"`,
|
||||
`findmnt -n -o AVAIL,SIZE "${targetPath}"`,
|
||||
`findmnt -n -o AVAIL,SIZE,TARGET "${targetPath}"`,
|
||||
`df -P "${targetPath}"`,
|
||||
`df --output=avail,size "${targetPath}"`,
|
||||
];
|
||||
|
||||
for (const command of commandsToTry) {
|
||||
const result = await this._tryDiskSpaceCommand(command);
|
||||
@@ -187,25 +249,54 @@ export class StorageService {
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (error) {
|
||||
console.warn(`Error getting filesystem info for ${path}:`, error);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async _detectSynologyVolumes(): Promise<string[]> {
|
||||
try {
|
||||
if (!fs.existsSync("/proc/mounts")) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const mountsContent = await fs.promises.readFile("/proc/mounts", "utf8");
|
||||
const lines = mountsContent.split("\n").filter((line) => line.trim());
|
||||
const synologyPaths: string[] = [];
|
||||
|
||||
for (const line of lines) {
|
||||
const parts = line.split(/\s+/);
|
||||
if (parts.length >= 2) {
|
||||
const [, mountPoint] = parts;
|
||||
|
||||
if (mountPoint.match(/^\/volume\d+$/)) {
|
||||
synologyPaths.push(mountPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return synologyPaths;
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
private async _getDiskSpaceMultiplePaths(): Promise<{ total: number; available: number } | null> {
|
||||
const pathsToTry = IS_RUNNING_IN_CONTAINER
|
||||
? ["/app/server/uploads", "/app/server", "/app", "/"]
|
||||
: [".", "./uploads", process.cwd()];
|
||||
const basePaths = IS_RUNNING_IN_CONTAINER
|
||||
? ["/app/server/uploads", "/app/server/temp-uploads", "/app/server/temp-chunks", "/app/server", "/app", "/"]
|
||||
: [env.CUSTOM_PATH || ".", "./uploads", process.cwd()];
|
||||
|
||||
const synologyPaths = await this._detectSynologyVolumes();
|
||||
|
||||
const pathsToTry = [...basePaths, ...synologyPaths];
|
||||
|
||||
for (const pathToCheck of pathsToTry) {
|
||||
if (pathToCheck.includes("uploads")) {
|
||||
if (pathToCheck.includes("uploads") || pathToCheck.includes("temp-")) {
|
||||
try {
|
||||
if (!fs.existsSync(pathToCheck)) {
|
||||
fs.mkdirSync(pathToCheck, { recursive: true });
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn(`Could not create path ${pathToCheck}:`, err);
|
||||
} catch {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -214,12 +305,8 @@ export class StorageService {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Use the new filesystem detection method
|
||||
const result = await this._getFileSystemInfo(pathToCheck);
|
||||
if (result) {
|
||||
if (result.mountPoint) {
|
||||
console.log(`✅ Storage resolved via bind mount: ${result.mountPoint}`);
|
||||
}
|
||||
return { total: result.total, available: result.available };
|
||||
}
|
||||
}
|
||||
@@ -241,7 +328,6 @@ export class StorageService {
|
||||
const diskInfo = await this._getDiskSpaceMultiplePaths();
|
||||
|
||||
if (!diskInfo) {
|
||||
console.error("❌ Could not determine disk space - system configuration issue");
|
||||
throw new Error("Unable to determine actual disk space - system configuration issue");
|
||||
}
|
||||
|
||||
@@ -256,7 +342,7 @@ export class StorageService {
|
||||
diskSizeGB: Number(diskSizeGB.toFixed(2)),
|
||||
diskUsedGB: Number(diskUsedGB.toFixed(2)),
|
||||
diskAvailableGB: Number(diskAvailableGB.toFixed(2)),
|
||||
uploadAllowed: diskAvailableGB > 0.1, // At least 100MB free
|
||||
uploadAllowed: diskAvailableGB > 0.1,
|
||||
};
|
||||
} else if (userId) {
|
||||
const maxTotalStorage = BigInt(await this.configService.getValue("maxTotalStoragePerUser"));
|
||||
@@ -268,7 +354,6 @@ export class StorageService {
|
||||
});
|
||||
|
||||
const totalUsedStorage = userFiles.reduce((acc, file) => acc + file.size, BigInt(0));
|
||||
|
||||
const usedStorageGB = this._ensureNumber(Number(totalUsedStorage) / (1024 * 1024 * 1024), 0);
|
||||
const availableStorageGB = this._ensureNumber(maxStorageGB - usedStorageGB, 0);
|
||||
|
||||
@@ -282,7 +367,7 @@ export class StorageService {
|
||||
|
||||
throw new Error("User ID is required for non-admin users");
|
||||
} catch (error) {
|
||||
console.error("❌ Error getting disk space:", error);
|
||||
console.error("Error getting disk space:", error);
|
||||
throw new Error(
|
||||
`Failed to get disk space information: ${error instanceof Error ? error.message : String(error)}`
|
||||
);
|
||||
|
@@ -1,373 +0,0 @@
|
||||
import * as crypto from "crypto";
|
||||
import * as fsSync from "fs";
|
||||
import * as fs from "fs/promises";
|
||||
import * as path from "path";
|
||||
import { Transform } from "stream";
|
||||
import { pipeline } from "stream/promises";
|
||||
|
||||
import { directoriesConfig, getTempFilePath } from "../config/directories.config";
|
||||
import { env } from "../env";
|
||||
import { StorageProvider } from "../types/storage";
|
||||
import { IS_RUNNING_IN_CONTAINER } from "../utils/container-detection";
|
||||
|
||||
export class FilesystemStorageProvider implements StorageProvider {
|
||||
private static instance: FilesystemStorageProvider;
|
||||
private uploadsDir: string;
|
||||
private encryptionKey = env.ENCRYPTION_KEY;
|
||||
private uploadTokens = new Map<string, { objectName: string; expiresAt: number }>();
|
||||
private downloadTokens = new Map<string, { objectName: string; expiresAt: number; fileName?: string }>();
|
||||
|
||||
private constructor() {
|
||||
this.uploadsDir = directoriesConfig.uploads;
|
||||
|
||||
this.ensureUploadsDir();
|
||||
setInterval(() => this.cleanExpiredTokens(), 5 * 60 * 1000);
|
||||
setInterval(() => this.cleanupEmptyTempDirs(), 10 * 60 * 1000); // Every 10 minutes
|
||||
}
|
||||
|
||||
public static getInstance(): FilesystemStorageProvider {
|
||||
if (!FilesystemStorageProvider.instance) {
|
||||
FilesystemStorageProvider.instance = new FilesystemStorageProvider();
|
||||
}
|
||||
return FilesystemStorageProvider.instance;
|
||||
}
|
||||
|
||||
private async ensureUploadsDir(): Promise<void> {
|
||||
try {
|
||||
await fs.access(this.uploadsDir);
|
||||
} catch {
|
||||
await fs.mkdir(this.uploadsDir, { recursive: true });
|
||||
}
|
||||
}
|
||||
|
||||
private cleanExpiredTokens(): void {
|
||||
const now = Date.now();
|
||||
|
||||
for (const [token, data] of this.uploadTokens.entries()) {
|
||||
if (now > data.expiresAt) {
|
||||
this.uploadTokens.delete(token);
|
||||
}
|
||||
}
|
||||
|
||||
for (const [token, data] of this.downloadTokens.entries()) {
|
||||
if (now > data.expiresAt) {
|
||||
this.downloadTokens.delete(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public getFilePath(objectName: string): string {
|
||||
const sanitizedName = objectName.replace(/[^a-zA-Z0-9\-_./]/g, "_");
|
||||
return path.join(this.uploadsDir, sanitizedName);
|
||||
}
|
||||
|
||||
private createEncryptionKey(): Buffer {
|
||||
return crypto.scryptSync(this.encryptionKey, "salt", 32);
|
||||
}
|
||||
|
||||
public createEncryptStream(): Transform {
|
||||
const key = this.createEncryptionKey();
|
||||
const iv = crypto.randomBytes(16);
|
||||
const cipher = crypto.createCipheriv("aes-256-cbc", key, iv);
|
||||
|
||||
let isFirstChunk = true;
|
||||
|
||||
return new Transform({
|
||||
transform(chunk, encoding, callback) {
|
||||
try {
|
||||
if (isFirstChunk) {
|
||||
this.push(iv);
|
||||
isFirstChunk = false;
|
||||
}
|
||||
|
||||
const encrypted = cipher.update(chunk);
|
||||
this.push(encrypted);
|
||||
callback();
|
||||
} catch (error) {
|
||||
callback(error as Error);
|
||||
}
|
||||
},
|
||||
|
||||
flush(callback) {
|
||||
try {
|
||||
const final = cipher.final();
|
||||
this.push(final);
|
||||
callback();
|
||||
} catch (error) {
|
||||
callback(error as Error);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
public createDecryptStream(): Transform {
|
||||
const key = this.createEncryptionKey();
|
||||
let iv: Buffer | null = null;
|
||||
let decipher: crypto.Decipher | null = null;
|
||||
let ivBuffer = Buffer.alloc(0);
|
||||
|
||||
return new Transform({
|
||||
transform(chunk, encoding, callback) {
|
||||
try {
|
||||
if (!iv) {
|
||||
ivBuffer = Buffer.concat([ivBuffer, chunk]);
|
||||
|
||||
if (ivBuffer.length >= 16) {
|
||||
iv = ivBuffer.slice(0, 16);
|
||||
decipher = crypto.createDecipheriv("aes-256-cbc", key, iv);
|
||||
const remainingData = ivBuffer.slice(16);
|
||||
if (remainingData.length > 0) {
|
||||
const decrypted = decipher.update(remainingData);
|
||||
this.push(decrypted);
|
||||
}
|
||||
}
|
||||
callback();
|
||||
return;
|
||||
}
|
||||
|
||||
if (decipher) {
|
||||
const decrypted = decipher.update(chunk);
|
||||
this.push(decrypted);
|
||||
}
|
||||
callback();
|
||||
} catch (error) {
|
||||
callback(error as Error);
|
||||
}
|
||||
},
|
||||
|
||||
flush(callback) {
|
||||
try {
|
||||
if (decipher) {
|
||||
const final = decipher.final();
|
||||
this.push(final);
|
||||
}
|
||||
callback();
|
||||
} catch (error) {
|
||||
callback(error as Error);
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
async getPresignedPutUrl(objectName: string, expires: number): Promise<string> {
|
||||
const token = crypto.randomBytes(32).toString("hex");
|
||||
const expiresAt = Date.now() + expires * 1000;
|
||||
|
||||
this.uploadTokens.set(token, { objectName, expiresAt });
|
||||
|
||||
return `/api/filesystem/upload/${token}`;
|
||||
}
|
||||
|
||||
async getPresignedGetUrl(objectName: string, expires: number, fileName?: string): Promise<string> {
|
||||
const token = crypto.randomBytes(32).toString("hex");
|
||||
const expiresAt = Date.now() + expires * 1000;
|
||||
|
||||
this.downloadTokens.set(token, { objectName, expiresAt, fileName });
|
||||
|
||||
return `/api/filesystem/download/${token}`;
|
||||
}
|
||||
|
||||
async deleteObject(objectName: string): Promise<void> {
|
||||
const filePath = this.getFilePath(objectName);
|
||||
try {
|
||||
await fs.unlink(filePath);
|
||||
} catch (error: any) {
|
||||
if (error.code !== "ENOENT") {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async uploadFile(objectName: string, buffer: Buffer): Promise<void> {
|
||||
const filePath = this.getFilePath(objectName);
|
||||
const dir = path.dirname(filePath);
|
||||
|
||||
await fs.mkdir(dir, { recursive: true });
|
||||
|
||||
const { Readable } = await import("stream");
|
||||
const readable = Readable.from(buffer);
|
||||
|
||||
await this.uploadFileFromStream(objectName, readable);
|
||||
}
|
||||
|
||||
async uploadFileFromStream(objectName: string, inputStream: NodeJS.ReadableStream): Promise<void> {
|
||||
const filePath = this.getFilePath(objectName);
|
||||
const dir = path.dirname(filePath);
|
||||
|
||||
await fs.mkdir(dir, { recursive: true });
|
||||
|
||||
const tempPath = getTempFilePath(objectName);
|
||||
const tempDir = path.dirname(tempPath);
|
||||
|
||||
await fs.mkdir(tempDir, { recursive: true });
|
||||
|
||||
const writeStream = fsSync.createWriteStream(tempPath);
|
||||
const encryptStream = this.createEncryptStream();
|
||||
|
||||
try {
|
||||
await pipeline(inputStream, encryptStream, writeStream);
|
||||
await fs.rename(tempPath, filePath);
|
||||
} catch (error) {
|
||||
await this.cleanupTempFile(tempPath);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
private encryptFileBuffer(buffer: Buffer): Buffer {
|
||||
const key = this.createEncryptionKey();
|
||||
const iv = crypto.randomBytes(16);
|
||||
const cipher = crypto.createCipheriv("aes-256-cbc", key, iv);
|
||||
|
||||
const encrypted = Buffer.concat([iv, cipher.update(buffer), cipher.final()]);
|
||||
|
||||
return encrypted;
|
||||
}
|
||||
|
||||
async downloadFile(objectName: string): Promise<Buffer> {
|
||||
const filePath = this.getFilePath(objectName);
|
||||
const encryptedBuffer = await fs.readFile(filePath);
|
||||
|
||||
if (encryptedBuffer.length > 16) {
|
||||
try {
|
||||
return this.decryptFileBuffer(encryptedBuffer);
|
||||
} catch (error: unknown) {
|
||||
if (error instanceof Error) {
|
||||
console.warn("Failed to decrypt with new method, trying legacy format", error.message);
|
||||
}
|
||||
return this.decryptFileLegacy(encryptedBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
return this.decryptFileLegacy(encryptedBuffer);
|
||||
}
|
||||
|
||||
private decryptFileBuffer(encryptedBuffer: Buffer): Buffer {
|
||||
const key = this.createEncryptionKey();
|
||||
const iv = encryptedBuffer.slice(0, 16);
|
||||
const encrypted = encryptedBuffer.slice(16);
|
||||
|
||||
const decipher = crypto.createDecipheriv("aes-256-cbc", key, iv);
|
||||
|
||||
return Buffer.concat([decipher.update(encrypted), decipher.final()]);
|
||||
}
|
||||
|
||||
private decryptFileLegacy(encryptedBuffer: Buffer): Buffer {
|
||||
const CryptoJS = require("crypto-js");
|
||||
const decrypted = CryptoJS.AES.decrypt(encryptedBuffer.toString("utf8"), this.encryptionKey);
|
||||
return Buffer.from(decrypted.toString(CryptoJS.enc.Utf8), "base64");
|
||||
}
|
||||
|
||||
async fileExists(objectName: string): Promise<boolean> {
|
||||
const filePath = this.getFilePath(objectName);
|
||||
try {
|
||||
await fs.access(filePath);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
validateUploadToken(token: string): { objectName: string } | null {
|
||||
const data = this.uploadTokens.get(token);
|
||||
if (!data || Date.now() > data.expiresAt) {
|
||||
this.uploadTokens.delete(token);
|
||||
return null;
|
||||
}
|
||||
return { objectName: data.objectName };
|
||||
}
|
||||
|
||||
validateDownloadToken(token: string): { objectName: string; fileName?: string } | null {
|
||||
const data = this.downloadTokens.get(token);
|
||||
|
||||
if (!data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const now = Date.now();
|
||||
|
||||
if (now > data.expiresAt) {
|
||||
this.downloadTokens.delete(token);
|
||||
return null;
|
||||
}
|
||||
|
||||
return { objectName: data.objectName, fileName: data.fileName };
|
||||
}
|
||||
|
||||
consumeUploadToken(token: string): void {
|
||||
this.uploadTokens.delete(token);
|
||||
}
|
||||
|
||||
consumeDownloadToken(token: string): void {
|
||||
this.downloadTokens.delete(token);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up temporary file and its parent directory if empty
|
||||
*/
|
||||
private async cleanupTempFile(tempPath: string): Promise<void> {
|
||||
try {
|
||||
await fs.unlink(tempPath);
|
||||
|
||||
const tempDir = path.dirname(tempPath);
|
||||
try {
|
||||
const files = await fs.readdir(tempDir);
|
||||
if (files.length === 0) {
|
||||
await fs.rmdir(tempDir);
|
||||
}
|
||||
} catch (dirError: any) {
|
||||
if (dirError.code !== "ENOTEMPTY" && dirError.code !== "ENOENT") {
|
||||
console.warn("Warning: Could not remove temp directory:", dirError.message);
|
||||
}
|
||||
}
|
||||
} catch (cleanupError: any) {
|
||||
if (cleanupError.code !== "ENOENT") {
|
||||
console.error("Error deleting temp file:", cleanupError);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up empty temporary directories periodically
|
||||
*/
|
||||
private async cleanupEmptyTempDirs(): Promise<void> {
|
||||
try {
|
||||
const tempUploadsDir = directoriesConfig.tempUploads;
|
||||
|
||||
try {
|
||||
await fs.access(tempUploadsDir);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
const items = await fs.readdir(tempUploadsDir);
|
||||
|
||||
for (const item of items) {
|
||||
const itemPath = path.join(tempUploadsDir, item);
|
||||
|
||||
try {
|
||||
const stat = await fs.stat(itemPath);
|
||||
|
||||
if (stat.isDirectory()) {
|
||||
const dirContents = await fs.readdir(itemPath);
|
||||
if (dirContents.length === 0) {
|
||||
await fs.rmdir(itemPath);
|
||||
console.log(`🧹 Cleaned up empty temp directory: ${itemPath}`);
|
||||
}
|
||||
} else if (stat.isFile()) {
|
||||
const oneHourAgo = Date.now() - 60 * 60 * 1000;
|
||||
if (stat.mtime.getTime() < oneHourAgo) {
|
||||
await fs.unlink(itemPath);
|
||||
console.log(`🧹 Cleaned up stale temp file: ${itemPath}`);
|
||||
}
|
||||
}
|
||||
} catch (error: any) {
|
||||
if (error.code !== "ENOENT") {
|
||||
console.warn(`Warning: Could not process temp item ${itemPath}:`, error.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error during temp directory cleanup:", error);
|
||||
}
|
||||
}
|
||||
}
|
@@ -3,6 +3,7 @@ import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
|
||||
|
||||
import { bucketName, s3Client } from "../config/storage.config";
|
||||
import { StorageProvider } from "../types/storage";
|
||||
import { getContentType } from "../utils/mime-types";
|
||||
|
||||
export class S3StorageProvider implements StorageProvider {
|
||||
constructor() {
|
||||
@@ -91,6 +92,7 @@ export class S3StorageProvider implements StorageProvider {
|
||||
Bucket: bucketName,
|
||||
Key: objectName,
|
||||
ResponseContentDisposition: this.encodeFilenameForHeader(rcdFileName),
|
||||
ResponseContentType: getContentType(rcdFileName),
|
||||
});
|
||||
|
||||
return await getSignedUrl(s3Client, command, { expiresIn: expires });
|
||||
|
@@ -1,25 +1,19 @@
|
||||
import * as fs from "fs/promises";
|
||||
import crypto from "node:crypto";
|
||||
import path from "path";
|
||||
import fastifyMultipart from "@fastify/multipart";
|
||||
import fastifyStatic from "@fastify/static";
|
||||
|
||||
import { buildApp } from "./app";
|
||||
import { directoriesConfig } from "./config/directories.config";
|
||||
import { env } from "./env";
|
||||
import { appRoutes } from "./modules/app/routes";
|
||||
import { authProvidersRoutes } from "./modules/auth-providers/routes";
|
||||
import { authRoutes } from "./modules/auth/routes";
|
||||
import { bulkDownloadRoutes } from "./modules/bulk-download/routes";
|
||||
import { fileRoutes } from "./modules/file/routes";
|
||||
import { ChunkManager } from "./modules/filesystem/chunk-manager";
|
||||
import { filesystemRoutes } from "./modules/filesystem/routes";
|
||||
import { folderRoutes } from "./modules/folder/routes";
|
||||
import { healthRoutes } from "./modules/health/routes";
|
||||
import { reverseShareRoutes } from "./modules/reverse-share/routes";
|
||||
import { shareRoutes } from "./modules/share/routes";
|
||||
import { storageRoutes } from "./modules/storage/routes";
|
||||
import { twoFactorRoutes } from "./modules/two-factor/routes";
|
||||
import { userRoutes } from "./modules/user/routes";
|
||||
import { IS_RUNNING_IN_CONTAINER } from "./utils/container-detection";
|
||||
|
||||
if (typeof globalThis.crypto === "undefined") {
|
||||
globalThis.crypto = crypto.webcrypto as any;
|
||||
@@ -29,27 +23,9 @@ if (typeof global.crypto === "undefined") {
|
||||
(global as any).crypto = crypto.webcrypto;
|
||||
}
|
||||
|
||||
async function ensureDirectories() {
|
||||
const dirsToCreate = [
|
||||
{ path: directoriesConfig.uploads, name: "uploads" },
|
||||
{ path: directoriesConfig.tempUploads, name: "temp-uploads" },
|
||||
];
|
||||
|
||||
for (const dir of dirsToCreate) {
|
||||
try {
|
||||
await fs.access(dir.path);
|
||||
} catch {
|
||||
await fs.mkdir(dir.path, { recursive: true });
|
||||
console.log(`📁 Created ${dir.name} directory: ${dir.path}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function startServer() {
|
||||
const app = await buildApp();
|
||||
|
||||
await ensureDirectories();
|
||||
|
||||
await app.register(fastifyMultipart, {
|
||||
limits: {
|
||||
fieldNameSize: 100,
|
||||
@@ -61,27 +37,16 @@ async function startServer() {
|
||||
},
|
||||
});
|
||||
|
||||
if (env.ENABLE_S3 !== "true") {
|
||||
await app.register(fastifyStatic, {
|
||||
root: directoriesConfig.uploads,
|
||||
prefix: "/uploads/",
|
||||
decorateReply: false,
|
||||
});
|
||||
}
|
||||
|
||||
app.register(authRoutes);
|
||||
app.register(authProvidersRoutes, { prefix: "/auth" });
|
||||
app.register(twoFactorRoutes, { prefix: "/auth" });
|
||||
app.register(userRoutes);
|
||||
app.register(fileRoutes);
|
||||
|
||||
if (env.ENABLE_S3 !== "true") {
|
||||
app.register(filesystemRoutes);
|
||||
}
|
||||
|
||||
app.register(folderRoutes);
|
||||
app.register(shareRoutes);
|
||||
app.register(reverseShareRoutes);
|
||||
app.register(storageRoutes);
|
||||
app.register(bulkDownloadRoutes);
|
||||
app.register(appRoutes);
|
||||
app.register(healthRoutes);
|
||||
|
||||
@@ -101,21 +66,16 @@ async function startServer() {
|
||||
}
|
||||
|
||||
console.log(`🌴 Palmr server running on port 3333 🌴`);
|
||||
console.log(`📦 Storage mode: ${env.ENABLE_S3 === "true" ? "S3" : "Local Filesystem (Encrypted)"}`);
|
||||
console.log(`🔐 Auth Providers: ${authProviders}`);
|
||||
|
||||
console.log("\n📚 API Documentation:");
|
||||
console.log(` - API Reference: http://localhost:3333/docs\n`);
|
||||
|
||||
process.on("SIGINT", async () => {
|
||||
const chunkManager = ChunkManager.getInstance();
|
||||
chunkManager.destroy();
|
||||
process.exit(0);
|
||||
});
|
||||
|
||||
process.on("SIGTERM", async () => {
|
||||
const chunkManager = ChunkManager.getInstance();
|
||||
chunkManager.destroy();
|
||||
process.exit(0);
|
||||
});
|
||||
}
|
||||
|
378
apps/server/src/utils/mime-types.ts
Normal file
378
apps/server/src/utils/mime-types.ts
Normal file
@@ -0,0 +1,378 @@
|
||||
/**
|
||||
* Utility for detecting MIME types based on file extensions
|
||||
* Fallback to application/octet-stream if extension is unknown
|
||||
*/
|
||||
|
||||
const mimeTypeMap: Record<string, string> = {
|
||||
// Images
|
||||
".jpg": "image/jpeg",
|
||||
".jpeg": "image/jpeg",
|
||||
".png": "image/png",
|
||||
".gif": "image/gif",
|
||||
".bmp": "image/bmp",
|
||||
".webp": "image/webp",
|
||||
".svg": "image/svg+xml",
|
||||
".ico": "image/x-icon",
|
||||
".tiff": "image/tiff",
|
||||
".tif": "image/tiff",
|
||||
".avif": "image/avif",
|
||||
".heic": "image/heic",
|
||||
".heif": "image/heif",
|
||||
".jxl": "image/jxl",
|
||||
".psd": "image/vnd.adobe.photoshop",
|
||||
".raw": "image/x-canon-cr2",
|
||||
".cr2": "image/x-canon-cr2",
|
||||
".nef": "image/x-nikon-nef",
|
||||
".arw": "image/x-sony-arw",
|
||||
".dng": "image/x-adobe-dng",
|
||||
".xcf": "image/x-xcf",
|
||||
".pbm": "image/x-portable-bitmap",
|
||||
".pgm": "image/x-portable-graymap",
|
||||
".ppm": "image/x-portable-pixmap",
|
||||
".pnm": "image/x-portable-anymap",
|
||||
|
||||
// Documents
|
||||
".pdf": "application/pdf",
|
||||
".doc": "application/msword",
|
||||
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||
".docm": "application/vnd.ms-word.document.macroEnabled.12",
|
||||
".dotx": "application/vnd.openxmlformats-officedocument.wordprocessingml.template",
|
||||
".dotm": "application/vnd.ms-word.template.macroEnabled.12",
|
||||
".xls": "application/vnd.ms-excel",
|
||||
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
".xlsm": "application/vnd.ms-excel.sheet.macroEnabled.12",
|
||||
".xltx": "application/vnd.openxmlformats-officedocument.spreadsheetml.template",
|
||||
".xltm": "application/vnd.ms-excel.template.macroEnabled.12",
|
||||
".xlsb": "application/vnd.ms-excel.sheet.binary.macroEnabled.12",
|
||||
".ppt": "application/vnd.ms-powerpoint",
|
||||
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
||||
".pptm": "application/vnd.ms-powerpoint.presentation.macroEnabled.12",
|
||||
".potx": "application/vnd.openxmlformats-officedocument.presentationml.template",
|
||||
".potm": "application/vnd.ms-powerpoint.template.macroEnabled.12",
|
||||
".ppsx": "application/vnd.openxmlformats-officedocument.presentationml.slideshow",
|
||||
".ppsm": "application/vnd.ms-powerpoint.slideshow.macroEnabled.12",
|
||||
".odt": "application/vnd.oasis.opendocument.text",
|
||||
".ods": "application/vnd.oasis.opendocument.spreadsheet",
|
||||
".odp": "application/vnd.oasis.opendocument.presentation",
|
||||
".odg": "application/vnd.oasis.opendocument.graphics",
|
||||
".odf": "application/vnd.oasis.opendocument.formula",
|
||||
".odb": "application/vnd.oasis.opendocument.database",
|
||||
".odc": "application/vnd.oasis.opendocument.chart",
|
||||
".odi": "application/vnd.oasis.opendocument.image",
|
||||
|
||||
// Text and Code
|
||||
".txt": "text/plain",
|
||||
".html": "text/html",
|
||||
".htm": "text/html",
|
||||
".css": "text/css",
|
||||
".js": "application/javascript",
|
||||
".mjs": "application/javascript",
|
||||
".ts": "text/typescript",
|
||||
".tsx": "text/tsx",
|
||||
".jsx": "text/jsx",
|
||||
".json": "application/json",
|
||||
".xml": "application/xml",
|
||||
".csv": "text/csv",
|
||||
".yaml": "text/yaml",
|
||||
".yml": "text/yaml",
|
||||
".toml": "text/plain",
|
||||
".ini": "text/plain",
|
||||
".cfg": "text/plain",
|
||||
".conf": "text/plain",
|
||||
".log": "text/plain",
|
||||
".md": "text/markdown",
|
||||
".markdown": "text/markdown",
|
||||
".rst": "text/x-rst",
|
||||
".tex": "text/x-tex",
|
||||
".latex": "text/x-latex",
|
||||
".rtf": "application/rtf",
|
||||
".ps": "application/postscript",
|
||||
".eps": "application/postscript",
|
||||
|
||||
// Programming Languages
|
||||
".c": "text/x-c",
|
||||
".cc": "text/x-c",
|
||||
".cpp": "text/x-c",
|
||||
".cxx": "text/x-c",
|
||||
".h": "text/x-c",
|
||||
".hpp": "text/x-c",
|
||||
".hxx": "text/x-c",
|
||||
".java": "text/x-java-source",
|
||||
".class": "application/java-vm",
|
||||
".jar": "application/java-archive",
|
||||
".war": "application/java-archive",
|
||||
".py": "text/x-python",
|
||||
".pyw": "text/x-python",
|
||||
".rb": "text/x-ruby",
|
||||
".php": "text/x-php",
|
||||
".pl": "text/x-perl",
|
||||
".pm": "text/x-perl",
|
||||
".sh": "text/x-shellscript",
|
||||
".bash": "text/x-shellscript",
|
||||
".zsh": "text/x-shellscript",
|
||||
".fish": "text/x-shellscript",
|
||||
".bat": "text/x-msdos-batch",
|
||||
".cmd": "text/x-msdos-batch",
|
||||
".ps1": "text/plain",
|
||||
".psm1": "text/plain",
|
||||
".go": "text/x-go",
|
||||
".rs": "text/x-rust",
|
||||
".swift": "text/x-swift",
|
||||
".kt": "text/x-kotlin",
|
||||
".scala": "text/x-scala",
|
||||
".clj": "text/x-clojure",
|
||||
".hs": "text/x-haskell",
|
||||
".elm": "text/x-elm",
|
||||
".dart": "text/x-dart",
|
||||
".r": "text/x-r",
|
||||
".R": "text/x-r",
|
||||
".sql": "text/x-sql",
|
||||
".vb": "text/x-vb",
|
||||
".cs": "text/x-csharp",
|
||||
".fs": "text/x-fsharp",
|
||||
".lua": "text/x-lua",
|
||||
".m": "text/x-objc",
|
||||
".mm": "text/x-objc",
|
||||
|
||||
// Audio
|
||||
".mp3": "audio/mpeg",
|
||||
".mp2": "audio/mpeg",
|
||||
".m4a": "audio/mp4",
|
||||
".m4b": "audio/mp4",
|
||||
".m4p": "audio/mp4",
|
||||
".wav": "audio/wav",
|
||||
".wave": "audio/wav",
|
||||
".aiff": "audio/aiff",
|
||||
".aif": "audio/aiff",
|
||||
".aifc": "audio/aiff",
|
||||
".flac": "audio/flac",
|
||||
".ogg": "audio/ogg",
|
||||
".oga": "audio/ogg",
|
||||
".opus": "audio/opus",
|
||||
".aac": "audio/aac",
|
||||
".wma": "audio/x-ms-wma",
|
||||
".ac3": "audio/ac3",
|
||||
".amr": "audio/amr",
|
||||
".au": "audio/basic",
|
||||
".snd": "audio/basic",
|
||||
".mid": "audio/midi",
|
||||
".midi": "audio/midi",
|
||||
".kar": "audio/midi",
|
||||
".ra": "audio/x-realaudio",
|
||||
".ram": "audio/x-realaudio",
|
||||
".3gp": "audio/3gpp",
|
||||
".3g2": "audio/3gpp2",
|
||||
".spx": "audio/speex",
|
||||
".wv": "audio/x-wavpack",
|
||||
".ape": "audio/x-ape",
|
||||
".mpc": "audio/x-musepack",
|
||||
|
||||
// Video
|
||||
".mp4": "video/mp4",
|
||||
".m4v": "video/mp4",
|
||||
".avi": "video/x-msvideo",
|
||||
".mov": "video/quicktime",
|
||||
".qt": "video/quicktime",
|
||||
".wmv": "video/x-ms-wmv",
|
||||
".asf": "video/x-ms-asf",
|
||||
".flv": "video/x-flv",
|
||||
".f4v": "video/x-f4v",
|
||||
".webm": "video/webm",
|
||||
".mkv": "video/x-matroska",
|
||||
".mka": "audio/x-matroska",
|
||||
".mks": "video/x-matroska",
|
||||
".ogv": "video/ogg",
|
||||
".ogm": "video/ogg",
|
||||
".mxf": "application/mxf",
|
||||
".m2ts": "video/mp2t",
|
||||
".mts": "video/mp2t",
|
||||
".vob": "video/dvd",
|
||||
".mpg": "video/mpeg",
|
||||
".mpeg": "video/mpeg",
|
||||
".m1v": "video/mpeg",
|
||||
".m2v": "video/mpeg",
|
||||
".rm": "application/vnd.rn-realmedia",
|
||||
".rmvb": "application/vnd.rn-realmedia-vbr",
|
||||
".divx": "video/divx",
|
||||
".xvid": "video/x-xvid",
|
||||
|
||||
// Archives and Compression
|
||||
".zip": "application/zip",
|
||||
".rar": "application/vnd.rar",
|
||||
".7z": "application/x-7z-compressed",
|
||||
".tar": "application/x-tar",
|
||||
".tar.gz": "application/gzip",
|
||||
".tgz": "application/gzip",
|
||||
".tar.bz2": "application/x-bzip2",
|
||||
".tbz2": "application/x-bzip2",
|
||||
".tar.xz": "application/x-xz",
|
||||
".txz": "application/x-xz",
|
||||
".tar.lz": "application/x-lzip",
|
||||
".tar.Z": "application/x-compress",
|
||||
".Z": "application/x-compress",
|
||||
".gz": "application/gzip",
|
||||
".bz2": "application/x-bzip2",
|
||||
".xz": "application/x-xz",
|
||||
".lz": "application/x-lzip",
|
||||
".lzma": "application/x-lzma",
|
||||
".lzo": "application/x-lzop",
|
||||
".arj": "application/x-arj",
|
||||
".ace": "application/x-ace-compressed",
|
||||
".cab": "application/vnd.ms-cab-compressed",
|
||||
".iso": "application/x-iso9660-image",
|
||||
".dmg": "application/x-apple-diskimage",
|
||||
".img": "application/x-img",
|
||||
".bin": "application/octet-stream",
|
||||
".cue": "application/x-cue",
|
||||
".nrg": "application/x-nrg",
|
||||
".mdf": "application/x-mdf",
|
||||
".toast": "application/x-toast",
|
||||
|
||||
// Executables and System
|
||||
".exe": "application/vnd.microsoft.portable-executable",
|
||||
".dll": "application/vnd.microsoft.portable-executable",
|
||||
".msi": "application/x-msdownload",
|
||||
".msp": "application/x-msdownload",
|
||||
".deb": "application/vnd.debian.binary-package",
|
||||
".rpm": "application/x-rpm",
|
||||
".pkg": "application/x-newton-compatible-pkg",
|
||||
".apk": "application/vnd.android.package-archive",
|
||||
".ipa": "application/octet-stream",
|
||||
".app": "application/octet-stream",
|
||||
".snap": "application/x-snap",
|
||||
".flatpak": "application/vnd.flatpak",
|
||||
".appimage": "application/x-appimage",
|
||||
|
||||
// Adobe and Design
|
||||
".ai": "application/illustrator",
|
||||
".indd": "application/x-indesign",
|
||||
".idml": "application/vnd.adobe.indesign-idml-package",
|
||||
".sketch": "application/x-sketch",
|
||||
".fig": "application/x-figma",
|
||||
".xd": "application/vnd.adobe.xd",
|
||||
|
||||
// Fonts
|
||||
".ttf": "font/ttf",
|
||||
".otf": "font/otf",
|
||||
".woff": "font/woff",
|
||||
".woff2": "font/woff2",
|
||||
".eot": "application/vnd.ms-fontobject",
|
||||
".fon": "application/x-font-bdf",
|
||||
".bdf": "application/x-font-bdf",
|
||||
".pcf": "application/x-font-pcf",
|
||||
".pfb": "application/x-font-type1",
|
||||
".pfm": "application/x-font-type1",
|
||||
".afm": "application/x-font-afm",
|
||||
|
||||
// E-books
|
||||
".epub": "application/epub+zip",
|
||||
".mobi": "application/x-mobipocket-ebook",
|
||||
".azw": "application/vnd.amazon.ebook",
|
||||
".azw3": "application/vnd.amazon.ebook",
|
||||
".fb2": "application/x-fictionbook+xml",
|
||||
".lit": "application/x-ms-reader",
|
||||
".pdb": "application/vnd.palm",
|
||||
".prc": "application/vnd.palm",
|
||||
".tcr": "application/x-psion3-s",
|
||||
|
||||
// CAD and 3D
|
||||
".dwg": "image/vnd.dwg",
|
||||
".dxf": "image/vnd.dxf",
|
||||
".step": "application/step",
|
||||
".stp": "application/step",
|
||||
".iges": "application/iges",
|
||||
".igs": "application/iges",
|
||||
".stl": "application/sla",
|
||||
".obj": "application/x-tgif",
|
||||
".3ds": "application/x-3ds",
|
||||
".dae": "model/vnd.collada+xml",
|
||||
".ply": "application/ply",
|
||||
".x3d": "model/x3d+xml",
|
||||
|
||||
// Database
|
||||
".db": "application/x-sqlite3",
|
||||
".sqlite": "application/x-sqlite3",
|
||||
".sqlite3": "application/x-sqlite3",
|
||||
".mdb": "application/x-msaccess",
|
||||
".accdb": "application/x-msaccess",
|
||||
|
||||
// Virtual Machine and Disk Images
|
||||
".vmdk": "application/x-vmdk",
|
||||
".vdi": "application/x-virtualbox-vdi",
|
||||
".vhd": "application/x-virtualbox-vhd",
|
||||
".vhdx": "application/x-virtualbox-vhdx",
|
||||
".ova": "application/x-virtualbox-ova",
|
||||
".ovf": "application/x-virtualbox-ovf",
|
||||
".qcow2": "application/x-qemu-disk",
|
||||
|
||||
// Scientific and Math
|
||||
".mat": "application/x-matlab-data",
|
||||
".nc": "application/x-netcdf",
|
||||
".cdf": "application/x-netcdf",
|
||||
".hdf": "application/x-hdf",
|
||||
".h5": "application/x-hdf5",
|
||||
|
||||
// Misc Application Formats
|
||||
".torrent": "application/x-bittorrent",
|
||||
".rss": "application/rss+xml",
|
||||
".atom": "application/atom+xml",
|
||||
".gpx": "application/gpx+xml",
|
||||
".kml": "application/vnd.google-earth.kml+xml",
|
||||
".kmz": "application/vnd.google-earth.kmz",
|
||||
".ics": "text/calendar",
|
||||
".vcs": "text/x-vcalendar",
|
||||
".vcf": "text/x-vcard",
|
||||
".p7s": "application/pkcs7-signature",
|
||||
".p7m": "application/pkcs7-mime",
|
||||
".p12": "application/x-pkcs12",
|
||||
".pfx": "application/x-pkcs12",
|
||||
".cer": "application/x-x509-ca-cert",
|
||||
".crt": "application/x-x509-ca-cert",
|
||||
".pem": "application/x-pem-file",
|
||||
".key": "application/x-pem-file",
|
||||
};
|
||||
|
||||
/**
|
||||
* Get MIME type from file extension
|
||||
* @param filename - The filename or extension (with or without leading dot)
|
||||
* @returns MIME type string, defaults to 'application/octet-stream' if unknown
|
||||
*/
|
||||
export function getMimeType(filename: string): string {
|
||||
if (!filename) {
|
||||
return "application/octet-stream";
|
||||
}
|
||||
|
||||
let extension: string;
|
||||
|
||||
if (filename.startsWith(".")) {
|
||||
extension = filename.toLowerCase();
|
||||
} else if (!filename.includes(".")) {
|
||||
extension = "." + filename.toLowerCase();
|
||||
} else {
|
||||
const lastDotIndex = filename.lastIndexOf(".");
|
||||
if (lastDotIndex === -1) {
|
||||
return "application/octet-stream";
|
||||
}
|
||||
extension = filename.substring(lastDotIndex).toLowerCase();
|
||||
}
|
||||
|
||||
return mimeTypeMap[extension] || "application/octet-stream";
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a MIME type represents an image
|
||||
* @param mimeType - The MIME type to check
|
||||
* @returns true if the MIME type is an image type
|
||||
*/
|
||||
export function isImageMimeType(mimeType: string): boolean {
|
||||
return mimeType.startsWith("image/");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get appropriate Content-Type header value for a file
|
||||
* @param filename - The filename to detect type for
|
||||
* @returns Content-Type header value
|
||||
*/
|
||||
export function getContentType(filename: string): string {
|
||||
return getMimeType(filename);
|
||||
}
|
@@ -1 +1,2 @@
|
||||
API_BASE_URL=http:localhost:3333
|
||||
API_BASE_URL=http:localhost:3333
|
||||
NEXT_PUBLIC_DEFAULT_LANGUAGE=en-US
|
@@ -1,5 +0,0 @@
|
||||
|
||||
|
||||
> palmr-web@3.1-beta lint /Users/daniel/clones/Palmr/apps/web
|
||||
> eslint "src/**/*.+(ts|tsx)"
|
||||
|
@@ -144,7 +144,13 @@
|
||||
"update": "تحديث",
|
||||
"click": "انقر على",
|
||||
"creating": "جاري الإنشاء...",
|
||||
"loadingSimple": "جاري التحميل..."
|
||||
"loadingSimple": "جاري التحميل...",
|
||||
"create": "إنشاء",
|
||||
"deleting": "جاري الحذف...",
|
||||
"move": "نقل",
|
||||
"rename": "إعادة تسمية",
|
||||
"search": "بحث",
|
||||
"share": "مشاركة"
|
||||
},
|
||||
"createShare": {
|
||||
"title": "إنشاء مشاركة",
|
||||
@@ -159,7 +165,54 @@
|
||||
"passwordLabel": "كلمة المرور",
|
||||
"create": "إنشاء مشاركة",
|
||||
"success": "تم إنشاء المشاركة بنجاح",
|
||||
"error": "فشل في إنشاء المشاركة"
|
||||
"error": "فشل في إنشاء المشاركة",
|
||||
"namePlaceholder": "أدخل اسمًا لمشاركتك",
|
||||
"nextSelectFiles": "التالي: اختيار الملفات",
|
||||
"searchLabel": "بحث",
|
||||
"tabs": {
|
||||
"shareDetails": "تفاصيل المشاركة",
|
||||
"selectFiles": "اختيار الملفات"
|
||||
}
|
||||
},
|
||||
"customization": {
|
||||
"breadcrumb": "التخصيص",
|
||||
"colors": {
|
||||
"title": "ألوان السمة",
|
||||
"description": "اختر لون السمة الرئيسي المفضل لديك",
|
||||
"presets": "الألوان المتاحة",
|
||||
"presetsDescription": "اختر من بين السمات اللونية المتاحة",
|
||||
"reset": "إعادة التعيين إلى الافتراضي"
|
||||
},
|
||||
"fonts": {
|
||||
"title": "الخطوط",
|
||||
"description": "اختر عائلة الخط المفضلة لديك",
|
||||
"available": "الخطوط المتاحة",
|
||||
"availableDescription": "اختر من بين عائلات الخطوط المتاحة",
|
||||
"reset": "إعادة التعيين إلى الافتراضي"
|
||||
},
|
||||
"radius": {
|
||||
"title": "حواف الإطار",
|
||||
"description": "تخصيص استدارة عناصر الواجهة",
|
||||
"available": "خيارات الاستدارة",
|
||||
"availableDescription": "اختر كيف يجب أن تظهر الزوايا المستديرة",
|
||||
"reset": "إعادة التعيين إلى الافتراضي"
|
||||
},
|
||||
"background": {
|
||||
"title": "ألوان الخلفية",
|
||||
"description": "تخصيص ألوان الخلفية للوضعين الفاتح والداكن",
|
||||
"lightMode": "الوضع الفاتح",
|
||||
"darkMode": "الوضع الداكن",
|
||||
"availableDescription": "اختر ألوان الخلفية لكل من السمات الفاتحة والداكنة",
|
||||
"reset": "إعادة التعيين إلى الافتراضي"
|
||||
},
|
||||
"theme": {
|
||||
"title": "وضع السمة",
|
||||
"description": "اختر بين السمة الفاتحة أو الداكنة أو سمة النظام",
|
||||
"selectTheme": "تفضيلات السمة",
|
||||
"availableDescription": "حدد وضع السمة المفضل لديك",
|
||||
"reset": "إعادة التعيين إلى النظام"
|
||||
},
|
||||
"pageTitle": "التخصيص"
|
||||
},
|
||||
"dashboard": {
|
||||
"loadError": "فشل في تحميل بيانات لوحة التحكم",
|
||||
@@ -173,7 +226,42 @@
|
||||
},
|
||||
"deleteConfirmation": {
|
||||
"filesToDelete": "الملفات المراد حذفها",
|
||||
"sharesToDelete": "المشاركات التي سيتم حذفها"
|
||||
"sharesToDelete": "المشاركات التي سيتم حذفها",
|
||||
"foldersToDelete": "المجلدات المراد حذفها",
|
||||
"itemsToDelete": "العناصر المراد حذفها"
|
||||
},
|
||||
"downloadQueue": {
|
||||
"downloadQueued": "تم إضافة التنزيل إلى قائمة الانتظار: {fileName}",
|
||||
"queuedDescription": "سيبدأ التنزيل تلقائياً عندما يتوفر موقع",
|
||||
"queuePosition": "التنزيل في قائمة الانتظار في الموقع {position}: {fileName}",
|
||||
"estimatedWait": "وقت الانتظار المقدر: {time}",
|
||||
"queueFull": "قائمة انتظار التنزيل ممتلئة",
|
||||
"queueFullDescription": "يرجى المحاولة مرة أخرى بعد بضع دقائق عندما تتوفر مساحة في قائمة الانتظار",
|
||||
"cancelSuccess": "تم إلغاء التنزيل بنجاح",
|
||||
"cancelError": "فشل إلغاء التنزيل: {error}",
|
||||
"status": {
|
||||
"pending": "جارٍ التحضير...",
|
||||
"queued": "في قائمة الانتظار",
|
||||
"downloading": "جارٍ التنزيل",
|
||||
"completed": "مكتمل",
|
||||
"failed": "فشل"
|
||||
},
|
||||
"waitTime": {
|
||||
"seconds": "{seconds} ثانية",
|
||||
"minutes": "{minutes} دقيقة",
|
||||
"hoursMinutes": "{hours} ساعة {minutes} دقيقة"
|
||||
},
|
||||
"indicator": {
|
||||
"title": "التنزيلات",
|
||||
"downloads": "قائمة التنزيل",
|
||||
"active": "نشط",
|
||||
"queued": "في قائمة الانتظار",
|
||||
"position": "الموقع {position}",
|
||||
"estimatedWait": "الانتظار: {time}",
|
||||
"unknownFile": "ملف غير معروف",
|
||||
"noDownloads": "لا توجد تنزيلات قيد التقدم",
|
||||
"refresh": "تحديث قائمة الانتظار"
|
||||
}
|
||||
},
|
||||
"emptyState": {
|
||||
"noFiles": "لم يتم رفع أي ملفات بعد",
|
||||
@@ -202,7 +290,8 @@
|
||||
"descriptionPlaceholder": "أدخل وصف الملف",
|
||||
"deleteFile": "حذف الملف",
|
||||
"deleteConfirmation": "هل أنت متأكد أنك تريد حذف ؟",
|
||||
"deleteWarning": "هذا الإجراء لا يمكن التراجع عنه."
|
||||
"deleteWarning": "هذا الإجراء لا يمكن التراجع عنه.",
|
||||
"addDescriptionPlaceholder": "إضافة وصف..."
|
||||
},
|
||||
"fileManager": {
|
||||
"downloadError": "فشل في تنزيل الملف",
|
||||
@@ -247,7 +336,8 @@
|
||||
"previewFile": "معاينة الملف",
|
||||
"addToShare": "إضافة إلى المشاركة",
|
||||
"removeFromShare": "إزالة من المشاركة",
|
||||
"saveChanges": "حفظ التغييرات"
|
||||
"saveChanges": "حفظ التغييرات",
|
||||
"editFolder": "تحرير المجلد"
|
||||
},
|
||||
"files": {
|
||||
"title": "جميع الملفات",
|
||||
@@ -270,7 +360,20 @@
|
||||
"table": "جدول",
|
||||
"grid": "شبكة"
|
||||
},
|
||||
"totalFiles": "{count, plural, =0 {لا توجد ملفات} =1 {ملف واحد} other {# ملفات}}"
|
||||
"totalFiles": "{count, plural, =0 {لا توجد ملفات} =1 {ملف واحد} other {# ملفات}}",
|
||||
"bulkDeleteConfirmation": "هل أنت متأكد من رغبتك في حذف {count, plural, =1 {ملف واحد} other {# ملفات}}؟ لا يمكن التراجع عن هذا الإجراء.",
|
||||
"bulkDeleteTitle": "حذف الملفات المحددة",
|
||||
"actions": {
|
||||
"open": "فتح",
|
||||
"rename": "إعادة تسمية",
|
||||
"delete": "حذف"
|
||||
},
|
||||
"empty": {
|
||||
"title": "لا توجد ملفات أو مجلدات بعد",
|
||||
"description": "ارفع ملفك الأول أو أنشئ مجلدًا للبدء"
|
||||
},
|
||||
"files": "ملفات",
|
||||
"folders": "مجلدات"
|
||||
},
|
||||
"filesTable": {
|
||||
"ariaLabel": "جدول الملفات",
|
||||
@@ -300,6 +403,33 @@
|
||||
"delete": "حذف المحدد"
|
||||
}
|
||||
},
|
||||
"folderActions": {
|
||||
"editFolder": "تحرير المجلد",
|
||||
"folderName": "اسم المجلد",
|
||||
"folderNamePlaceholder": "أدخل اسم المجلد",
|
||||
"folderDescription": "الوصف",
|
||||
"folderDescriptionPlaceholder": "أدخل وصف المجلد (اختياري)",
|
||||
"createFolder": "إنشاء مجلد جديد",
|
||||
"renameFolder": "إعادة تسمية المجلد",
|
||||
"moveFolder": "نقل المجلد",
|
||||
"shareFolder": "مشاركة المجلد",
|
||||
"deleteFolder": "حذف المجلد",
|
||||
"moveTo": "نقل إلى",
|
||||
"selectDestination": "اختر مجلد الوجهة",
|
||||
"rootFolder": "الجذر",
|
||||
"folderCreated": "تم إنشاء المجلد بنجاح",
|
||||
"folderRenamed": "تم إعادة تسمية المجلد بنجاح",
|
||||
"folderMoved": "تم نقل المجلد بنجاح",
|
||||
"folderDeleted": "تم حذف المجلد بنجاح",
|
||||
"folderShared": "تم مشاركة المجلد بنجاح",
|
||||
"createFolderError": "خطأ في إنشاء المجلد",
|
||||
"renameFolderError": "خطأ في إعادة تسمية المجلد",
|
||||
"moveFolderError": "خطأ في نقل المجلد",
|
||||
"deleteFolderError": "خطأ في حذف المجلد",
|
||||
"shareFolderError": "خطأ في مشاركة المجلد",
|
||||
"deleteConfirmation": "هل أنت متأكد من أنك تريد حذف هذا المجلد؟",
|
||||
"deleteWarning": "لا يمكن التراجع عن هذا الإجراء."
|
||||
},
|
||||
"footer": {
|
||||
"poweredBy": "مدعوم من",
|
||||
"kyanHomepage": "الصفحة الرئيسية لـ Kyantech"
|
||||
@@ -313,7 +443,8 @@
|
||||
"title": "نسيت كلمة المرور",
|
||||
"description": "أدخل بريدك الإلكتروني وسنرسل لك تعليمات إعادة تعيين كلمة المرور.",
|
||||
"resetInstructions": "تم إرسال تعليمات إعادة التعيين إلى بريدك الإلكتروني",
|
||||
"pageTitle": "نسيت كلمة المرور"
|
||||
"pageTitle": "نسيت كلمة المرور",
|
||||
"passwordAuthDisabled": "تم تعطيل المصادقة بكلمة المرور. يرجى الاتصال بالمسؤول أو استخدام مزود مصادقة خارجي."
|
||||
},
|
||||
"generateShareLink": {
|
||||
"generateTitle": "إنشاء رابط المشاركة",
|
||||
@@ -327,7 +458,12 @@
|
||||
"copyButton": "نسخ الرابط",
|
||||
"success": "تم إنشاء الرابط بنجاح",
|
||||
"error": "فشل في إنشاء الرابط",
|
||||
"copied": "تم نسخ الرابط إلى الحافظة"
|
||||
"copied": "تم نسخ الرابط إلى الحافظة",
|
||||
"readyDescription": "رابط المشاركة الخاص بك جاهز. يمكنك مسح رمز QR مباشرة، أو تنزيله للاستخدام لاحقًا، أو نسخ الرابط أدناه.",
|
||||
"tabs": {
|
||||
"link": "الرابط",
|
||||
"qrcode": "رمز QR"
|
||||
}
|
||||
},
|
||||
"home": {
|
||||
"description": "البديل مفتوح المصدر لـ WeTransfer. شارك ملفاتك بأمان، دون تتبع أو قيود.",
|
||||
@@ -355,6 +491,12 @@
|
||||
"stats": "{iconCount} أيقونة من {libraryCount} مكتبة",
|
||||
"categoryBadge": "{category} ({count} أيقونات)"
|
||||
},
|
||||
"imageEdit": {
|
||||
"title": "تعديل الصورة",
|
||||
"rotate": "تدوير",
|
||||
"zoom": "تكبير/تصغير",
|
||||
"cropInstructions": "اسحب لإعادة تحديد الموضع، غير حجم الزوايا لضبط منطقة القص"
|
||||
},
|
||||
"login": {
|
||||
"welcome": "مرحبا بك",
|
||||
"signInToContinue": "قم بتسجيل الدخول للمتابعة",
|
||||
@@ -389,13 +531,21 @@
|
||||
"removeFailed": "فشل في حذف الشعار"
|
||||
}
|
||||
},
|
||||
"moveItems": {
|
||||
"itemsToMove": "العناصر المراد نقلها:",
|
||||
"movingTo": "النقل إلى:",
|
||||
"title": "نقل {count, plural, =1 {عنصر} other {عناصر}}",
|
||||
"description": "نقل {count, plural, =1 {عنصر} other {عناصر}} إلى موقع جديد",
|
||||
"success": "تم نقل {count} {count, plural, =1 {عنصر} other {عناصر}} بنجاح"
|
||||
},
|
||||
"navbar": {
|
||||
"logoAlt": "شعار التطبيق",
|
||||
"profileMenu": "قائمة الملف الشخصي",
|
||||
"profile": "الملف الشخصي",
|
||||
"settings": "الإعدادات",
|
||||
"usersManagement": "إدارة المستخدمين",
|
||||
"logout": "تسجيل الخروج"
|
||||
"logout": "تسجيل الخروج",
|
||||
"customization": "التخصيص"
|
||||
},
|
||||
"navigation": {
|
||||
"dashboard": "لوحة التحكم"
|
||||
@@ -442,6 +592,11 @@
|
||||
},
|
||||
"pageTitle": "الملف الشخصي"
|
||||
},
|
||||
"qrCodeModal": {
|
||||
"title": "مشاركة رمز QR",
|
||||
"description": "امسح رمز QR هذا للوصول إلى الرابط.",
|
||||
"download": "تحميل رمز QR"
|
||||
},
|
||||
"quickAccess": {
|
||||
"files": {
|
||||
"title": "ملفاتي",
|
||||
@@ -613,7 +768,8 @@
|
||||
"createLink": "إنشاء رابط",
|
||||
"delete": "حذف",
|
||||
"copyLinkTitle": "نسخ الرابط",
|
||||
"createLinkCTA": "إنشاء رابط استلام"
|
||||
"createLinkCTA": "إنشاء رابط استلام",
|
||||
"viewQrCode": "عرض رمز QR"
|
||||
},
|
||||
"status": {
|
||||
"active": "نشط",
|
||||
@@ -629,7 +785,8 @@
|
||||
"viewDetails": "عرض التفاصيل",
|
||||
"edit": "تحرير",
|
||||
"delete": "حذف",
|
||||
"viewFiles": "الملفات المستلمة"
|
||||
"viewFiles": "الملفات المستلمة",
|
||||
"viewQrCode": "عرض رمز QR"
|
||||
},
|
||||
"empty": {
|
||||
"title": "لم يتم إنشاء روابط استلام",
|
||||
@@ -775,7 +932,8 @@
|
||||
"timeout": "انتهت مهلة عملية النسخ. يرجى المحاولة مرة أخرى باستخدام ملف أصغر أو التحقق من اتصالك.",
|
||||
"failed": "فشلت عملية النسخ. يرجى المحاولة مرة أخرى.",
|
||||
"aborted": "تم إلغاء عملية النسخ بسبب انتهاء المهلة."
|
||||
}
|
||||
},
|
||||
"invalidDate": "تاريخ غير صحيح"
|
||||
}
|
||||
},
|
||||
"form": {
|
||||
@@ -992,7 +1150,10 @@
|
||||
},
|
||||
"searchBar": {
|
||||
"placeholder": "ابحث عن الملفات...",
|
||||
"results": "تم العثور على {filtered} من {total} ملف"
|
||||
"results": "تم العثور على {filtered} من {total} ملف",
|
||||
"placeholderFolders": "البحث في المجلدات...",
|
||||
"noResults": "لم يتم العثور على نتائج لـ \"{query}\"",
|
||||
"placeholderFiles": "البحث في الملفات..."
|
||||
},
|
||||
"settings": {
|
||||
"groups": {
|
||||
@@ -1117,6 +1278,10 @@
|
||||
"smtpTrustSelfSigned": {
|
||||
"title": "الوثوق بالشهادات الموقعة ذاتياً",
|
||||
"description": "قم بتمكين هذا للوثوق بشهادات SSL/TLS الموقعة ذاتياً (مفيد لبيئات التطوير)"
|
||||
},
|
||||
"passwordAuthEnabled": {
|
||||
"title": "المصادقة بالكلمة السرية",
|
||||
"description": "تمكين أو تعطيل المصادقة بالكلمة السرية"
|
||||
}
|
||||
},
|
||||
"buttons": {
|
||||
@@ -1126,7 +1291,8 @@
|
||||
},
|
||||
"errors": {
|
||||
"loadFailed": "فشل في تحميل الإعدادات",
|
||||
"updateFailed": "فشل في تحديث الإعدادات"
|
||||
"updateFailed": "فشل في تحديث الإعدادات",
|
||||
"passwordAuthRequiresProvider": "لا يمكن تعطيل المصادقة بالكلمة السرية دون وجود على الأقل موفرين مصادقة مفعلين"
|
||||
},
|
||||
"messages": {
|
||||
"noChanges": "لا توجد تغييرات للحفظ",
|
||||
@@ -1200,7 +1366,18 @@
|
||||
"editSuccess": "تم تحديث المشاركة بنجاح",
|
||||
"editError": "فشل في تحديث المشاركة",
|
||||
"bulkDeleteConfirmation": "هل أنت متأكد من أنك تريد حذف {count, plural, =1 {مشاركة واحدة} other {# مشاركات}} محددة؟ لا يمكن التراجع عن هذا الإجراء.",
|
||||
"bulkDeleteTitle": "حذف المشاركات المحددة"
|
||||
"bulkDeleteTitle": "حذف المشاركات المحددة",
|
||||
"addDescriptionPlaceholder": "إضافة وصف...",
|
||||
"aliasLabel": "اسم مستعار للرابط",
|
||||
"aliasPlaceholder": "أدخل اسمًا مستعارًا مخصصًا",
|
||||
"copyLink": "نسخ الرابط",
|
||||
"fileTitle": "مشاركة ملف",
|
||||
"folderTitle": "مشاركة مجلد",
|
||||
"generateLink": "إنشاء رابط",
|
||||
"linkDescriptionFile": "إنشاء رابط مخصص لمشاركة الملف",
|
||||
"linkDescriptionFolder": "إنشاء رابط مخصص لمشاركة المجلد",
|
||||
"linkReady": "رابط المشاركة جاهز:",
|
||||
"linkTitle": "إنشاء رابط"
|
||||
},
|
||||
"shareDetails": {
|
||||
"title": "تفاصيل المشاركة",
|
||||
@@ -1232,7 +1409,10 @@
|
||||
"invalidDate": "تاريخ غير صحيح",
|
||||
"loadError": "فشل في تحميل تفاصيل المشاركة",
|
||||
"editSecurity": "تحرير الأمان",
|
||||
"editExpiration": "تحرير انتهاء الصلاحية"
|
||||
"editExpiration": "تحرير انتهاء الصلاحية",
|
||||
"clickToEnlargeQrCode": "انقر لتكبير رمز QR",
|
||||
"downloadQrCode": "تحميل رمز QR",
|
||||
"qrCode": "رمز QR"
|
||||
},
|
||||
"shareExpiration": {
|
||||
"neverExpires": "لا تنتهي صلاحيته أبداً",
|
||||
@@ -1324,7 +1504,8 @@
|
||||
"files": "ملفات",
|
||||
"totalSize": "الحجم الإجمالي",
|
||||
"creating": "جاري الإنشاء...",
|
||||
"create": "إنشاء مشاركة"
|
||||
"create": "إنشاء مشاركة",
|
||||
"itemsToShare": "العناصر للمشاركة ({count} {count, plural, =1 {عنصر} other {عناصر}})"
|
||||
},
|
||||
"shareSecurity": {
|
||||
"subtitle": "تكوين حماية كلمة المرور وخيارات الأمان لهذه المشاركة",
|
||||
@@ -1419,7 +1600,8 @@
|
||||
"copyLink": "نسخ الرابط",
|
||||
"notifyRecipients": "إشعار المستقبلين",
|
||||
"delete": "حذف",
|
||||
"downloadShareFiles": "قم بتنزيل جميع الملفات"
|
||||
"downloadShareFiles": "قم بتنزيل جميع الملفات",
|
||||
"viewQrCode": "عرض رمز QR"
|
||||
},
|
||||
"bulkActions": {
|
||||
"delete": "حذف",
|
||||
@@ -1428,7 +1610,8 @@
|
||||
"download": "تنزيل محدد"
|
||||
},
|
||||
"selectAll": "تحديد الكل",
|
||||
"selectShare": "تحديد المشاركة {shareName}"
|
||||
"selectShare": "تحديد المشاركة {shareName}",
|
||||
"folderCount": "مجلدات"
|
||||
},
|
||||
"storageUsage": {
|
||||
"title": "استخدام التخزين",
|
||||
@@ -1636,7 +1819,8 @@
|
||||
"title": "إفلات الملفات للرفع",
|
||||
"description": "حرر للرفع ملفاتك"
|
||||
},
|
||||
"pasteSuccess": "{count, plural, =1 {تم لصق الصورة ورفعها بنجاح} other {تم لصق # صور ورفعها بنجاح}}"
|
||||
"pasteSuccess": "{count, plural, =1 {تم لصق الصورة ورفعها بنجاح} other {تم لصق # صور ورفعها بنجاح}}",
|
||||
"filesQueued": "{count, plural, one {# ملف في الصف} other {# ملفات في الصف}}"
|
||||
},
|
||||
"users": {
|
||||
"modes": {
|
||||
@@ -1721,11 +1905,5 @@
|
||||
"passwordRequired": "كلمة المرور مطلوبة",
|
||||
"nameRequired": "الاسم مطلوب",
|
||||
"required": "هذا الحقل مطلوب"
|
||||
},
|
||||
"imageEdit": {
|
||||
"title": "تعديل الصورة",
|
||||
"rotate": "تدوير",
|
||||
"zoom": "تكبير/تصغير",
|
||||
"cropInstructions": "اسحب لإعادة تحديد الموضع، غير حجم الزوايا لضبط منطقة القص"
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user