This is a Node.js-based cloud storage platform, which uses Express.js for the backend, Next.js for the frontend, and MongoDB for storing user data.
Before working with this project:
- Install Node.js version 16 or higher.
- Create a MongoDB cluster at MongoDB.
- Clone the project repository and navigate to its root directory:
git clone https://github.com/sweet-peach/vault.git
cd ./vault
- Navigate to the backend folder:
cd ./backend
- Install dependencies:
npm i
-
Create a file named
.env
and copy the contents ofenv.template
into it. -
Configure the following fields in the
.env
file:
PORT
: Specify the port for the backend server.MONGODB_URL
: URL to your MongoDB cluster.JWT_SECRET
: Generated a JWT secret key of 64 length or above. You can use a tool like jwtsecret.com
- Start the development backend server:
npm run dev
- Navigate to the frontend folder:
cd ./../frontend
- Install dependencies:
npm i
-
Create a file named
.env
and copy the contents ofenv.template
into it. -
Configure the following fields in the
.env
file:
NEXT_PUBLIC_BACKEND_BASE_URL
: URL to your backend server. Modify only if the backend server's port is different from the default.
- Start the development frontend server:
npm run dev
Backend server almost all endpoints start with /api/
besides from /avatar/
. Use a reverse proxy (e.g., Nginx) to deploy the server on a domain. Ensure your domain is correctly configured to point to your server before deployment.
- Clone the project repository and navigate to its root directory
git clone https://github.com/sweet-peach/vault.git
cd ./vault
- Navigate to the backend folder:
cd ./backend
- Install dependencies:
npm i
-
Create a file named .env and copy the contents of env.template into it.
-
Configure the following fields in the
.env
file:
PORT
: Specify the port for the backend server.MONGODB_URL
: URL to your MongoDB cluster.JWT_SECRET
: Generated a JWT secret key of 64 length or above. You can use a tool like jwtsecret.com
- Start the production backend server:
npm run start
- Navigate to the frontend folder:
cd ..
cd ./frontend
- Install dependencies:
npm i
-
Create a file named
.env
and copy the contents ofenv.template
into it. -
Configure the following fields in the
.env
file:
NEXT_PUBLIC_BACKEND_BASE_URL
: Add your domain name here.
Example .env file:
NEXT_PUBLIC_BACKEND_BASE_URL=https://example.com
- Build the frontend:
npm run build
- Start the frontend server:
npm run start
- Configure a reverse proxy to redirect requests:
- Redirect all requests with the
/api/
endpoint to your backend server. - Redirect all requests with the
/avatar/
endpoint to your backend server. - Redirect other requests to your frontend server.
The backend includes a configuration file located at /core/config.js
, which allows you to customize the following settings:
avatar_maximum_size
: Specifies the maximum allowable size for a user's avatar upload, measured in bytes.files_directory
: Defines the directory path where all user files are stored.avatars_directory
: Sets the directory path for storing user avatars.jwt_expiration_in_ms
: Determines the expiration time for JSON Web Tokens (JWTs), specified in milliseconds.