@upstash/qstash
Advanced tools
Comparing version 0.0.0 to 0.0.2
import { HttpClient } from "./http.js"; | ||
import { Topics } from "./topic.js"; | ||
import { Endpoints } from "./endpoint.js"; | ||
import { Topics } from "./topics.js"; | ||
import { Messages } from "./messages.js"; | ||
import { Schedules } from "./schedules.js"; | ||
import { Endpoints } from "./endpoints.js"; | ||
export class Client { | ||
@@ -25,2 +27,8 @@ constructor(config) { | ||
} | ||
get messages() { | ||
return new Messages(this.http); | ||
} | ||
get schedules() { | ||
return new Schedules(this.http); | ||
} | ||
async publish(req) { | ||
@@ -35,2 +43,14 @@ const res = await this.http.request({ | ||
} | ||
async logs(req) { | ||
const query = {}; | ||
if (req?.cursor && req.cursor > 0) { | ||
query["cursor"] = req.cursor; | ||
} | ||
const res = await this.http.request({ | ||
path: ["v1", "logs"], | ||
method: "GET", | ||
query, | ||
}); | ||
return res; | ||
} | ||
} |
@@ -50,3 +50,3 @@ import { QstashError } from "./error.js"; | ||
const requestOptions = { | ||
method: "POST", | ||
method: req.method, | ||
headers, | ||
@@ -56,3 +56,10 @@ body: req.body, | ||
}; | ||
await fetch("https://qstash-debug.requestcatcher.com/test", requestOptions); | ||
const url = new URL([this.baseUrl, ...(req.path ?? [])].join("/")); | ||
if (req.query) { | ||
for (const [key, value] of Object.entries(req.query)) { | ||
if (typeof value !== "undefined") { | ||
url.searchParams.set(key, value.toString()); | ||
} | ||
} | ||
} | ||
let res = null; | ||
@@ -62,3 +69,3 @@ let error = null; | ||
try { | ||
res = await fetch([this.baseUrl, ...(req.path ?? [])].join("/"), requestOptions); | ||
res = await fetch(url.toString(), requestOptions); | ||
break; | ||
@@ -65,0 +72,0 @@ } |
@@ -6,3 +6,3 @@ { | ||
"name": "@upstash/qstash", | ||
"version": "v0.0.0", | ||
"version": "v0.0.2", | ||
"description": "Official Deno/Typescript client for qStash", | ||
@@ -9,0 +9,0 @@ "repository": { |
@@ -5,4 +5,6 @@ "use strict"; | ||
const http_js_1 = require("./http.js"); | ||
const topic_js_1 = require("./topic.js"); | ||
const endpoint_js_1 = require("./endpoint.js"); | ||
const topics_js_1 = require("./topics.js"); | ||
const messages_js_1 = require("./messages.js"); | ||
const schedules_js_1 = require("./schedules.js"); | ||
const endpoints_js_1 = require("./endpoints.js"); | ||
class Client { | ||
@@ -24,7 +26,13 @@ constructor(config) { | ||
get topics() { | ||
return new topic_js_1.Topics(this.http); | ||
return new topics_js_1.Topics(this.http); | ||
} | ||
get endpoints() { | ||
return new endpoint_js_1.Endpoints(this.http); | ||
return new endpoints_js_1.Endpoints(this.http); | ||
} | ||
get messages() { | ||
return new messages_js_1.Messages(this.http); | ||
} | ||
get schedules() { | ||
return new schedules_js_1.Schedules(this.http); | ||
} | ||
async publish(req) { | ||
@@ -39,3 +47,15 @@ const res = await this.http.request({ | ||
} | ||
async logs(req) { | ||
const query = {}; | ||
if (req?.cursor && req.cursor > 0) { | ||
query["cursor"] = req.cursor; | ||
} | ||
const res = await this.http.request({ | ||
path: ["v1", "logs"], | ||
method: "GET", | ||
query, | ||
}); | ||
return res; | ||
} | ||
} | ||
exports.Client = Client; |
@@ -53,3 +53,3 @@ "use strict"; | ||
const requestOptions = { | ||
method: "POST", | ||
method: req.method, | ||
headers, | ||
@@ -59,3 +59,10 @@ body: req.body, | ||
}; | ||
await fetch("https://qstash-debug.requestcatcher.com/test", requestOptions); | ||
const url = new URL([this.baseUrl, ...(req.path ?? [])].join("/")); | ||
if (req.query) { | ||
for (const [key, value] of Object.entries(req.query)) { | ||
if (typeof value !== "undefined") { | ||
url.searchParams.set(key, value.toString()); | ||
} | ||
} | ||
} | ||
let res = null; | ||
@@ -65,3 +72,3 @@ let error = null; | ||
try { | ||
res = await fetch([this.baseUrl, ...(req.path ?? [])].join("/"), requestOptions); | ||
res = await fetch(url.toString(), requestOptions); | ||
break; | ||
@@ -68,0 +75,0 @@ } |
import { Requester } from "./http.js"; | ||
import { Topics } from "./topic.js"; | ||
import { Endpoints } from "./endpoint.js"; | ||
import { Topics } from "./topics.js"; | ||
import { Messages } from "./messages.js"; | ||
import { Schedules } from "./schedules.js"; | ||
import { Endpoints } from "./endpoints.js"; | ||
import type { Log } from "./types.js"; | ||
export declare type ClientConfig = { | ||
@@ -110,2 +113,9 @@ /** | ||
}; | ||
export declare type LogsRequest = { | ||
cursor?: number; | ||
}; | ||
export declare type GetLogsRespone = { | ||
cursor?: number; | ||
logs: Log[]; | ||
}; | ||
export declare class Client { | ||
@@ -116,3 +126,6 @@ http: Requester; | ||
get endpoints(): Endpoints; | ||
get messages(): Messages; | ||
get schedules(): Schedules; | ||
publish<R extends PublishRequest = PublishRequest>(req: R): Promise<PublishResponse<R>>; | ||
logs(req?: LogsRequest): Promise<GetLogsRespone>; | ||
} | ||
@@ -119,0 +132,0 @@ declare type PublishResponse<PublishRequest> = PublishRequest extends { |
@@ -23,2 +23,3 @@ export declare type UpstashRequest = { | ||
method?: "GET" | "POST" | "PUT" | "DELETE"; | ||
query?: Record<string, string | number | boolean | undefined>; | ||
}; | ||
@@ -25,0 +26,0 @@ export declare type UpstashResponse<TResult> = TResult & { |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
37685
32
1290
4