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-LACOSTE followers
Swann HERRERA followers
Clément BOSSARD followers

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 variable Default Description
PORT 3000 Express listen port
DB_DRIVER mysql Driver for sql connection for sequelize
DB_HOST localhost Host domain / IP for DB
DB_NAME zoo DB Schema name
DB_USER zoo DB user
DB_PASSWORD empty DB password

Main dependencies

Dependency Version Description
Express express version Web API Framework
Date FNS date-fns version Useful librairies to manipulates dates
Dotenv date fns version Used to load .env file
Argon2 argon2 version Used to encrupt users password
Mysql2 mysql version DB driver
Sequelize sequelize version Orm librairies to bind class to DB entities
Swagger-jsdoc version Used to implements swagger page
Swagger-ui-express version Used to implements swagger page
Yup yup version Form validation library used to validate data in post body of our requests
Typescript typescript version Very 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