{"id":13714384,"url":"https://github.com/jaggerwang/zqc-server-demo","last_synced_at":"2025-05-07T01:33:43.229Z","repository":{"id":112813157,"uuid":"74666165","full_name":"jaggerwang/zqc-server-demo","owner":"jaggerwang","description":"Lite version of zaiqiuchang api server, which developed by go and deploy using docker. It also can be used as a starter kit for developing api server.","archived":false,"fork":false,"pushed_at":"2017-02-20T13:40:20.000Z","size":54,"stargazers_count":112,"open_issues_count":0,"forks_count":38,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-08-02T23:30:11.153Z","etag":null,"topics":["api-server","docker","go"],"latest_commit_sha":null,"homepage":"https://www.zaiqiuchang.com/","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jaggerwang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-11-24T11:16:13.000Z","updated_at":"2022-11-20T11:49:01.000Z","dependencies_parsed_at":"2024-05-18T02:04:33.462Z","dependency_job_id":"d0c5355f-f210-4fa6-a713-72fc59859fe5","html_url":"https://github.com/jaggerwang/zqc-server-demo","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaggerwang%2Fzqc-server-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaggerwang%2Fzqc-server-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaggerwang%2Fzqc-server-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jaggerwang%2Fzqc-server-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jaggerwang","download_url":"https://codeload.github.com/jaggerwang/zqc-server-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224551246,"owners_count":17330111,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-server","docker","go"],"created_at":"2024-08-02T23:01:58.468Z","updated_at":"2024-11-14T01:31:08.051Z","avatar_url":"https://github.com/jaggerwang.png","language":"Go","funding_links":[],"categories":["Repositories"],"sub_categories":[],"readme":"# Zaiqiuchang server demo\n\n[Zaiqiuchang(在球场)](https://www.zaiqiuchang.com) is a mobile app developed using React Native, both iOS and Android are supported. This project is the lite version of the api server, which developed in Go, and deploy using Docker. The lite version only include account related apis, but it should be a good start to develop your own. \n\n### Packages\n\n|Package|Description|\n|-------|-----------|\n|[github.com/labstack/echo](https://echo.labstack.com/)|Http server and framework.|\n|[github.com/spf13/cobra](https://github.com/spf13/cobra)|CLI app framework.|\n|[github.com/spf13/viper](https://github.com/spf13/viper)|Manage app configuration.|\n|[github.com/asaskevich/govalidator](https://github.com/asaskevich/govalidator)|Validate input.|\n|[github.com/Sirupsen/logrus](https://github.com/Sirupsen/logrus)|Logging.|\n|[gopkg.in/mgo.v2](https://labix.org/mgo)|Mongodb driver.|\n|[github.com/garyburd/redigo/redis](https://github.com/garyburd/redigo/)|Redis driver.|\n|[github.com/gorilla/sessions](https://github.com/gorilla/sessions)|Manage user session.|\n|[github.com/smartystreets/goconvey/convey](https://github.com/smartystreets/goconvey)|Test framework.|\n\n### How to deploy\n\nYou need install [docker engine](https://docs.docker.com/engine/installation/) first.\n\n**run in dev mode with auto detecting code change**\n\n```\n\u003e git clone git@github.com:jaggerwang/zqc-server-demo.git \u0026\u0026 cd zqc-server-demo\n\u003e mkdir -p ~/data/projects/zqc-server-demo # create directory for data volumes\n\u003e ./deploy.sh # pull images and run containers\n\u003e ./fswatch.sh # watching code change, fswatch needed\n```\n\nThe data and log of server, mongodb and redis will be saved at host's path \"~/data/projects/zqc-server-demo\", which mounted at container's path \"/data\".\n\n**run in prod mode**\n\n```\n\u003e git clone git@github.com:jaggerwang/zqc-server-demo.git \u0026\u0026 cd zqc-server-demo\n\u003e mkdir -p /data/zqc-server-demo # create directory for data volumes\n\u003e ./deploy-prod.sh\n```\n\nThe data and log of server, mongodb and redis will be saved at host's path \"/data/zqc-server-demo\", which mounted at container's path \"/data\".\n\n**run test**\n\n```\n\u003e cd zqc-server-demo\n\u003e ./test.sh\n...\n2017/02/11 16:01:03 parser.go:24: [passed]: zqc/test\n2017/02/11 16:01:03 executor.go:69: Executor status: 'idle'\n```\n\nScript `tesh.sh` will run a new group of docker containers to run unittests, including server, mongodb and redis. The new group has separated volumes and ports, to avoid empty the existing data. We use `goconvey` to write and run unittests. It supplied a web console to show the test result, and will run test automatically when detected code change.\n\nOpen url \"http://localhost:10402/\" to view test result.\n\u003cimg src=\"https://zqc.cdn.zaiqiuchang.com/github/goconvey-result.png?x-oss-process=style/w-1080\" /\u003e\n\n**build image of your own**\n\n```\n\u003e cd zqc-server-demo\n\u003e ./docker-build.sh\n```\n\n### Command\n\n**help**\n\n```\n\u003e cd zqc-server-demo\n\u003e docker-compose -p zqc-server-demo exec server zqc\nZai qiu chang app.\n\nUsage:\n  zqc [command]\n\nAvailable Commands:\n  db          Database admin\n  server      Run server\n\nFlags:\n  -c, --config string              config file (default \"./config.json\")\n      --dir.data string            directory for saving runtime data\n      --env string                 deployment environment\n      --log.level string           log filter level\n      --mongodb.zqc.addrs string   address of zqc db\n\nUse \"zqc [command] --help\" for more information about a command.\n```\n\n**create mongodb index**\n\n```\n\u003e cd zqc-server-demo\n\u003e docker-compose -p zqc-server-demo exec server zqc db createIndexes\n```\nWhen deploy, it will auto run this command to create mongodb index. So normally you do not need to do this by your own.\n\n### API\n\nThe server container exposed port 1323, and it mapped to port 10400 of the host. So you can use domain \"http://localhost:10400\" to access the following api.\n\nPath|Method|Description\n----|------|-----------\n/register|POST|Register account.\n/login|GET|Login.\n/isLogined|GET|Check whether logined.\n/logout|GET|Logout.\n/account/edit|POST|Edit account profile.\n/account/info|GET|Get current account info.\n/user/info|GET|Get user info by id.\n/user/infos|GET|Get user info by ids.\n\n### FAQ\n\n**How to change image repository?**\n\n\u003e Search and replace all \"daocloud.io/jaggerwang/zqc-server-demo\" to your own.\n\n**How can I build the base images of this project, including go, mongodb and redis?**\n\n\u003e The dockerfiles of the base images can be found at \"https://github.com/jaggerwang/jw-dockerfiles\".\n\n### Other resources\n\n* [技术文章 - Go + Docker API服务开发和部署](https://jaggerwang.net/develop-and-deploy-api-service-with-go-and-docker-intro/)\n* [在球场官网](https://www.zaiqiuchang.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaggerwang%2Fzqc-server-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjaggerwang%2Fzqc-server-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjaggerwang%2Fzqc-server-demo/lists"}