{"id":18084545,"url":"https://github.com/endel/thrift.js","last_synced_at":"2025-06-15T19:37:04.653Z","repository":{"id":137835493,"uuid":"60856520","full_name":"endel/thrift.js","owner":"endel","description":"Apache Thrift module for the browser. Only compatible with this patch: https://github.com/endel/thrift/commit/32357443b5bfb5663ef3c45036c1680c08d04953","archived":false,"fork":false,"pushed_at":"2016-06-27T14:54:10.000Z","size":57,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-12T06:21:16.353Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/endel.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":"2016-06-10T15:08:13.000Z","updated_at":"2016-06-10T15:08:54.000Z","dependencies_parsed_at":"2023-05-02T17:16:17.201Z","dependency_job_id":null,"html_url":"https://github.com/endel/thrift.js","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/endel%2Fthrift.js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/endel%2Fthrift.js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/endel%2Fthrift.js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/endel%2Fthrift.js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/endel","download_url":"https://codeload.github.com/endel/thrift.js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247415973,"owners_count":20935387,"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-10-31T15:07:08.034Z","updated_at":"2025-04-06T00:11:28.407Z","avatar_url":"https://github.com/endel.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Thrift Javascript Library\n=========================\nThis browser based Apache Thrift implementation supports\nRPC clients using the JSON protocol over Http[s] with XHR\nand WebSocket.\n\nLicense\n-------\nLicensed to the Apache Software Foundation (ASF) under one\nor more contributor license agreements. See the NOTICE file\ndistributed with this work for additional information\nregarding copyright ownership. The ASF licenses this file\nto you under the Apache License, Version 2.0 (the\n\"License\"); you may not use this file except in compliance\nwith the License. You may obtain a copy of the License at\n\n  http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing,\nsoftware distributed under the License is distributed on an\n\"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\nKIND, either express or implied. See the License for the\nspecific language governing permissions and limitations\nunder the License.\n\nGrunt Build\n------------\nThis is the base directory for the Apache Thrift JavaScript\nlibrary. This directory contains a Gruntfile.js and a\npackage.json. Many of the build and test tools used here\nrequire a recent version of Node.js to be installed. To \ninstall the support files for the Grunt build tool execute\nthe command:\n\n    npm install\n    \nThis reads the package.json and pulls in the appropriate\nsources from the internet. To build the JavaScript branch\nof Apache Thrift execute the command:\n\n    grunt\n    \nThis runs the grunt build tool, linting all of the source\nfiles, setting up and running the tests, concatenating and\nminifying the main libraries and generating the html \ndocumentation.\n\nIf grunt is not installed you can install it with npm\nlike this:\n\n   sudo npm install -g grunt-cli\n   npm install grunt --save-dev\n\n\nTree\n----\nThe following directories are present (some only after the\ngrunt build):\n  /src  - The JavaScript Apache Thrift source\n  /doc  - HTML documentation\n  /dist - Distribution files (thrift.js and thrift.min.js)\n  /test - Various tests, this is a good place to look for\n          example code\n  /node_modules - Build support files installed by npm\n\n\nExample JavaScript Client and Server\n------------------------------------\nThe listing below demonstrates a simple browser based JavaScript\nThrift client and Node.js JavaScript server for the hello_svc \nservice. \n\n### hello.thrift - Service IDL \n### build with: $ thrift -gen js -gen js:node hello.thrift\n    service hello_svc {\n      string get_message(1: string name)\n    }\n\n### hello.html - Browser Client\n    \u003c!DOCTYPE html\u003e\n    \u003chtml lang=\"en\"\u003e\n      \u003chead\u003e\n        \u003cmeta charset=\"utf-8\"\u003e\n        \u003ctitle\u003eHello Thrift\u003c/title\u003e\n      \u003c/head\u003e\n      \u003cbody\u003e\n        Name: \u003cinput type=\"text\" id=\"name_in\"\u003e\n        \u003cinput type=\"button\" id=\"get_msg\" value=\"Get Message\" \u003e\n        \u003cdiv id=\"output\"\u003e\u003c/div\u003e\n  \n        \u003cscript src=\"thrift.js\"\u003e\u003c/script\u003e\n        \u003cscript src=\"gen-js/hello_svc.js\"\u003e\u003c/script\u003e\n        \u003cscript\u003e\n          (function() {\n            var transport = new Thrift.TXHRTransport(\"/hello\");\n            var protocol  = new Thrift.TJSONProtocol(transport);\n            var client    = new hello_svcClient(protocol);\n            var nameElement = document.getElementById(\"name_in\");\n            var outputElement = document.getElementById(\"output\");\n            document.getElementById(\"get_msg\")\n              .addEventListener(\"click\", function(){\n                client.get_message(nameElement.value, function(result) {\n                  outputElement.innerHTML = result;\n                });\n              });\n          })();\n        \u003c/script\u003e\n      \u003c/body\u003e\n    \u003c/html\u003e\n\n### hello.js - Node Server\n    var thrift = require('thrift');\n    var hello_svc = require('./gen-nodejs/hello_svc.js');\n    \n    var hello_handler = {\n      get_message: function(name, result) {\n        var msg = \"Hello \" + name + \"!\";\n        result(null, msg);\n      }\n    }\n    \n    var hello_svc_opt = {\n      transport: thrift.TBufferedTransport,\n      protocol: thrift.TJSONProtocol,\n      processor: hello_svc,\n      handler: hello_handler\n    };\n    \n    var server_opt = {\n      staticFilePath: \".\",\n      services: {\n        \"/hello\": hello_svc_opt\n      }\n    }\n    \n    var server = Thrift.createWebServer(server_opt);\n    var port = 9099;\n    server.listen(port);\n    console.log(\"Http/Thrift Server running on port: \" + port);\n\n\nTypeScript\n------------------------------------\nTypeScript definition files can also be generated by running:\n\n    thrift --gen js:ts file.thrift\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fendel%2Fthrift.js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fendel%2Fthrift.js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fendel%2Fthrift.js/lists"}