Skip to content

Cabinet Dentaire Backend built using express js and prisma

Notifications You must be signed in to change notification settings

hadarisas/cabinet_dentaire_backend

Repository files navigation

Backend for a 'Cabinet dentaire' project

This the backend part of the 'Cabinet dentaire' project, Built using express js and prisma and postgres.

Git clone this repository

git clone [email protected]:hadarisas/cabinet_dentaire_backend.git

Access to repository folder

cd cabinet_dentaire_backend

install packages

npm i

install nodemon to run development mode

npm i -g nodemon

Create an image for Postgres database using docker

docker build -t postgres_db_cabinet .

Create a folder for Postgres database data:

mkdir postgres_db_data

Run the image in the container

docker run -d --name cabinet_db_container -v /absolute_path_to_postgres_db_data:/var/lib/postgresql/data -p 5432:5432 postgres_db_cabinet

Create a .env file and add the environment variables

cp example_env.txt .env

Push the database schema to the database

npx prisma db push

Seed the database

npm run seed

To Run the prisma studio to see the database data

npx prisma studio

Create a self-signed certificate for https

For MacOS:

# Install Homebrew if you don't have it
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install mkcert
brew install mkcert

# Install nss (for Firefox)
brew install nss

# Create and install the local CA
mkcert -install

# Create certificates for localhost
mkcert localhost 127.0.0.1 ::1

For Windows:

# Using chocolatey
choco install mkcert

# Or using scoop
scoop bucket add extras
scoop install mkcert

For Linux:

# Ubuntu/Debian
sudo apt install libnss3-tools
sudo apt install mkcert

# Or download the binary directly
curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64"
chmod +x mkcert-v*-linux-amd64
sudo cp mkcert-v*-linux-amd64 /usr/local/bin/mkcert

After that you can create the certificates with the following command:

# Create and install the local CA
mkcert -install

# Create certificates for localhost
mkcert localhost 127.0.0.1 ::1

This will generate two files: localhost+2.pem (the certificate) and localhost+2-key.pem (the private key)

Move these files to your project directory and update your

run the project in development mode:

npm run dev

For the API documentation, you can use the following link (if you use another port than 3000, replace it in the link):

http://localhost:3000/docs-api

If you want to use the cookie instead of the token you need to comment

router.use(authJwt.verifyToken);

in the routes files and uncomment

router.use(authJwt.authenticateToken);

The project is not finished yet, other features will be added in Coming days. so stay tuned!

About

Cabinet Dentaire Backend built using express js and prisma

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published