Skip to content

kazi-naimul/file-sharing-api-server

Repository files navigation

File Sharing API Server

Docker Installation

This application needs to have postgresql database and redis server. You need to have prepare those enviroment for this. Or you can use the run the following docker-compose commands to prepare the enviroment. Clone the repo:

docker-compose build
docker-compose up -d

Manual Installation

Install the dependencies:

yarn install

Set the environment variables:

cp .env.example .env

# open .env and modify the environment variables (if needed)

Features

  • ORM: Sequelize orm for object data modeling
  • Migration and Seed: DB migration and Seed using Sequelize-CLI
  • Authentication and authorization: using passport
  • Error handling: centralized error handling
  • Validation: request data validation using Joi
  • Logging: using winston
  • Testing: unittests using Mocha
  • Caching: Caching using Redis
  • Bidirectional Communication: using Scoket
  • Job scheduler: with Node-cron
  • Dependency management: with Yarn
  • Environment variables: using dotenv and cross-env
  • CORS: Cross-Origin Resource-Sharing enabled using cors
  • Docker support
  • Linting: with ESLint and Prettier

Commands

Running locally:

yarn dev

Running in production:

yarn start

Testing:

# run all tests
yarn test

Environment Variables

The environment variables can be found and modified in the .env file. They come with these default values:

#Server environment
NODE_ENV=development
#Port number
PORT=5000

#Db configuration
DB_HOST=db-host
DB_USER=db-user
DB_PASS=db-pass
DB_NAME=db-name


# JWT secret key
JWT_SECRET=your-jwt-secret-key
# Number of minutes after which an access token expires
JWT_ACCESS_EXPIRATION_MINUTES=5
# Number of days after which a refresh token expires
JWT_REFRESH_EXPIRATION_DAYS=30

#Log config
LOG_FOLDER=logs/
LOG_FILE=%DATE%-app-log.log
LOG_LEVEL=error

#Redis
REDIS_HOST=redis-host
REDIS_PORT=6379
REDIS_USE_PASSWORD=no
REDIS_PASSWORD=your-password

FOLDER=folder-name
PROVIDER=local

#S3 config
S3_BUCKET=s3-bucket-name
AWS_ACCESS_KEY_ID=AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY=AWS_SECRET_ACCESS_KEY
S3_REGION="s3-region"

UPLOAD_LIMIT=10
DOWNLOAD_LIMIT=10

MAX_INACTIVE_PERIOD_IN_DAYS=10

Project Structure

specs\
src\
 |--config\         # Environment variables and configuration related things
 |--controllers\    # Route controllers (controller layer)
 |--dao\            # Data Access Object for models
 |--db\             # Migrations and Seed files
 |--models\         # Sequelize models (data layer)
 |--routes\         # Routes
 |--services\       # Business logic (service layer)
 |--helper\         # Helper classes and functions
 |--validations\    # Request data validation schemas
 |--app.js          # Express app
 |--cronJobs.js     # Job Scheduler
 |--index.js        # App entry point

Here is the API Documentation

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published