{"id":20752162,"url":"https://github.com/ynwd/serverless","last_synced_at":"2026-05-14T23:41:44.387Z","repository":{"id":122402931,"uuid":"369687706","full_name":"ynwd/serverless","owner":"ynwd","description":"Fastrex serverless webapp. Built on google cloud function.","archived":false,"fork":false,"pushed_at":"2021-08-21T07:09:01.000Z","size":1651,"stargazers_count":2,"open_issues_count":8,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-18T03:45:37.765Z","etag":null,"topics":["cloud-functions","cloudbuild","firebase","firestore","golang","secrets-manager","serverless"],"latest_commit_sha":null,"homepage":"","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/ynwd.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}},"created_at":"2021-05-22T01:08:49.000Z","updated_at":"2022-03-26T16:22:18.000Z","dependencies_parsed_at":"2024-02-01T04:45:47.804Z","dependency_job_id":"36a6c9e9-d15f-4925-b69d-df474709d2e6","html_url":"https://github.com/ynwd/serverless","commit_stats":null,"previous_names":["fastrodev/serverless"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ynwd%2Fserverless","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ynwd%2Fserverless/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ynwd%2Fserverless/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ynwd%2Fserverless/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ynwd","download_url":"https://codeload.github.com/ynwd/serverless/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243052771,"owners_count":20228455,"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":["cloud-functions","cloudbuild","firebase","firestore","golang","secrets-manager","serverless"],"created_at":"2024-11-17T08:40:03.774Z","updated_at":"2026-05-14T23:41:44.331Z","avatar_url":"https://github.com/ynwd.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Fastrex Serverless\n\nGoogle provides a very efficient serverless service. A function will serve if\nsomeone uses it and will iddle if no one is using it. You pay nothing when your\nfunction is idle. _So cheap, right?_\n\nWith [fastrex](https://github.com/fastrodev/fastrex) you can create golang based\nfullstack applications and install them in cloud functions. You can create\nmultiple routes, handle static files, and render html templates -- then\nassociate them with an entry point in the cloud function. The entry point is\nthen redirected to firebase hosting according to the domain and url you want.\n\nLive demo: [https://fastro-319406.web.app](https://fastro-319406.web.app/)\n\n## Getting start\n\nCreate serverless webapp folder: `serverless`\n\n```\nmkdir serverless \u0026\u0026 cd serverless\ngo mod init github.com/fastrodev/serverless\ngo get github.com/fastrodev/fastrex\n```\n\nYou can rename the module `github.com/fastrodev/serverless` to anything.\n\n## Create web application\n\ncreate an app folder: `internal`\n\n```\nmkdir internal\n```\n\ncreate a webapp file: `internal/app.go`\n\n```go\npackage internal\n\nimport \"github.com/fastrodev/fastrex\"\n\nfunc handler(req fastrex.Request, res fastrex.Response) {\n\tres.Json(`{\"message\":\"ok\"}`)\n}\n\nfunc CreateApp() fastrex.App {\n\tapp := fastrex.New()\n\tapp.Get(\"/\", handler)\n\treturn app\n}\n```\n\n\u003e _You can add new routes, handlers, templates and static files later. See the\n\u003e full source code at: [internal/app.go](internal/app.go)_\n\n## Localhost entrypoint\n\nTo test locally, you can create a localhost webapp entrypoint file:\n`cmd/main.go`\n\n```go\npackage main\n\nimport (\n\t\"github.com/fastrodev/serverless/internal\"\n)\n\nfunc main() {\n\tinternal.CreateApp().Listen(9000)\n}\n```\n\n\u003e _You can see the full source code at: [cmd/main.go](cmd/main.go)_\n\nYou can run by this command:\n\n```\ngo run cmd/main.go\n```\n\nor you can use [air live reload](https://github.com/cosmtrek/air)\n\n```\nair\n```\n\nYou can access it via url:\n\n```\nhttp://localhost:9000\n```\n\n## Serverless entrypoint\n\nTo see serverless endpoint, you must create a serverless webapp entrypoint file:\n`serverless.go`\n\n```go\npackage serverless\n\nimport (\n\t\"net/http\"\n\n\t\"github.com/fastrodev/serverless/internal\"\n)\n\nfunc Main(w http.ResponseWriter, r *http.Request) {\n  internal.CreateApp().Serverless(true).ServeHTTP(w, r)\n}\n```\n\n\u003e _You can see the full source code at: [serverless.go](serverless.go)_\n\n## Cloud function deployment\n\n\u003e _Prerequisite: [Cloud SDK](https://cloud.google.com/sdk/docs/quickstart)_\n\nTo see live serverless endpoint, you must deploy to google cloud function:\n\n```\ngcloud functions deploy Main --runtime go113 --trigger-http --allow-unauthenticated\n```\n\nLive demo:\n[https://us-central1-fastro-319406.cloudfunctions.net/Main](https://us-central1-fastro-319406.cloudfunctions.net/Main)\n\n## Firebase domain setup\n\nWe will redirect above url to firebase domain. You can change it with your own\nfrom firebase dashboard.\n\nInstall firebase:\n\n```\nnpm install -g firebase-tools\n```\n\nInit hosting files:\n\n```\nfirebase init hosting\n```\n\nRemove public folder:\n\n```\nrm -rf public\n```\n\nChange firebase config:\n\n```json\n{\n  \"hosting\": {\n    \"rewrites\": [\n      {\n        \"source\": \"**\",\n        \"function\": \"Main\"\n      }\n    ],\n    \"ignore\": [\n      \"**/cmd/**\",\n      \"**/internal/**\",\n      \"**/static/**\",\n      \"**/template/**\",\n      \".gitignore\",\n      \"cloudbuild.yaml\",\n      \"firebase.json\",\n      \"go.mod\",\n      \"go.sum\",\n      \"README.md\",\n      \"serverless.go\",\n      \"**/.*\"\n    ]\n  }\n}\n```\n\nDeploy to firebase:\n\n```\nfirebase deploy\n```\n\nLive demo: [https://fastro-319406.web.app](https://fastro-319406.web.app)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fynwd%2Fserverless","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fynwd%2Fserverless","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fynwd%2Fserverless/lists"}