Skip to content

lperrious/template-backend-2022

Repository files navigation

FEE's Backend

The backend for fee (api.fee.fr).

The main goals of this backend is to provide:

  • A connection to our MongoDB database via Mongoose models.
  • An authentication service for the FEE's frontend.
  • A Stripe payment process handler for processing subscription.
  • A GraphQL endpoint powered by Apollo's graphql-tools serving services of the frontend (api.fee.fr/graphql).

Installation

IDE

You need to use VSCode. With ESLint and Prettier plugins installed. You may need to restart VSCode.

System Dependencies

Node.js

You need a recent Node.js version (v16.14+).

You should use nvm.

MongoDB

You just need a fairly recent Mongo to run this.

Node Dependencies

Dependencies resolved via npm:

npm install

Setup script

Needed for various package (i.e. Husky):

npm run setup

Runtime Dependencies

Those dependencies are needed for this application to run.

Here are the most important ones you should know about:

Our main language. Permits to have the power of JS features in a type-based language so as to compiled it and avoid erros during the runtime.

Understanding TypeScript is key to master this codebase

JavaScript runtime built on Chrome's V8 JavaScript engine.

Node.js framework for building efficient, reliable and scalable server-side applications. Under the hood it uses Express.

Understanding Nest is key to master this codebase

Builds a production-ready, self-documenting GraphQL API that can use data from any source. See also the GraphQL's doc for more details.

Understanding Apollo is key to master this codebase

Our ODM to connect to our MongoDB. Mongoose is an intustry-standard.

Development Dependencies

Those dependencies are used for helping with the development:

Code linter.

Configuration

  • The .env.development file - .env.development.local - Describes the env variables used in development environment.
  • The .env.production file - .env.production.local - Describes the env variables used in production environment.
  • The config file - src/utils/config.js - Creates a config data structure which can be accessed thoughout the application.

Run

The application has two running modes:

Dev runner

npm run dev

Nest will automatically load .env.development and set NODE_ENV='DEVELOPMENT'. It then listens on 3030.

Prod build runner

npm run build

Nest will automatically load .env.production and set NODE_ENV='PRODUCTION'.

Then, start the server:

npm start

Contributing

In order to help you contribute to the repository, we provide you two main tools:

  • Testing via npm test
  • Typechecking via npm run typecheck
  • Linting + Typechecking on all files via npm run lint-all
  • Linting + Typechecking on staged files via npm run lint

Rules

You can't commit directly on master, you should fill Pull Request via Github.

Those must respond to the checklist provided in the template.

Reporting issues

You are welcome to report backend issues here!

Follow the template and everything should roll well!

Repository structure

Here is the repository structure (here is the inspiration):

About

TypeScript, Nest, Apollo server, Mongo

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published