Sign inSign up

anclarma/crud-nestjs

By anclarma

•Updated over 3 years ago

une API NestJS permettant d'obtenir des informations sur des codes barres via l'API OpenFoodFact.

Image
0

442

anclarma/crud-nestjs repository overview

Nest Logo openfoodfacts Logo

⁠Description

A NestJS API for obtaining barcode information via the OpenFoodFact API.

⁠Documentation

The documentation is automatically generated by swagger and is accessible at the url http://localhost:3000/api⁠

⁠Running the app

⁠run in docker image

# run postgres container
$ docker run --detach \
           --name postgres \
           --env POSTGRES_USER=test_user \
           --env POSTGRES_PASSWORD=test_pass \
           --env POSTGRES_DB=test_db \
           --expose 5432 \
           --net=bridge \
           --volume /custom/data:/var/lib/postgresql/data \
           postgres:15

# export postgres host ip for crud-nestjs container
$ export POSTGRES_HOST=$(docker network inspect bridge | grep -A 4 "\"Name\": \"postgres\"" | grep "IPv4Address" | cut -d'"' -f4 | cut -d'/' -f1)

# run crud-nestjs container
$ docker run --detach \
           --name crud-nestjs \
           --env POSTGRES_HOST \
           --env POSTGRES_PORT=5432 \
           --env POSTGRES_USER=test_user \
           --env POSTGRES_PASSWORD=test_pass \
           --env POSTGRES_DB=test_db \
           --env JWT_SECRET=jwt_secret \
           --publish 3000:3000 \
           --net=bridge \
           anclarma/crud-nestjs

# test crud-nestjs
$ curl http://localhost:3000

⁠run in docker compose

## docker-compose.yml
version: '3.9'

services:
  postgres:
    container_name: postgres
    image: postgres
    restart: always
    environment:
      POSTGRES_USER: test_user
      POSTGRES_PASSWORD: test_pass
      POSTGRES_DB: test_db
    expose:
      - 5432
    networks:
      - backend_network
    volumes:
      - data:/var/lib/postgresql/data

  crud-nestjs:
    container_name: crud-nestjs
    image: anclarma/crud-nestjs:latest
    restart: always
    environment:
      POSTGRES_HOST: postgres
      POSTGRES_PORT: 5432
      POSTGRES_USER: test_user
      POSTGRES_PASSWORD: test_pass
      POSTGRES_DB: test_db
      JWT_SECRET: jwt_secret
    ports:
      - 3000:3000
    networks:
      - backend_network
    depends_on:
      - postgres

volumes:
  data:

networks:
  backend_network:
    driver: bridge
# run crud-nestjs and postgres in docker compose
$ docker compose up -d

# test crud-nestjs
$ curl http://localhost:3000

Tag summary

Content type

Image

Digest

sha256:9d07b0edb…

Size

104.4 MB

Last updated

over 3 years ago

docker pull anclarma/crud-nestjs