Skip to content

dscfuto-org/fasthrash-BE

Repository files navigation

Fasthrash

 GDSC FUTO Backend repository for Google Solution Challenge 2023

Fastrash

Features

  • Basic Authentication (Register/Login with hashed password)
  • Email sending with Nodemailer.
  • Computer vision via the Google Cloud Vision API
  • JWT Tokens, make requests with a token after login with Authorization header with value yourToken where yourToken will be returned in Login response.
  • Validations added.
  • Included API collection for Postman.
  • Light-weight project.
  • Test cases with Mocha and Chai.
  • Code coverage with Istanbuljs (nyc).
  • Included CI (Continuous Integration) with Travis CI.
  • Linting with Eslint.

Software Requirements

  • Node.js 8+
  • MongoDB 3.6+ (Recommended 4+)

How to install

Using Git (recommended)

  1. Clone the project from github.
git clone https://github.com/dscfuto-org/fasthrash-BE.git fastrash-BE

Using manual download ZIP

  1. Download repository
  2. Uncompress to your desired directory

Install npm dependencies after installing (Git or manual download)

cd fastrash-BE
npm install

Setting up environments

  1. You will find a file named .env.example on root directory of project.
  2. Create a new file by copying and pasting the file and then renaming it to just .env
    cp .env.example .env
  3. The file .env is already ignored, so you never commit your credentials.
  4. Change the values of the file to your environment. Helpful comments added to .env.example file to understand the constants.

Project structure

.
├── app.js
├── package.json
├── bin
│   └── www
├── controllers
│   ├── HistoryControllers
│   │   ├── CollectionHistoryController.js
│   │   └── DepositHistoryController.js
│   ├── AuthController.js
|   ├── AlertController.js
│   └── ImageUploadController.js
├── models
│   ├── HistoryModels
│   │   ├── CollectionHistory.js
│   │   └── DepositHistory.js
│   ├── alertModel.js
│   └── imgModel.js
|   └── userModel.js
|   └── tokenModel.js
|   └── pointModel.js
├── routes
│   ├── alert.js
│   ├── auth.js
│   └── history.js
│   └── imageUpload.js
|   └── testConfig.js
├── middlewares
│   ├── jwt.js
│   └── upload.js
│   └── verifyUser.js
│   └── vision.js
├── helpers
│   ├── apiResponse.js
│   ├── constants.js
│   ├── mailer.js
│   └── utility.js
│   └── cloudStorage.js
├── test
│   ├── testConfig.js
│   ├── auth.js
│   └── alert.js
│   └── history.js
│   └── imageUpload.js
├── views
│   └── resetPassword.ejs
└── public
    ├── index.html
    └── stylesheets
        └── style.css

How to run

Running API server locally

npm run dev

You will know server is running by checking the output of the command npm run dev

Connected to mongodb:YOUR_DB_CONNECTION_STRING
App is running ...

Press CTRL + C to stop the process.

Note: YOUR_DB_CONNECTION_STRING will be your MongoDB connection string.

Tests

Running Test Cases

npm run test

You can set custom command for test at package.json file inside scripts property. You can also change timeout for each assertion with --timeout parameter of mocha command.

Creating new tests

If you need to add more test cases to the project just create a new file in /test/ and run the command.

ESLint

Running Eslint

npm run lint

You can set custom rules for eslint in .eslintrc.json file, Added at project root.

Bugs or improvements

Every project needs improvements, Feel free to report any bugs or improvements. Pull requests are always welcome.

License

This project is open-sourced software licensed under the MIT License. See the LICENSE file for more information.