{"id":34172618,"url":"https://github.com/psavelis/goa-pos-poc","last_synced_at":"2026-05-01T20:31:34.971Z","repository":{"id":144549450,"uuid":"109617956","full_name":"psavelis/goa-pos-poc","owner":"psavelis","description":"Design-first POC using GOA","archived":false,"fork":false,"pushed_at":"2018-02-14T19:29:17.000Z","size":8219,"stargazers_count":2,"open_issues_count":3,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-18T09:17:42.791Z","etag":null,"topics":["go","goa","golang","mgo","microservice","mongodb","openapi","openapi-specification","poc","pos","pubsub","rest","swagger"],"latest_commit_sha":null,"homepage":"https://psavelis.github.io/goa-pos-poc/","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/psavelis.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-11-05T21:29:23.000Z","updated_at":"2023-04-15T19:54:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"78e3a4a6-ef28-4463-9c8b-f2694eccc1c3","html_url":"https://github.com/psavelis/goa-pos-poc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/psavelis/goa-pos-poc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psavelis%2Fgoa-pos-poc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psavelis%2Fgoa-pos-poc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psavelis%2Fgoa-pos-poc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psavelis%2Fgoa-pos-poc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/psavelis","download_url":"https://codeload.github.com/psavelis/goa-pos-poc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/psavelis%2Fgoa-pos-poc/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32512662,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"online","status_checked_at":"2026-05-01T02:00:05.856Z","response_time":64,"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":["go","goa","golang","mgo","microservice","mongodb","openapi","openapi-specification","poc","pos","pubsub","rest","swagger"],"created_at":"2025-12-15T11:59:59.074Z","updated_at":"2026-05-01T20:31:34.963Z","avatar_url":"https://github.com/psavelis.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Point Of Sale (POS) POC\n[![Heroku](https://heroku-badge.herokuapp.com/?app=psavelis\u0026root=ui\u0026svg=1)](https://psavelis.herokuapp.com/pos/v1/purchases/5a07c7c3f44ead00043e5f96)\n[![Swagger](https://img.shields.io/swagger/valid/2.0/https/raw.githubusercontent.com/psavelis/goa-pos-poc/master/public/swagger/swagger.json.svg)](https://raw.githubusercontent.com/psavelis/goa-pos-poc/master/public/swagger/swagger.json)\n[![Golang](https://img.shields.io/badge/language-go-blue.svg)](https://img.shields.io/badge/language-go-blue.svg)\n[![MongoDB](https://img.shields.io/badge/dbengine-mongodb%203.2-yellow.svg)](https://img.shields.io/badge/dbengine-mongodb%203.2-yellow.svg)\n\n---\nGolang design-based REST API built with [Goa](https://goa.design/).\n\n## Instructions:\n```\n$ dep ensure    // restore packages\n$ go build      // build\n$ goa-pos-poc   // start app...\n```\n\n## Design-first code generation\nNow that the design is done, let's run `goagen` on the design package:\n```\ncd $GOPATH/src/goa-poc-pos\ngoagen bootstrap -d goa-poc-pos/design\n```\n\n\n## Example: Creating a new `Purchase` resource (POST)\nBy sending a `POST` request to `/purchases` prior to create a new resource of type `Purchase`, a controller-bound function ``Create `` is assigned to handle this request. Please find below an example of a few operations available using *Context's HTTP pre-defined responses*, *Mgo* (a MongoDB driver) and *error logging* within a [Goa](https://goa.design/) controller implementation.\n\n````go\n// Create runs the create action.\nfunc (c *PurchaseController) Create(ctx *app.CreatePurchaseContext) error {\n\n\tnewID := bson.NewObjectId()\n\n\tctx.Payload.ID = \u0026newID\n\n\t// reuse from connection pool\n\tsession := Database.Session.Copy()\n\tdefer session.Close()\n\n\t// inserts the document into Purchase collection\n\terr := session.DB(\"services-pos\").C(\"Purchase\").Insert(ctx.Payload)\n\n\tif err != nil {\n\t\n\t\t// duplicated record?\n\t\tif mgo.IsDup(err) {\n\t\t\n\t\t\t// Then this purchase already exists. (HTTP 409 - Conflict)\n\t\t\treturn ctx.Conflict()\n\t\t}\n\t\t\n\t\t// Ok, there is an error, log it ftw...\n\t\tService.LogError(err.Error())\n\n\t\t// HTTP 500 - Internal Server Error\n\t\treturn ctx.Err()\n\t}\n\n\t// indicates the new URI for the new resource (e.g. /purchases/{:id})\n    ctx.ResponseData.Header().Set(\"Location\", app.PurchaseHref(newID.Hex()))\n\n\t// HTTP 201 - Created\n\treturn ctx.Created()\n}\n````\n\n### Note:\nSince `Purchase` payload type has been defined on the api design at the very begining, field validation was automatically generated preventing the forwarding-request to be processed by a controller until all defined constraints matches the input.\nPlease find below:\n\n## Auto-generated payload/media type validation:\nFormat, size, mandatory fields and even pattern checks are performed without getting swet: \n````go\n// Code generated by goagen v1.3.0, DO NOT EDIT.\n//\n// Validate validates the Purchase media type instance.\nfunc (mt *Purchase) Validate() (err error) {\n\tif mt.TransactionID == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"transaction_id\"))\n\t}\n\tif mt.Locator == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"locator\"))\n\t}\n\n\tif mt.Href == \"\" {\n\t\terr = goa.MergeErrors(err, goa.MissingAttributeError(`response`, \"href\"))\n\t}\n\tif utf8.RuneCountInString(mt.Locator) \u003c 1 {\n\t\terr = goa.MergeErrors(err, goa.InvalidLengthError(`response.locator`, mt.Locator, utf8.RuneCountInString(mt.Locator), 1, true))\n\t}\n\tif utf8.RuneCountInString(mt.Locator) \u003e 30 {\n\t\terr = goa.MergeErrors(err, goa.InvalidLengthError(`response.locator`, mt.Locator, utf8.RuneCountInString(mt.Locator), 30, false))\n\t}\n\tif mt.PurchaseValue \u003c 0.010000 {\n\t\terr = goa.MergeErrors(err, goa.InvalidRangeError(`response.purchase_value`, mt.PurchaseValue, 0.010000, true))\n\t}\n\tif ok := goa.ValidatePattern(`^[0-9a-fA-F]{24}$`, mt.TransactionID); !ok {\n\t\terr = goa.MergeErrors(err, goa.InvalidPatternError(`response.transaction_id`, mt.TransactionID, `^[0-9a-fA-F]{24}$`))\n\t}\n\treturn\n}\n\n\n````\nInconsistencies found in the ongoing request may be sent back to the initiator with a HTTP.400 status code and a auto-generated well readable description a `how to fix it` instruction in the response body.\n\n````json\n{\n\t\"id\": \"xuykdHvt\",\n\t\"code\": \"bad_request\",\n\t\"status\": 400,\n\t\"detail\": \"[Jfhx633K] 400 invalid_request: length of request.locator must be greater than or equal to 1 but got value \\\"\\\" (len=0)\"\n}\n````\n\n## Heroku's application log: server request info\n`2017-11-12T20:31:57.888292+00:00 app[web.1]: 2017/11/12 20:31:57 [INFO] started req_id=0f89abd1-20f2-44c2-92b5-df4c6f2343d7 POST=/pos/v1/purchases/ from=201.6.135.39 ctrl=PurchaseController action=create`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsavelis%2Fgoa-pos-poc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpsavelis%2Fgoa-pos-poc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpsavelis%2Fgoa-pos-poc/lists"}