Skip to main content

Sanazoo

GitHub repo

package.json versionexpress
versionsequelize
versiontypescript
version

SanaZoo is a very popular zoo !

First created in C with XML files, it is now developed with nodejs and swagger, for your eyes only

Our project

In this school project, we have to realize a complete API to manage a zoo, using Express and Sequelize as a base.

This project has been tested and integrated both on heroku, but also thanks to docker whose image is detailed below

Project Syllabus : Syllabus.pdf

Gantt chart

This project was carried out using a gantt chart :

image-20210424163444370.png

Data model used for DB

Here is our DB model used for this project :

Planode-Zoo.png

Contributions

Noé LARRIEU-LACOSTEfollowers
Swann HERRERAfollowers
Clément BOSSARDfollowers

Information about code

Docker integration

Our docker image is built in 2 step :

  • First we build all the project with dev dependencies
  • Then we only keep production dependencies with compiled project

This reduce drastictly the size of the image

## Stage 1 building the code
FROM node:lts-alpine as builder
WORKDIR /usr/app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

## Stage 2 final stage with builded code
FROM node:lts-alpine
WORKDIR /usr/app
COPY package*.json ./
RUN npm ci --production

COPY --from=builder /usr/app/dist ./dist

ENV PORT=3000 \
    DB_PORT=3306 \
    DB_DRIVER='mysql' \
    DB_HOST='localhost' \
    DB_NAME='zoo' \
    DB_USER='root' \
    DB_PASSWORD=''

CMD node dist/src/index.js

Env

Environment variableDefaultDescription
PORT3000Express listen port
DB_DRIVERmysqlDriver for sql connection for sequelize
DB_HOSTlocalhostHost domain / IP for DB
DB_NAMEzooDB Schema name
DB_USERzooDB user
DB_PASSWORDemptyDB password

Main dependencies

DependencyVersionDescription
Expressexpress versionWeb API Framework
Date FNSdate-fns versionUseful librairies to manipulates dates
Dotenvdate fns versionUsed to load .env file
Argon2argon2 versionUsed to encrupt users password
Mysql2mysql versionDB driver
Sequelizesequelize versionOrm librairies to bind class to DB entities
Swagger-jsdocversionUsed to implements swagger page
Swagger-ui-expressversionUsed to implements swagger page
Yupyup versionForm validation library used to validate data in post body of our requests
Typescripttypescript versionVery useful to use types in JS based framework

API Endpoints

Postman Environment

You can check our endpoints with postman directly on this URL: https://documenter.getpostman.com/view/11568150/TzJvdwNA

API Description :


Swagger

This project contain a complete swagger test environment to use API, you can access it on https://domain.example/swagger

It look FABULOUS :

image-20210424170307083.png