{"id":13634657,"url":"https://github.com/voltbras/ts-ocpp","last_synced_at":"2025-04-18T23:32:37.484Z","repository":{"id":40401292,"uuid":"303548971","full_name":"voltbras/ts-ocpp","owner":"voltbras","description":":zap: OCPP (Open Charge Point Protocol) implemented in Typescript.","archived":false,"fork":false,"pushed_at":"2024-09-16T19:29:46.000Z","size":285,"stargazers_count":43,"open_issues_count":12,"forks_count":25,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-11-02T03:03:41.654Z","etag":null,"topics":["chargepoint","electric-vehicles","functional-programming","ocpp","typescript"],"latest_commit_sha":null,"homepage":"https://voltbras.github.io/ts-ocpp","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/voltbras.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-13T00:50:34.000Z","updated_at":"2024-09-16T19:29:47.000Z","dependencies_parsed_at":"2024-05-18T03:28:29.409Z","dependency_job_id":"fd05f927-d316-474e-babd-7626bde1f0ba","html_url":"https://github.com/voltbras/ts-ocpp","commit_stats":{"total_commits":124,"total_committers":10,"mean_commits":12.4,"dds":0.3306451612903226,"last_synced_commit":"49c9a40f14e2e02b27a72801878bed8cf15abd80"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voltbras%2Fts-ocpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voltbras%2Fts-ocpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voltbras%2Fts-ocpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voltbras%2Fts-ocpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/voltbras","download_url":"https://codeload.github.com/voltbras/ts-ocpp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223786390,"owners_count":17202581,"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":["chargepoint","electric-vehicles","functional-programming","ocpp","typescript"],"created_at":"2024-08-02T00:00:28.924Z","updated_at":"2024-11-09T04:30:57.017Z","avatar_url":"https://github.com/voltbras.png","language":"TypeScript","funding_links":[],"categories":["Tools and Resources"],"sub_categories":["OCPP"],"readme":"# ts-ocpp\n\n:zap: OCPP (Open Charge Point Protocol) implemented in Typescript. Supports OCPP-JSON v1.6 and OCPP-SOAP v1.5.\n\n## install\n\n```bash\nyarn add @voltbras/ts-ocpp\n# OR\nnpm install @voltbras/ts-ocpp --save\n```\n\n## instruction\n\n### central system\n\ndefining a central system that accepts OCPP requests:\n\n```typescript\n// port and request handler as arguments\nconst centralSystem = new CentralSystem(3000, (req, { chargePointId }) =\u003e {\n  switch (req.action) {\n    case 'Heartbeat':\n      // returns a successful response\n      // (we pass the action and ocpp version so typescript knows which fields are needed)\n      return {\n        action: req.action,\n        ocppVersion: req.ocppVersion,\n        currentTime: new Date().toISOString()\n      };\n  }\n  throw new Error('message not supported');\n});\n```\n\nsending a request to the chargepoint \"123\":\n\n```typescript\n// Returns a Either(Error or Success) object(functional, will not throw on error)\nconst response = await centralSystem.sendRequest({ chargePointId: '123', ocppVersion: 'v1.6-json', action: 'GetConfiguration', payload: {} });\n// it can be used in a functional way\nresponse.map(({ configurationKey }) =\u003e configurationKey[0].key);\n// or can be used in the standard JS way(will throw if there was an error)\nconst unsafeResponse = response.unsafeCoerce();\n```\n\n### chargepoint\n\ndefining a chargepoint that accepts OCPP requests:\n\n```typescript\n// port, request handler and central system URL as arguments\nconst chargepoint = new ChargePoint(3001, req =\u003e {\n  switch (action) {\n    case 'GetConfiguration':\n      // returns a successful response\n      // (we pass the action and ocpp version so typescript knows which fields are needed)\n      return {\n        action: req.action,\n        ocppVersion: req.ocppVersion,\n        configurationKey: [],\n      };\n  }\n  throw new Error('message not supported');\n});\n```\n\nsending a request to the central system(see central system's section to understand the return type):\n```typescript\nconst response = await chargepoint.sendRequest({ action: 'Heartbeat', ocppVersion: '1.6-json', payload: {} );\n```\n\n### troubleshooting\n\nSet the environment variable `DEBUG` to `ts-ocpp:*` to enable troubleshooting.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoltbras%2Fts-ocpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvoltbras%2Fts-ocpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoltbras%2Fts-ocpp/lists"}