Sanazoo
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 :
Data model used for DB
Here is our DB model used for this project :
Contributions
Noé LARRIEU-LACOSTE | |
Swann HERRERA | |
Clément BOSSARD |
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 | Web API Framework | |
Date FNS | Useful librairies to manipulates dates | |
Dotenv | Used to load .env file |
|
Argon2 | Used to encrupt users password | |
Mysql2 | DB driver | |
Sequelize | Orm librairies to bind class to DB entities | |
Swagger-jsdoc | Used to implements swagger page | |
Swagger-ui-express | Used to implements swagger page | |
Yup | Form validation library used to validate data in post body of our requests | |
Typescript | 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 :
- Affluence
- Animal
- Animal Health Book
- Enclosure
- Enclosure Images
- Enclosure Service-book
- Enclosure Type
- Entry
- Maintenance
- Pass
- Pass Night
- Pass Type
- Planning
- Specie
- Statistics
- User
- User Role
- Swagger
Swagger
This project contain a complete swagger test environment to use API, you can access it
on https://domain.example/swagger
It look FABULOUS :