Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

pnicto/IS-F341-Bitwise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bitwise

This project is setup with nx a new tool found in the wild.

How to run

Prerequisites

  • node >= 18
  • pnpm >= 8
  • docker >= 25

Setup

  • In the project root, run to install the dependencies.
    pnpm install
  • Run this generate the typescript types for our schemas.
    pnpm prisma generate

Development

  • Make Prettier your default formatter in your editor.

  • cp .example.env .env

    Add the required fields in .env.

  • In the project root, run to start the db.

    docker compose up
    
    # alternatively you can use this command to run in detached mode
    docker compose up -d
  • Optionally to seed the db, run

    pnpm prisma db seed
  • Once the db is up and running, you use nx to serve the project

    # both frontend and backend
    pnpm nx run-many -t serve -p frontend backend # or
    pnpm nx run-many -t serve
    
    # only the backend
    pnpm nx serve backend
    
    # only the frontend
    pnpm nx serve frontend

    Alternatively, you can use the vscode extension to the do the same.

Other questions

Adding new packages

You have to install them in the project root using pnpm.

Schemas

The schemas for the entire project are defined in prisma/schema.prisma. Every time you make changes to schemas make sure you run the generate and push commands. If you are getting some errors after running this commands it just means that the new schema changes are not straightforward to apply. In that case run the second command.

pnpm prisma db push

# this also clears the data
pnpm prisma db push --force-reset

The terminal output is messed up

I think there's some problem with the nx cli's stdout with new lines. Even if the terminal is not responsive it is going to work fine. If you want to kill it you can run pkill node in another window.

Deleting .nx folder

Yes, you can delete that folder.

The backend is too slow to update changes after save

We are relying on webpack hope that answers.

Seeding database

Data is seeded from prisma/seed.ts file. The sample lines of code in that file use upsert(), alternatively the entire db could be deleted and data can be inserted using createMany().

https://www.prisma.io/docs/orm/prisma-migrate/workflows/seeding

Useful commands

# to open the mongodb shell where you can interact with the database
docker exec -it bitwise-db-dev mongosh -u bitwise -p password --authenticationDatabase admin bitwise

# use a GUI to view/edit the db
pnpm prisma studio

# delete the db data (you could also use pnpm prisma db push --force-reset)
docker compose down -v # or
docker volume rm bitwise_data # after removing the container

API Response formats

// success
// both of these formats can be combined if required for success responses
// this message will be displayed on the frontend
{
	msg: string
}
// or
// this data will be used by the frontend
{
  products: [...]
}

// errors
{ msg: string }[]
// example
const errors = [
	{ msg: 'Missing field price' },
	{ msg: 'Age needs to a number greater than 0' },
]

References

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published