Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make DEPLOY_API_ENDPOINT more configurable #166

Merged
merged 3 commits into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions action/deps.js
Original file line number Diff line number Diff line change
Expand Up @@ -3890,11 +3890,11 @@ class API {
this.#endpoint = endpoint;
}
static fromToken(token) {
const endpoint = Deno.env.get("DEPLOY_API_ENDPOINT") ?? "https://dash.deno.com";
const endpoint = Deno.env.get("DEPLOY_API_ENDPOINT") ?? "https://dash.deno.com/api";
return new API(`Bearer ${token}`, endpoint);
}
async #request(path2, opts = {}) {
const url = `${this.#endpoint}/api${path2}`;
const url = `${this.#endpoint}/${path2}`;
const method = opts.method ?? "GET";
const body = opts.body !== undefined ? opts.body instanceof FormData ? opts.body : JSON.stringify(opts.body) : undefined;
const headers = {
Expand Down
2 changes: 1 addition & 1 deletion action/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from "./deps.js";

// The origin of the server to make Deploy requests to.
const ORIGIN = process.env.DEPLOY_API_ENDPOINT ?? "https://dash.deno.com";
const ORIGIN = process.env.DEPLOY_API_ENDPOINT ?? "https://dash.deno.com/api";

async function main() {
const projectId = core.getInput("project", { required: true });
Expand Down
4 changes: 2 additions & 2 deletions src/utils/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ export class API {

static fromToken(token: string) {
const endpoint = Deno.env.get("DEPLOY_API_ENDPOINT") ??
"https://dash.deno.com";
"https://dash.deno.com/api";
return new API(`Bearer ${token}`, endpoint);
}

async #request(path: string, opts: RequestOptions = {}): Promise<Response> {
const url = `${this.#endpoint}/api${path}`;
const url = `${this.#endpoint}/${path}`;
const method = opts.method ?? "GET";
const body = opts.body !== undefined
? opts.body instanceof FormData ? opts.body : JSON.stringify(opts.body)
Expand Down
Loading