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).
You need to use VSCode. With ESLint and Prettier plugins installed. You may need to restart VSCode.
You need a recent Node.js version (v16.14+).
You should use nvm.
You just need a fairly recent Mongo to run this.
Dependencies resolved via npm:
npm install
Needed for various package (i.e. Husky):
npm run setup
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.
Those dependencies are used for helping with the development:
Code linter.
- 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.
The application has two running modes:
npm run dev
Nest will automatically load .env.development and set NODE_ENV='DEVELOPMENT'. It then listens on 3030
.
npm run build
Nest will automatically load .env.production and set NODE_ENV='PRODUCTION'.
Then, start the server:
npm start
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
You can't commit directly on master
, you should fill Pull Request via Github.
Those must respond to the checklist provided in the template.
You are welcome to report backend issues here!
Follow the template and everything should roll well!
Here is the repository structure (here is the inspiration):