Giter Site home page Giter Site logo

blogapp's Introduction

Overview/Design

A sample blogging application backend api. A simple Go(Gin-Gonic) backend server to host blogging apis with the mongoDb as the persistence layer. This hosts two CRUD apis blogUsers and blogPosts and runs on default http port 8080

Example requests: post -> http://localhost:8080/blogUsers
get -> http://localhost:8080/blogPosts?userId=<60170ef7-2157-4c83-b0db-9efcf492f17d>&pageSize=10

Assumptions:

  1. To keep it simple, old version of mongoDb (3.4) is installed with in the Golang-alpine image. Look at DockerFile for the more details

  2. For persistence as of now this application is tightly coupled with mongoDB. If need be a database abstraction layer can be added to use a different database or an external db service.

  3. blog-openapi.yaml file has the api spec definition. To keep the api models consistent open-api generator is used to generate the routers.go file. NOTE: Upstream go-gin-server target for open-api generator has a bug. It does not set the proper binding in the models which is required for the data validation. So models are overridden with required bindings.

  4. Persistence volume is bind mounted to /tmp/db location. So this will be used for the storage.

Install and Build

Requires Golang installed. Please follow the instruction from here https://golang.org/doc/install Requires Docker installed. https://docs.docker.com/get-docker/

This library is developed with go version 1.14.4

Download/clone the application code from from https://github.com/gouthams/blogApp

Needs access from github to resolve dependencies.

To build the docker container

make dockerBuild

To run the docker container

make dockerRun

To stop the running docker container and clean the residue

make dockerStop

Unit test

To build the docker test container

make dockerBuildTest

To run the docker test container

make dockerRunTest

To stop the running docker test container and clean the residue

make dockerStopTest

To execute the unit test with the coverage profile local with a system installed with go, do the following

cd github.com/gouthams/blogApp/server
go test -coverprofile cp.out
go tool cover -html=cp.out

Future Consideration:

  1. Search string are limited to name,id and pageSize. To support paging to large queries with context further enhancements are required.

blogapp's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.