Cinojose / StudentEnrollmentApi

A simple student enrollment api server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build Status

Student Enrollment Api Server

A student enrollment api server using Go Swagger

Prerequisites

  • Running mysql database with a table created based on the sql/student.sql
  • Docker engine

How to run ?

 # Download source code
  git clone https://github.com/Cinojose/StudentEnrollmentApi.git
 #setup the env variables
  export DB_USER=<db-user>
  export DB_PASSWORD=<db-password>
  export DB_NAME=<database-name>
  export DB_HOST=<database-host-address>
 # build the docker image
  docker build -t studentenrollment .
 # Run the docker image
  docker run -it -p 8001:8001 --env DB_USER --env DB_PASSWORD --env DB_NAME --env DB_HOST studentenrollment studentenrollment 
 # The app can  be accessed via following URL upon successful run
 # http://localhost:8001/internal/apidocs

How to run tests ?

Start the APP server using the above instructions

   # set up the env variables
   export API_PORT=<aplication port>
   export API_HOST=<application-host>

   # Build and run docker
   docker build -t unitest -f DockerfileTest . && docker rm unitest && docker run -it --env API_HOST --env API_PORT--name unitest unitest
   

Generating server stub using swagger

   # Generate a server stub using the swagger yml
   cd github.com/StudentEntollmentApi
   alias swagger="docker run --rm -it -e GOPATH=$HOME/go:/go -v $HOME:$HOME -w $(pwd) quay.io/goswagger/swagger"
   # Update the swagger.yml with your new changes
   swagger generate server -f swagger.yaml -A StudentEnrollmentApi
   # Run the above docker commands to build the code

App Deployment

CICD diagram

About

A simple student enrollment api server


Languages

Language:Go 70.8%Language:HCL 18.3%Language:Shell 6.2%Language:Dockerfile 4.7%