{"id":16715114,"url":"https://github.com/dean177/hypernova-go","last_synced_at":"2025-03-15T08:12:36.921Z","repository":{"id":79229242,"uuid":"124744758","full_name":"Dean177/hypernova-go","owner":"Dean177","description":"A Go client for Hypernova","archived":false,"fork":false,"pushed_at":"2018-03-11T10:18:14.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-21T23:11:22.432Z","etag":null,"topics":["go","golang","hypernova","react"],"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/Dean177.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":"2018-03-11T10:16:38.000Z","updated_at":"2019-08-12T16:16:33.000Z","dependencies_parsed_at":"2023-04-19T04:01:31.512Z","dependency_job_id":null,"html_url":"https://github.com/Dean177/hypernova-go","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dean177%2Fhypernova-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dean177%2Fhypernova-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dean177%2Fhypernova-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dean177%2Fhypernova-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dean177","download_url":"https://codeload.github.com/Dean177/hypernova-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243701467,"owners_count":20333631,"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":["go","golang","hypernova","react"],"created_at":"2024-10-12T21:08:24.984Z","updated_at":"2025-03-15T08:12:36.913Z","avatar_url":"https://github.com/Dean177.png","language":"Go","readme":"# hypernova-client\n\n\u003e A Go client for Hypernova\n\n## Getting Started\n\n`go get github.com/dean177/hypernova-go`\n\n## Example usage\n\n```go\npackage main\n\nimport (\n\t\"github.com/dean177/hypernova-go\"\n\t\"log\"\n\t\"net/http\"\n)\n\nfunc main() {\n\trenderer := hypernova_go.Renderer{\n\t\tUrl: \"http://localhost:3030/batch\",\n\t\tPlugins: []hypernova_go.Plugin{hypernova_go.DevPlugin{}},\n\t}\n\n\thttp.HandleFunc(\"/\", func(writer http.ResponseWriter, request *http.Request) {\n\t\twriter.Header().Set(\"Content-Type\", \"text/html\")\n\n\t\thtml, err := renderer.Render(hypernova_go.Jobs{\n\t\t\t\"MyComponent.js\": {\n\t\t\t\tName: \"MyComponent.js\",\n\t\t\t\tData: map[string]interface{}{ \"name\": \"strange\" },\n\t\t\t},\n\t\t\t\"Component2.js\": {\n\t\t\t\tName: \"Component2.js\",\n\t\t\t\tData: map[string]interface{}{ \"text\": \"Hi!\" },\n\t\t\t},\n\t\t})\n\n\t\tif err != nil {\t\t\t\n\t\t\twriter.WriteHeader(http.StatusInternalServerError)\n\t\t\twriter.Write([]byte(\"500\"))\n\t\t} else {\n\t\t\twriter.WriteHeader(http.StatusOK)\n\t\t\twriter.Write([]byte(`\n\t\t\t\t\u003c!DOCTYPE html\u003e\n\t\t\t\t\u003chtml\u003e\n\t\t\t\t\u003cbody\u003e\n\t\t\t\t\t\u003ch1\u003eHi\u003c/h1\u003e\n\t\t\t`))\n\t\t\twriter.Write([]byte(html))\n\t\t\twriter.Write([]byte(`\t\t\n\t\t\t\t\u003c/body\u003e\n\t\t\t\t\u003c/html\u003e\n\t\t\t`))\n\t\t}\n\t})\n\n\tlog.Print(\"Listening\")\n\tlog.Fatal(http.ListenAndServe(\":8080\", nil))\n}\n```\n\n## Plugin API\n\nHypernova enables you to control and alter requests at different stages of the render lifecycle via a plugin system.\n\n### `getViewData`\n\n```go\ntype ReactProps interface {}\ngetViewData(name string, data ReactProps) ReactProps\n```\n\nAllows you to alter the data that a \"view\" will receive.\n\n### `prepareRequest`\n\n```go\ntype Job struct {\n\tName string\n\tData ReactProps `json:\"data\"`\n}\n\ntype Jobs map[string]Job\nprepareRequest(jobs Jobs) Jobs\n```\n\nThis function is called when preparing the request to Hypernova and receives the current running jobs Object.\n\n### `shouldSendRequest`\n\n```go\nshouldSendRequest(jobs Jobs) bool\n```\nIf `false` is returned then the request is canceled and falls back to client rendering.\n\n\nAn `every` type function. If one returns `false` then the request is canceled.\n\n### `willSendRequest`\n\n```go\nwillSendRequest(jobs: Jobs): void {}\n```\n\nAn event type function that is called prior to a request being sent.\n\n### `afterResponse`\n\n```go\ntype JobResponse struct {\n\tError      JobError \t\n\tHtml       string   \n\tDuration   float32  \n\tStatusCode int      \n\tSuccess    bool    \n}\n\ntype HypernovaResponse struct {\n\tSuccess bool                 \n\tError   string                 \n\tResults map[string]JobResponse \n}\n\nafterResponse(currentResponse HypernovaResponse, originalResponse HypernovaResponse) HypernovaResponse\n```\n\nA reducer type function which receives the current response and the original response from the\nHypernova service.\n\n### `onSuccess`\n\n```go\nonSuccess(resp HypernovaResponse, jobs Jobs)\n```\n\nAn event type function that is called whenever a request was successful.\n\n### `onSuccess`\n\n```go\nonError(err error, jobs Jobs)\n```\n\nAn event type function that is called whenever any error is encountered.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdean177%2Fhypernova-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdean177%2Fhypernova-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdean177%2Fhypernova-go/lists"}