Skip to content

Commit

Permalink
Merge pull request #84 from tago-io/TCORE-255_Fix_Taogio_Intgration
Browse files Browse the repository at this point in the history
Changes to use new SDK
  • Loading branch information
felipefdl authored Dec 3, 2024
2 parents e5d75f4 + 41cfdbc commit cf9504a
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 36 deletions.
3 changes: 2 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ install:

# The process.env is not working on Vite Build
# This is a workaround to make it work
file_path := "./node_modules/@tago-io/sdk/out/regions.js"
file_path := "./node_modules/@tago-io/sdk/lib/regions.js"
_pre-build:
@sed -i'' -e 's/ process\.env\.TAGOIO_API/ window.process.env.TAGOIO_API/g' "{{file_path}}"
@sed -i'' -e 's/ process\.env\.TAGOIO_REALTIME/ window.process.env.TAGOIO_REALTIME/g' "{{file_path}}"
@sed -i'' -e 's/ process\.env\.TAGOIO_SSE/ window.process.env.TAGOIO_SSE/g' "{{file_path}}"
@echo "SDK patched"
149 changes: 118 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"url": "git+https://github.com/tago-io/tcore.git"
},
"dependencies": {
"@tago-io/sdk": "10.4.4",
"@tago-io/sdk": "11.3.6",
"async": "3.2.6",
"axios": "0.26.0",
"body-parser": "2.0.1",
Expand Down
3 changes: 2 additions & 1 deletion plugins/tagoio-integration/src/back/RealtimeConnection.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os from "node:os";
import { URLSearchParams } from "node:url";
import * as getConnectionURI from "@tago-io/sdk/lib/regions.js";
import { core, helpers, pluginStorage } from "@tago-io/tcore-sdk";
import EventSource from "eventsource";
import removeNullValues from "../../../../packages/sdk/src/Types/Helpers/removeNullValues.ts";
Expand All @@ -22,7 +23,7 @@ function startRealtimeCommunication(token: string) {

const channel = "commands";
const params = new URLSearchParams({ token, channel });
const url = `${process.env.TAGOIO_SSE}/events?${params.toString()}`;
const url = `${getConnectionURI.default.default("usa-1").sse}?${params.toString()}`;

const connect = () => {
events = new EventSource(url);
Expand Down
5 changes: 3 additions & 2 deletions plugins/tagoio-integration/src/back/Request.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import * as getConnectionURI from "@tago-io/sdk/lib/regions.js";
import axios from "axios";

/**
Expand All @@ -6,7 +7,7 @@ import axios from "axios";
async function createTCore(token: string, data: any) {
try {
const response = await axios({
url: `${process.env.TAGOIO_API}/tcore/instance`,
url: `${getConnectionURI.default.default("usa-1").api}/tcore/instance`,
method: "POST",
headers: { token },
data,
Expand All @@ -28,7 +29,7 @@ async function sendDataToTagoio(
) {
try {
const response = await axios({
url: `${process.env.TAGOIO_API}/tcore/sse/${connId}`,
url: `${getConnectionURI.default.default("usa-1").api}/tcore/sse/${connId}`,
method: "POST",
headers: { token },
data: {
Expand Down

0 comments on commit cf9504a

Please sign in to comment.