Giter VIP home page Giter VIP logo

dalal-street-server's Introduction

CircleCI build status Go Report Card

Server for Dalal Street

Prerequisites

  • Go 1.16
  • Protocol buffers
  • MySQL

Build instructions

  • Setting up server

Refer Setup Wiki for setting up Dalal-Street-Server

  • Setup submodules
git submodule init
git submodule update --recursive
  • Create databases and run migrations
mysql -u root -p -e "CREATE DATABASE dalalstreet_dev; CREATE DATABASE dalalstreet_test;"
migrate -path "./migrations" -database "mysql://root:YOUR_MYSQL_PASSWORD@/dalalstreet_dev" up
  • Generate proto files
./scripts/build_proto.sh
  • Run cp config.json.example config.json
  • Fill in the database credentials in the Dev section of config.json.
  • Run the server
    • development - Install air for live reload
      air
    • production
      go run main.go

Create Migrations

migrate create -ext sql -dir ./migrations MIGRATION_NAME

Tests

  • Run the test script locally before pushing commits.
./scripts/test.sh

Docker usage instructions

  • Install docker and docker-compose.

  • Run cp .env.example .env and cp config.json.example config.json.

  • Fill in the DB_PASS in .env and make any additional changes if necessary.

  • Use the same credentials in Docker section config.json (DbPassword)

  • Running server

docker-compose up
  • Once the containers are up, you can get shell access by using
docker exec -it <CONTAINER_NAME> bash
docker-compose build
docker-compose up

(might require sudo, depending on permissions of volume mount './docker/' )

  • To view all running docker containers:
docker ps
  • Server logs are present in ./docker/logs/

GoMock usage instructions

  • To generate mock for a file using mockgen, place this comment after import statement
 //go:generate mockgen -source {YOUR_FILE_NAME}.go -destination ../mocks/{YOUR_FILE_NAME}.go -package mocks
  • To generate mocks for all packages that has above comment
go generate ./...

  • To manually generate a mock package
mockgen -destination=mocks/{YOUR_FILE_NAME}.go -package=mocks {PATH_TO_YOUR_FILE}

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.