{"id":15322780,"url":"https://github.com/msfidelis/topper","last_synced_at":"2025-04-15T02:37:24.949Z","repository":{"id":32438082,"uuid":"133595602","full_name":"msfidelis/topper","owner":"msfidelis","description":"Lightweight Node.js framework to build fast microservices on TCP Servers. :electric_plug: :zap: :battery:","archived":false,"fork":false,"pushed_at":"2022-12-02T03:41:41.000Z","size":144,"stargazers_count":6,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-26T04:43:52.829Z","etag":null,"topics":["framework","microseconds","microservices","net","nodejs","scale","socket","tcp","tcp-server"],"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/msfidelis.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}},"created_at":"2018-05-16T01:54:19.000Z","updated_at":"2024-01-24T15:30:35.000Z","dependencies_parsed_at":"2023-01-14T21:13:24.770Z","dependency_job_id":null,"html_url":"https://github.com/msfidelis/topper","commit_stats":null,"previous_names":["msfidelis/yeap"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msfidelis%2Ftopper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msfidelis%2Ftopper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msfidelis%2Ftopper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msfidelis%2Ftopper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msfidelis","download_url":"https://codeload.github.com/msfidelis/topper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248995107,"owners_count":21195497,"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":["framework","microseconds","microservices","net","nodejs","scale","socket","tcp","tcp-server"],"created_at":"2024-10-01T09:17:57.670Z","updated_at":"2025-04-15T02:37:24.924Z","avatar_url":"https://github.com/msfidelis.png","language":"JavaScript","readme":"\n# Architecture Benchmark\n\n### Benchmark Tool\n\nBenchmark Tool: [Autocannon HTTP/1.1 benchmarking tool](https://github.com/mcollina/autocannon)\n\n```bash\nautocannon -c 20 -a 5000  -m POST --body '{\"numbers\": [1, 2, 3, 4, 5, 6, 7, 8, 9]}' --headers 'Content-Type:Application/json' http://localhost:9000/sum\n```\n\n### REST to REST \n\n* Express API Endpoint --\u003e Express REST Microservice\n\n```\nStat         Avg    Stdev Max\nLatency (ms) 76.52  22.53 234.85\nReq/Sec      250    50.99 320\nBytes/Sec    112 kB 23 kB 144 kB\n\n5k requests in 20s, 2.25 MB read\n```\n\n### REST to Topper\n\n* Express API Endpoint --\u003e Topper TCP Microservice\n\n```\nStat         Avg    Stdev  Max\nLatency (ms) 24.16  6.4    98.45\nReq/Sec      714.29 244.42 919\nBytes/Sec    312 kB 107 kB 402 kB\n\n5k requests in 7s, 2.19 MB read\n```\n\n# Installation\n\n```bash\nnpm install topper\n```\n\n## Create a simple TCP Microservice\n\n* Write a simple functions to receive an TCP Payload, and a server socket context and register on a Topper Server instance.\n\n```javascript\n\nconst { Server } = require('topper');\nconst server = new Server('0.0.0.0', 4000);\n\nconst task = async (data, socket) =\u003e {\n    console.log(`New message!`);\n    await socket.write(`Message payload: ${data}`);\n}\n\nserver.task(task);\n\n```\n\n### Client Console\n\n```bash\nnc localhost 4000\nˆ\nverything is connected, Todd...\nMessage payload: verything is connected, Todd...\n```\n\n### Server console output\n\n```bash\nnode app.js\nNew task registered on tcp://localhost:4000\nNew message!\n```\n\n## Send an JSON message to your TCP Microservice \n\n* Write a function to receive an JSON string and execute some actions with payload\n\n```javascript\nconst { Server } = require('topper');\nconst server = new Server('0.0.0.0', 4000);\n\nconst task = async (data, socket) =\u003e {\n    socket.write(`hello, my name is ${data.name} and i'm ${data.age} old\\n`);\n}\n\nserver.task(task);\n\n```\n\n```bash\nnc localhost 4000\n{\"name\": \"Matheus Fidelis\", \"age\":22}\nhello, my name is Matheus Fidelis and i'm 22 old\n```\n\n\n## Create a Multi Task Microservice\n\nCreate some arrays with task definitions and register on your server\n\n```javascript\nconst { Server } = require('./');\nconst server = new Server('0.0.0.0', 4000);\n\n\nconst tasks = [\n    {\n        name: 'Ping',\n        task: async (data, socket) =\u003e await socket.write('Pong\\n')\n    },\n    {\n        name: 'Sum',\n        task: async (data, socket) =\u003e {\n            let sum = data.numbers.reduce((prev, curr) =\u003e prev + curr);\n            await socket.write(`The sum is: ${sum} \\n`);\n        }\n    }\n]\n\nserver.multiTask(tasks);\n```\n\n### Client console\n\n```bash\necho 'Sum {\"numbers\": [1, 2, 3, 4, 5]}' | nc localhost 4000\n```\n\n```bash\necho 'Ping' | nc localhost 4000\n```\n\nOutput:\n\n```\nThe sum is: 15\n```\n\n```\nPong\n```\n\n## Create a simple client\n\n```javascript\nconst { Client } = require('topper');\nconst client = new Client();\n\nclient.addServer('0.0.0.0', 4000);\n\nclient.send('Sum', {numbers: [1,2]})\n    .then(success =\u003e console.log(success.toString()));\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsfidelis%2Ftopper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsfidelis%2Ftopper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsfidelis%2Ftopper/lists"}