{"id":21359256,"url":"https://github.com/alesr/stdservices","last_synced_at":"2025-06-10T14:05:29.438Z","repository":{"id":51001750,"uuid":"520191588","full_name":"alesr/stdservices","owner":"alesr","description":"This is a collection of small services that I use in my side projects","archived":false,"fork":false,"pushed_at":"2024-03-14T22:05:37.000Z","size":156,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-16T06:26:47.321Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/alesr.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2022-08-01T16:53:09.000Z","updated_at":"2024-10-18T23:01:18.000Z","dependencies_parsed_at":"2024-06-21T11:58:10.220Z","dependency_job_id":"0096bf2c-09e0-43e6-983c-5f47902251f0","html_url":"https://github.com/alesr/stdservices","commit_stats":null,"previous_names":["alesr/services"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alesr%2Fstdservices","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alesr%2Fstdservices/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alesr%2Fstdservices/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alesr%2Fstdservices/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alesr","download_url":"https://codeload.github.com/alesr/stdservices/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alesr%2Fstdservices/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259088539,"owners_count":22803652,"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":[],"created_at":"2024-11-22T05:27:19.361Z","updated_at":"2025-06-10T14:05:29.400Z","avatar_url":"https://github.com/alesr.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stdservices\n![master](https://github.com/alesr/stdservices/actions/workflows/ci.yaml/badge.svg)\n\n\nThis is a collection of small services that I use in my side projects.\n\nThis set of services includes a Docker Compose file with a Postgres database and migrations for integration testing.\n\nIf you decide to use these services, you should use the database migrations as a reference for your project.\n\n\n```\n------------------------------------------------------------------------\nstdservices\n------------------------------------------------------------------------\ndb-down                        remove the test database container and its volumes\ndb                             spin up the test database\nlint                           run go format, vet and lint code\nmigrate                        execute the migrations towards the test database\npsql                           executes a psql command to connect to the test database\ntest-it                        run integration tests\ntest-unit                      run unit tests\ntest                           Run linter, unit and integration tests\n```\n\n## Testing\n\nSo far, this project has implemented unit, integration tests, and code linting.\n\nTo run unit tests, run `make test-unit`.\n\nIntegrations tests require connecting to a Postgres database and migrations found on the \"migrations\" folder.\n\nThe command `make test-integration` will spin up a Docker container with a Postgres database, execute the migrations, and run tests following the naming convention `TestIntegration...`. \n\nThe command `make test` runs the linter, which includes `go fmt`, `go vet` and `statickcheck`, unit tests, and integration tests.\n\nFinally, you can use the service mocks to unit test your application.\n\n---\n## users\n\n`import \"github.com/alesr/stdservices/users\"`\n\nThe user service implements a set of CRUD operations for users. It is used in conjunction with JWT authentication and includes\na repository layer for storing users in a database. A PostgreSQL implementation is provided for convenience.\n\n```go\ntype Service interface {\n\t// Create creates a new user and returns the created user with its ID and \"user\" role\n\tCreate(ctx context.Context, in CreateUserInput) (*User, error)\n\n\t// Delete soft deletes a user by id\n\tDelete(ctx context.Context, id string) error\n\n\t// FetchByID fetches a non-deleted user by id and returns the user\n\tFetchByID(ctx context.Context, id string) (*User, error)\n\n\t// GenerateToken generates a JWT token for the user\n\tGenerateToken(ctx context.Context, email, password string) (string, error)\n\n\t// VerifyToken verifies a JWT token and returns the user username, id and role\n\tVerifyToken(ctx context.Context, token string) (*VerifyTokenResponse, error)\n\n\t// SendEmailVerification sends an email verification to the user.\n\t// The user must be created before calling this method.\n\tSendEmailVerification(ctx context.Context, userID, username, to string) error\n}\n```\n\n### Upcoming features\n    - Edit user\n    - Password reset\n    - Complete email verification\n    - Feed service\n    - Profile service\n    ...\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falesr%2Fstdservices","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falesr%2Fstdservices","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falesr%2Fstdservices/lists"}