Skip to content

sweet-peach/vault

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About this project

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.

Prerequisites

Before working with this project:

  • Install Node.js version 16 or higher.
  • Create a MongoDB cluster at MongoDB.

Development

  1. Clone the project repository and navigate to its root directory:
git clone https://github.com/sweet-peach/vault.git
cd ./vault
  1. Navigate to the backend folder:
cd ./backend
  1. Install dependencies:
npm i
  1. Create a file named .env and copy the contents of env.template into it.

  2. 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
  1. Start the development backend server:
npm run dev
  1. Navigate to the frontend folder:
cd ./../frontend
  1. Install dependencies:
npm i
  1. Create a file named .env and copy the contents of env.template into it.

  2. 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.
  1. Start the development frontend server:
npm run dev

Deployment

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.

  1. Clone the project repository and navigate to its root directory
git clone https://github.com/sweet-peach/vault.git
cd ./vault
  1. Navigate to the backend folder:
cd ./backend
  1. Install dependencies:
npm i
  1. Create a file named .env and copy the contents of env.template into it.

  2. 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
  1. Start the production backend server:
npm run start
  1. Navigate to the frontend folder:
cd ..
cd ./frontend
  1. Install dependencies:
npm i
  1. Create a file named .env and copy the contents of env.template into it.

  2. 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
  1. Build the frontend:
npm run build
  1. Start the frontend server:
npm run start
  1. 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.

Other configuration

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.

About

Cloud storage based on Node.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published