Giter Club home page Giter Club logo

crypto-journal-backend's Introduction

Crypto Journal Backend

NodeJs Nestjs Graphql Firebase MongoDB Docker Heroku

This is the backend of the Crypto Journal App, built with NestJs, Graphql and MongoDB.

Project Overview

This project implements all the server-side logic to handle the user data. Firebase is used to handle user auth, while MongoDB stores the user data. The cryptocurrencies data is retrieved using the CoinApi. As the project is hosted on Heroku, instead of having a cron-job to update regularly the crypto-currencies data, the project will do it on start-up if it wasn't already updated. A different approach, inspired by the Golang programming language, is used to handle errors. Instead of throwing errors, functions and methods return a tuple of two elements where the first is the error while the latter is the data itself.

Tech Stack

The project is built with the following tools:

Graphql

The API layer is exposed using Graphql. Every resource is exposed as a Graphql Union of two types to improve error handling on the client-side. These are:

  • ApiError
  • The requested resource (User, Operation ...)

If an error were to happen during a request, instead of sending the default graphql error response, the API would respond with a nicely formatted error.

graphql-union

Nestjs

Is the framework used to develop all the server side logic. Its main advantages are that it is built upon the express framework, it's easy to use, can be easily integrated with third party packages and enforces a good project structure.

Firebase

The Firebase Admin SDK is used to verify that the tokens received from the client app are valid so that a user can be successfully logged in or registered.

MongoDB

MongoDB is used to store the data. The aggregation framework is used to retrieve the overview and holding data belonging to a user.

Docker

Docker is used to standardize the project environment and to make it easier to deploy it to Heroku.

Setup

The project can be run either with docker or with the npm run start command. In both cases, the following variables must be provided:

PORT
NODE_ENV -> optional
DB_URI
ACCESS_TOKEN_SECRET
ACCESS_TOKEN_EXP
REFRESH_TOKEN_SECRET
REFRESH_TOKEN_EXP
GOOGLE_SERVICE_ACCOUNT -> Full google service account json object for firebase
COIN_API_BASE_URL -> Api url without version key
COIN_API_KEY

License

MIT

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.