{"id":25203830,"url":"https://github.com/twreporter/go-api","last_synced_at":"2025-10-09T15:50:50.824Z","repository":{"id":37271131,"uuid":"79105381","full_name":"twreporter/go-api","owner":"twreporter","description":"Golang API","archived":false,"fork":false,"pushed_at":"2025-10-02T18:13:12.000Z","size":2650,"stargazers_count":107,"open_issues_count":7,"forks_count":20,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-10-02T20:24:19.143Z","etag":null,"topics":["golang","mongodb","mysql","news","oauth2","rest-api"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/twreporter.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-01-16T09:59:22.000Z","updated_at":"2025-10-02T18:13:16.000Z","dependencies_parsed_at":"2023-10-04T12:17:50.568Z","dependency_job_id":"674caba8-ef56-4948-974e-4504a056d600","html_url":"https://github.com/twreporter/go-api","commit_stats":null,"previous_names":[],"tags_count":56,"template":false,"template_full_name":null,"purl":"pkg:github/twreporter/go-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twreporter%2Fgo-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twreporter%2Fgo-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twreporter%2Fgo-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twreporter%2Fgo-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/twreporter","download_url":"https://codeload.github.com/twreporter/go-api/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twreporter%2Fgo-api/sbom","scorecard":{"id":904447,"data":{"date":"2025-08-11","repo":{"name":"github.com/twreporter/go-api","commit":"632e9ad5812df57bd29e63ef03b7a03aad33d243"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Code-Review","score":3,"reason":"Found 5/13 approved changesets -- score normalized to 3","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":10,"reason":"30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: containerImage not pinned by hash: Dockerfile:6","Warn: containerImage not pinned by hash: Dockerfile:50: pin your Docker image by updating alpine:3.12 to alpine:3.12@sha256:c75ac27b49326926b803b9ed43bf088bc220d22556de1bc5f72d742c91398f69","Info:   0 out of   2 containerImage dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"20 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2022-0635","Warn: Project is vulnerable to: GO-2022-0646","Warn: Project is vulnerable to: GO-2020-0017 / GHSA-w73w-5m7g-f7qc","Warn: Project is vulnerable to: GO-2024-2955 / GHSA-869c-j7wc-8jqv","Warn: Project is vulnerable to: GO-2021-0052 / GHSA-h395-qcrw-5vmq","Warn: Project is vulnerable to: GHSA-3vp4-m3rf-835h","Warn: Project is vulnerable to: GO-2023-1737 / GHSA-2c4m-59x9-fr2g","Warn: Project is vulnerable to: GO-2021-0112 / GHSA-f6mq-5m25-4r72","Warn: Project is vulnerable to: GO-2022-0968 / GHSA-gwc9-m7rh-j2ww","Warn: Project is vulnerable to: GO-2021-0356 / GHSA-8c26-wmh5-6g9v","Warn: Project is vulnerable to: GO-2024-2961","Warn: Project is vulnerable to: GO-2023-2402 / GHSA-45x7-px36-x8w8","Warn: Project is vulnerable to: GO-2024-3321 / GHSA-v778-237x-gjrc","Warn: Project is vulnerable to: GO-2025-3487 / GHSA-hcg3-q754-cr77","Warn: Project is vulnerable to: GO-2025-3488 / GHSA-6v2p-p543-phr9","Warn: Project is vulnerable to: GO-2022-0493 / GHSA-p782-xgp4-8hr8","Warn: Project is vulnerable to: GO-2021-0113 / GHSA-ppp9-7jff-5vj2","Warn: Project is vulnerable to: GO-2022-1059 / GHSA-69ch-w2m2-3vjp","Warn: Project is vulnerable to: GO-2023-2153 / GHSA-m425-mq94-257g / GHSA-qppj-fm5r-hxr3","Warn: Project is vulnerable to: GO-2024-2611 / GHSA-8r3f-844c-mc37"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-24T16:49:53.024Z","repository_id":37271131,"created_at":"2025-08-24T16:49:53.024Z","updated_at":"2025-08-24T16:49:53.024Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001649,"owners_count":26083147,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["golang","mongodb","mysql","news","oauth2","rest-api"],"created_at":"2025-02-10T07:19:04.576Z","updated_at":"2025-10-09T15:50:50.773Z","avatar_url":"https://github.com/twreporter.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TWReporter's Golang Backend API\n\n## Environment \n### Development\n\n#### Go module\nAfter go-api@5.0.0 is released, go-api no longer needs to be developed within $GOPATH/src directory thanks to the go module support. Make sure your go version is go@1.11 or higher to have full compatibility. You can clone to anywhere outside the $GOPATH as you wish.\n\n```golang\n$ git clone github.com/twreporter/go-api\n$ cd go-api\n\n// Run test\n$ go test ./...\n\n// Use makefile\nmake start\n// Or\n$ go run main.go\n\n// Build server binaries\n$ go build -o go-api\n$ ./go-api\n```\n\n#### Deprecated\nPlease make sure that you install [Glide\n  package manager](https://github.com/Masterminds/glide) in the environment. (Switch to [go module](https://github.com/golang/go/wiki/Modules) after v5.0.0)\n\n```\ncd $GOPATH/src/github.com/twreporter/go-api\nglide install                           # Install packages and dependencies\n\n// use Makefile\nmake start \n// or \ngo run main.go                          # Run without live-reloading\n```\n\n### Production\n```\ngo build\n./go-api\n```\n\n## Dependencies Setup and Configurations\nThere are two major dependencies of go-api, one is MySQL database, \nanother is MongoDB. \u003cbr/\u003e\nMySQL DB stores membership data, which is related to users.\u003cbr/\u003e\nMongoDB stores news entities, which is the content that go-api provides.\u003cbr/\u003e\n\n### Install docker-compose\n[docker-compose installation](https://docs.docker.com/compose/install/) \n\n### Start/Stop MySQL and MongoDB with default settings\n```\n// start MySQL and MongoDB\nmake env-up\n\n// stop MySQL and MongoDB\nmake env-down\n```\n\n### Configure MySQL Connection\nCopy `configs/config.example.json` and rename as `configs/config.json`.\nChange `DBSettings` fields to connect to your own database, like following example.\n```\n  \"DBSettings\": {\n    \"Name\":     \"test_membership\",\n    \"User\":     \"test_membership\",\n    \"Password\": \"test_membership\",\n    \"Address\":  \"127.0.0.1\",\n    \"Port\":     \"3306\"\n  },\n```\n\n### Configure MongoDB Connection\nCopy `configs/config.example.json` and rename as `configs/config.json`.\nChange `MongoDBSettings` fields to connect to your own database, like following example.\n```\n  \"MongoDBSettings\": {\n    \"URL\": \"localhost\",\n    \"DBName\": \"plate\",\n    \"Timeout\": 5\n  },\n```\n\n### AWS SES Setup\nCurrently the source code sends email through AWS SES. \nIf you want to send email through your AWS SES, the config with credentials is needed.\n\nTo get credentials, please go to [Identity and Access Management (IAM)](https://console.aws.amazon.com/iamv2/home?#/users) page and add new user. Note that you need to set user details as follows:\n  - set user name\n    - naming convention:  `ses-smtp-user.{YYYYMMDD}-develop`\n  - select AWS access type: select `Access key - Programmatic access`\n\nAfter creating a new user, remember to copy the `Access key ID` and `Secret access key` and put them in AWS SES config under `~/.aws/credentials`\n```\n[default]\naws_access_key_id = ${AWS_ACCESS_KEY_ID}\naws_secret_access_key = ${AWS_SECRET_ACCESS_KEY}\n```\n\nFor more information, please refer to [this guide](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html). \n\nOtherwise, you have to change the `utils/mail.go` to integrate with your email service.\n\n### OAuth Setup\n- Google\n  - go to [APIs \u0026 Services](https://console.developers.google.com/apis/credentials/oauthclient/505721902139-u57i4r21h1e0b9rhdqcehleb4b05fcsf.apps.googleusercontent.com?project=coastal-run-106202\u0026authuser=0\u0026pli=1)\n  - copy  `Client ID` and `Client secret` \n  - edit `configs/config.go`\n    ```\n    oauth:\n      google:\n        id: $Client_ID\n        secret: $Client_secret\n    ```\n- Facebook\n  - go to [apps setting](https://developers.facebook.com/apps/760575077441512/settings/basic/)  - copy `App ID` and `App secret` \n  - edit `configs/config.go`\n    ```\n    oauth:\n      facebook:\n        id: $App_ID\n        secret: $App_secret\n    ```\n\n### Database Migrations\nGo-api integrates [go-migrate](https://github.com/golang-migrate/migrate) to do the schema version control. You can follow the instructions to install the cli from [here](https://github.com/golang-migrate/migrate/tree/master/cli).\n\nTo use Makefile, check following instruction:\n\nCheck Current Migration Version\n```bash\n$ make check-version\n```\n\nUpgrade Migration Version\n```bash\n# usage:\n# make upgrade-schema UP=\u003cnumber of version to upgrade\u003e\n#   UP: \u003cnumber\u003e, if undefined, upgrade to latest number\n\n# example: upgrade 4 versions\n$ make upgrade-schema UP=4\n\n# example: upgrade to latest version\n$ make upgrade-schema\n```\n\nDowngrade Migration Version\n```bash\n# usage:\n# make downgrade-schema DOWN=\u003cnumber of version to downgrade\u003e\n#   DOWN: \u003cnumber\u003e, if undefined, clear all migration\n\n# example: downgrade 1 version\n$ make downgrade-schema DOWN=1\n\n# example: remove all migration\n$ make downgrade-schema\n```\n\nGoto Certain Migration Version\n```bash\n# usage:\n# make goto-schema SCHEMA_VERSION=\u003cindex of which version you want to goto\u003e\n#   SCHEMA_VERSION: \u003cindex number\u003e, if undefined, interactive prompt will ask for index in next line.\n\n# example: goto version 3\n$ make goto-schema SCHEMA_VERSION=3\n\n# example: goto version 3\n$ make goto-schema\n$ 3\n```\n\nForce to Certain Migration Version\n```bash\n# usage:\n# make force-schema SCHEMA_VERSION=\u003cindex of which version you want to force to\u003e\n#   SCHEMA_VERSION: \u003cindex number\u003e, if undefined, interactive prompt will ask for index in next line.\n\n# notice:\n#   migrations will not be executed if you use this function.\n#   you can use this function to clean dirty state while development\n\n# example: force to version 4\n$ make force-schema SCHEMA_VERSION=4\n\n# example: force to version 4\n$ make force-schema\n$ 4\n```\n\nBasic operations are listed below:\n\nCreate\n\n```\n# Create migration pair files up/down_000001_$FILE_NAME.$FILE_EXTENSION in $FILE_DIR\nmigrate create -ext $FILE_EXTENSION -dir $FILE_DIR -seq $FILE_NAME \n```\n\nUp\n\n```\n# Upgrade to the latest version in migration directory\nmigrate -databsae $DATABASE_CONNECTION -path $MIGRATION_DIR up\n```\n\nDown (CAUTION)\n\n```\n# Remove all the existing versions change\nmigrate -database $DATABASE_CONNECTION -path $MIGRATION_DIR down\n```\n\nGoto\n\n```\n# Upgrade/Downgrade to the specific versions\nmigrate -database $DATABASE_CONNECTION -path $MIGRATION_DIR goto $VERSION\n```\n\nmore details in [FAQ](https://github.com/golang-migrate/migrate/blob/master/FAQ.md) and [godoc](https://godoc.org/github.com/mattes/migrate)(old repo)\n\n\n\n## Functional Testing\n### Prerequisite\n* Make sure the environment you run the test has a running `MySQL` server and `MongoDB` server\u003cbr/\u003e\n\n### How To Run Tests\n```\n// use Makefile\nmake test\n\n// or\n\ngo test $(glide novendor)\n\n// or print logs\ngo test -v $(glide novendor)\n```\n\n## API Document\nSee [https://twreporter.github.io/go-api/](https://twreporter.github.io/go-api/)\n\n## License\nGo-api is [MIT licensed](https://github.com/twreporter/go-api/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwreporter%2Fgo-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwreporter%2Fgo-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwreporter%2Fgo-api/lists"}