UNPKG

arangojs

Version:

The official ArangoDB JavaScript driver.

285 lines 10.9 kB
/// <reference types="node" resolution-mode="require"/> /// <reference types="node" resolution-mode="require"/> /** * ```ts * import type { Route } from "arangojs/routes"; * ``` * * The "routes" module provides route related types and interfaces for * TypeScript. * * @packageDocumentation */ import * as connections from "./connection.js"; import * as databases from "./databases.js"; /** * Represents an arbitrary route relative to an ArangoDB database. */ export declare class Route { protected _db: databases.Database; protected _pathname: string; protected _headers: Headers; /** * @internal */ constructor(db: databases.Database, pathname?: string, headers?: Headers | Record<string, string>); /** * Database this route belongs to. */ get database(): databases.Database; /** * Path of this route. */ get pathname(): string; /** * Headers of this route. */ get headers(): Headers; /** * Creates a new route relative to this route that inherits any of its default * HTTP headers. * * @param pathname - Path relative to this route. * @param headers - Additional headers that will be sent with each request. * * @example * ```js * const db = new Database(); * const foxx = db.route("/my-foxx-service"); * const users = foxx.route("/users"); * ``` */ route(pathname: string, headers?: Headers | Record<string, string>): Route; /** * Performs an arbitrary HTTP request relative to this route and returns the * server response. * * @param options - Options for performing the request. * * @example * ```js * const db = new Database(); * const foxx = db.route("/my-foxx-service"); * const res = await foxx.request({ * method: "POST", * pathname: "/users", * body: { * username: "admin", * password: "hunter2" * } * }); * ``` */ request(options?: connections.RequestOptions): Promise<connections.ProcessedResponse<any>>; /** * Performs a DELETE request against the given path relative to this route * and returns the server response. * * @param pathname - Path relative to this route. * @param search - Query string parameters for this request. * @param headers - Additional headers to send with this request. * * @example * ```js * const db = new Database(); * const foxx = db.route("/my-foxx-service"); * const res = await foxx.delete("/users/admin"); * ``` */ delete(pathname: string, search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<connections.ProcessedResponse>; /** * Performs a DELETE request against the given path relative to this route * and returns the server response. * * @param search - Query string parameters for this request. * @param headers - Additional headers to send with this request. * * @example * ```js * const db = new Database(); * const foxx = db.route("/my-foxx-service"); * const user = foxx.roue("/users/admin"); * const res = await user.delete(); * ``` */ delete(search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<connections.ProcessedResponse>; /** * Performs a GET request against the given path relative to this route * and returns the server response. * * @param pathname - Path relative to this route. * @param search - Query string parameters for this request. * @param headers - Additional headers to send with this request. * * @example * ```js * const db = new Database(); * const foxx = db.route("/my-foxx-service"); * const res = await foxx.get("/users", { offset: 10, limit: 5 }); * ``` */ get(pathname: string, search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<connections.ProcessedResponse>; /** * Performs a GET request against the given path relative to this route * and returns the server response. * * @param search - Query string parameters for this request. * @param headers - Additional headers to send with this request. * * @example * ```js * const db = new Database(); * const foxx = db.route("/my-foxx-service"); * const users = foxx.route("/users"); * const res = await users.get({ offset: 10, limit: 5 }); * ``` */ get(search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<connections.ProcessedResponse>; /** * Performs a HEAD request against the given path relative to this route * and returns the server response. * * @param pathname - Path relative to this route. * @param search - Query string parameters for this request. * @param headers - Additional headers to send with this request. * * @example * ```js * const db = new Database(); * const foxx = db.route("/my-foxx-service"); * const res = await foxx.head("/users", { offset: 10, limit: 5 }); * ``` */ head(pathname: string, search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<connections.ProcessedResponse>; /** * Performs a HEAD request against the given path relative to this route * and returns the server response. * * @param search - Query string parameters for this request. * @param headers - Additional headers to send with this request. * * @example * ```js * const db = new Database(); * const foxx = db.route("/my-foxx-service"); * const users = foxx.route("/users"); * const res = await users.head({ offset: 10, limit: 5 }); * ``` */ head(search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<connections.ProcessedResponse>; /** * Performs a PATCH request against the given path relative to this route * and returns the server response. * * @param pathname - Path relative to this route. * @param body - Body of the request object. * @param search - Query string parameters for this request. * @param headers - Additional headers to send with this request. * * @example * ```js * const db = new Database(); * const foxx = db.route("/my-foxx-service"); * const res = await foxx.patch("/users/admin", { password: "admin" }); * ``` */ patch(pathname: string, body?: any, search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<connections.ProcessedResponse>; /** * Performs a PATCH request against the given path relative to this route * and returns the server response. * * **Note**: `body` must not be a `string`. * * @param body - Body of the request object. Must not be a string. * @param search - Query string parameters for this request. * @param headers - Additional headers to send with this request. * * @example * ```js * const db = new Database(); * const foxx = db.route("/my-foxx-service"); * const user = foxx.route("/users/admin") * const res = await user.patch({ password: "admin" }); * ``` */ patch(body?: any, search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<connections.ProcessedResponse>; /** * Performs a POST request against the given path relative to this route * and returns the server response. * * @param pathname - Path relative to this route. * @param body - Body of the request object. * @param search - Query string parameters for this request. * @param headers - Additional headers to send with this request. * * @example * ```js * const db = new Database(); * const foxx = db.route("/my-foxx-service"); * const res = await foxx.post("/users", { * username: "admin", * password: "hunter2" * }); * ``` */ post(pathname: string, body?: any, search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<connections.ProcessedResponse>; /** * Performs a POST request against the given path relative to this route * and returns the server response. * * **Note**: `body` must not be a `string`. * * @param body - Body of the request object. Must not be a string. * @param search - Query string parameters for this request. * @param headers - Additional headers to send with this request. * * @example * ```js * const db = new Database(); * const foxx = db.route("/my-foxx-service"); * const users = foxx.route("/users"); * const res = await users.post({ * username: "admin", * password: "hunter2" * }); * ``` */ post(body?: any, search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<connections.ProcessedResponse>; /** * Performs a PUT request against the given path relative to this route * and returns the server response. * * @param pathname - Path relative to this route. * @param body - Body of the request object. * @param search - Query string parameters for this request. * @param headers - Additional headers to send with this request. * * @example * ```js * const db = new Database(); * const foxx = db.route("/my-foxx-service"); * const res = await foxx.put("/users/admin/password", { password: "admin" }); * ``` */ put(pathname: string, body?: any, search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<connections.ProcessedResponse>; /** * Performs a PUT request against the given path relative to this route * and returns the server response. * * **Note**: `body` must not be a `string`. * * @param body - Body of the request object. Must not be a string. * @param search - Query string parameters for this request. * @param headers - Additional headers to send with this request. * * @example * ```js * const db = new Database(); * const foxx = db.route("/my-foxx-service"); * const password = foxx.route("/users/admin/password"); * const res = await password.put({ password: "admin" }); * ``` */ put(body?: any, search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<connections.ProcessedResponse>; } //# sourceMappingURL=routes.d.ts.map