Giter Club home page Giter Club logo

club-manager's Introduction

CLUB MANAGER ⚽️ 🥅 🏟️

Manage your favorite club, make transfers, match squads and win championships.

This is a Node + React + TypeScript project.

  1. FIRST STEPS
  2. DATABASE
  3. AUTOMATED TESTS
  4. FOLDER STRUCTURE

FIRST STEPS

Clone the repository and create .env and development.ts files:

cp .env.example .env
cp src/config/development.example.ts src/config/development.ts

# Get the secrets on Heroku environment

Install packages, enable ORM and run:

yarn && yarn prisma generate && yarn dev

Run automated tests (see more in automated tests section):

yarn test             # run all tests
yarn test:mocked      # run just mocked tests
yarn test:non-mocked  # run just non-mocked tests

DATABASE

For development we're currently using the postgres14 docker image on infra-le-local-dev and both test and prod versions on Heroku are 1.5.

ORM

We use Prisma as our database ORM, they have good documentation here Whenever a prisma command is invoked, the CLI typically reads some information from the schema file, e.g.

So run yarn prisma generate: Reads all information from the Prisma schema to generate the correct data source client code (e.g. Prisma Client).

yarn prisma generate

And run yarn prisma migrate dev: Reads the data sources and data model definition to create a new migration.

yarn prisma migrate dev <migration_name> // name with snake case pattern

See all Prisma options running:

yarn prisma

Remember to run yarn prisma format every time you change schema.prisma before committing your changes

AUTOMATED TESTS

We need two layers of (with jest) tests to validate our service:

  • mocked tests: using jest.spyOn().mockImplementation() we can simulate the response for HTTP or SQL scripts and with that we can validate if the internal flow is correct like, for example, expect(someFunction).toCalledTimes(1).

this test will be run for every pre-push git hook.

  • non-mocked tests: these tests need to be run without mocks, fixtures or anything else. In this scenario, the tests make HTTP requests and save the data to our spec database. We need to ensure that everything will be fine in a real scenario.

these tests will run on Circle CI for every open PR.

So for that we need a folder called __tests__ for each folder in src/server:

src
  |-> helpers
            |-> tests
                    |-> mocked
                    |-> non-mocked

and the setup, fixtures, mocks... needs to be in:

src
  |-> tests-setup
                |-> mocks
                |-> fixtures
                |-> jest.setup.ts

FOLDER STRUCTURE

Inside src/server, please follow these rules:

src
  |-> api          // handle HTTP requests and responses
  |-> config       // handle environment variables
  |-> context      // handle business logic (should not know about HTTP requests or responses and should not talk to any external systems directly)
  |-> helpers      // handle specific functions for business logic
  |-> infra        // handle the connection with another libraries
  |-> middleware   // handle in the HTTP layer with things like cors...
  |-> repository   // handle wrapped Prisma functions and SQL scripts
  |-> services     // handle the communication with other APIs
  |-> tests-setup  // handle test configurations and fixtures, mocks...
  |-> types        // handle our interfaces for this project
  |-> utils        // handle generic functions

club-manager's People

Contributors

felipelealdefaria avatar

Watchers

 avatar

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.