{"id":13837003,"url":"https://github.com/nmerouze/selfjs","last_synced_at":"2025-03-22T18:33:28.385Z","repository":{"id":33963226,"uuid":"37696856","full_name":"nmerouze/selfjs","owner":"nmerouze","description":"Self.js: Self-contained web server running Javascript Universal applications.","archived":false,"fork":false,"pushed_at":"2016-03-01T08:24:27.000Z","size":10,"stargazers_count":56,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-10-14T19:43:02.679Z","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":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nmerouze.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}},"created_at":"2015-06-19T02:19:37.000Z","updated_at":"2021-03-29T00:27:35.000Z","dependencies_parsed_at":"2022-08-31T19:22:49.363Z","dependency_job_id":null,"html_url":"https://github.com/nmerouze/selfjs","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/nmerouze%2Fselfjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmerouze%2Fselfjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmerouze%2Fselfjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nmerouze%2Fselfjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nmerouze","download_url":"https://codeload.github.com/nmerouze/selfjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221832300,"owners_count":16888209,"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-08-04T15:00:59.002Z","updated_at":"2024-10-28T13:32:13.703Z","avatar_url":"https://github.com/nmerouze.png","language":"Go","funding_links":[],"categories":["Go"],"sub_categories":[],"readme":"# Self.js [![GoDoc](https://godoc.org/github.com/nmerouze/selfjs?status.png)](https://godoc.org/github.com/nmerouze/selfjs)\n\nWrapper around [v8worker](https://github.com/ry/v8worker) and `net/http`. Run Universal React applications faster than Node.js.\n\n# Setup\n\nFirst you need to install [v8worker](https://github.com/ry/v8worker). Then:\n\n```\ngo get -u github.com/nmerouze/selfjs\n```\n\n# Usage\n\n``` go\nimport (\n  \"io/ioutil\"\n  \"net/http\"\n  \"runtime\"\n\n  \"github.com/nmerouze/selfjs\"\n)\n\nfunc main() {\n  runtime.GOMAXPROCS(runtime.NumCPU())\n\n  js, _ := ioutil.ReadFile(\"path/to/file.js\")\n  http.Handle(\"/\", selfjs.New(runtime.NumCPU(), `\n    selfjs.handleRequest = function(req, res) {\n      res.write('Hello World!');\n    }\n  `))\n  http.ListenAndServe(\":8080\", nil)\n}\n```\n\n# Example\n\n```\ncd example\nnpm install\nnpm run build\ngo run server.go\nopen http://localhost:8080\n```\n\nThe application is rendered on the server. Both the client and the server share the same file (universal.js) with a few conditions to select the right rendering function. The code also runs on Node.js, just run `node server.js`. Self.js is 50% than Node.js while Node.js consumes 50% memory.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnmerouze%2Fselfjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnmerouze%2Fselfjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnmerouze%2Fselfjs/lists"}