@energyweb/node-red-contrib-green-proof-worker
Version:
28 lines (27 loc) • 880 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.hostApi = void 0;
const tslib_1 = require("tslib");
const zod_1 = tslib_1.__importDefault(require("zod"));
exports.hostApi = {
async vote(payload) {
await fetch('http://localhost:3002/sse/1', {
method: 'POST',
body: JSON.stringify(payload),
headers: {
'User-Agent': 'ewx-marketplace',
'Content-Type': 'application/json',
}
});
},
getAuthToken: async () => {
const response = await fetch('http://localhost:3002/token', {
method: 'GET'
});
const body = await response.text();
return GetAuthTokenResponse.parse(JSON.parse(body)).token;
}
};
const GetAuthTokenResponse = zod_1.default.object({
token: zod_1.default.string().nullable()
});