Skip to content

Latest commit

 

History

History
 
 

back

It Academy Project - Wiki (ITA Wiki)

This project uses a set of technologies to facilitate the development of web applications and APIs. The goal of this README is to provide a guide for new project members to integrate more easily and start contributing as soon as possible.

Getting Started

Before running the project, make sure you have Docker Desktop installed. Once you have Docker Desktop installed and running, follow the steps below:

With Linux/Mac

  1. cd into the back folder if you haven't already:

    cd back

  2. Install the required dependencies:

    npm i

  3. Start the project in docker:

    npm run up

With Windows

  1. cd into the back folder if you haven't already:

    cd back

  2. Install the required dependencies:

    npm i

  3. Allow npm to use bash commands:

    npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"

  4. Start the project in docker:

    npm run up

  5. Reset your database and apply all migrations:

    npm run prisma:migrate:reset

The above command will start the application and run the migrations using Prisma.

Scripts

Here are some of the useful scripts you can use:

  • "dev": starts a development server using nodemon, which watches for file changes and automatically restarts the server. It runs the src/server.ts file using ts-node/esm loader with experimental specifier resolution and ignores any changes to node_modules.
  • "build": compiles the TypeScript code into JavaScript code using the tsc compiler.
  • "bundle": creates a single-file bundle of the application using ncc, which includes all the dependencies in the bundle.
  • "start": starts the server by running the dist/index.js file generated by the build script.
  • "lint": lints the TypeScript code in the src folder using eslint.
  • "lint:fix": fixes the linting errors in the TypeScript code in the src folder using eslint.
  • "prisma:generate": generates the Prisma client code based on the schema defined in prisma/schema.prisma.
  • "prisma:studio": starts the Prisma Studio web interface to manage the database.
  • "prisma:migrate": creates a new migration for the database using prisma migrate dev with the name init.
  • "prisma:migrate:reset": resets the database to the initial state by dropping all tables using prisma migrate reset.
  • "test": runs the tests using the vitest test runner.
  • "up": changes directory to the scripts folder and runs the up.sh script, which starts the database server and other dependencies. Then, it changes directory back to the back folder and runs the prisma:migrate script.

Golden Rules

  1. All code contributions must pass the CI/CD pipeline, which includes running linters, tests, and other checks. Please do not try to make pull requests that do not pass these validations.
  2. Code must follow the project's ESLint configuration. Make sure your editor is configured to use the project's .eslintrc file (It should be automatically detected by ESLint if you are using Visual Studio Code).
  3. All code contributions must have accompanying tests.

Very Useful Documentation

Here are some useful links to official documentation for the technologies used in this project:

  • Prisma - Prisma ORM documentation.
  • vitest - vitest testing framework documentation.

If you are new to TypeScript or Prisma ORM, you may want to watch the following tutorial before diving into the project: REST API with TypeScript and Prisma ORM. This tutorial covers the basics of TypeScript and how it can be used with Node.js to create web applications.

Docker