UNPKG

10.4 kBTypeScriptView Raw
1/// <reference types="node" resolution-mode="require"/>
2/// <reference types="node" resolution-mode="require"/>
3/**
4 * ```ts
5 * import type { Route } from "arangojs/route.js";
6 * ```
7 *
8 * The "route" module provides route related types and interfaces for TypeScript.
9 *
10 * @packageDocumentation
11 */
12import { RequestOptions } from "./connection.js";
13import { Database } from "./database.js";
14import { ArangojsResponse } from "./lib/request.js";
15/**
16 * Represents an arbitrary route relative to an ArangoDB database.
17 */
18export declare class Route {
19 protected _db: Database;
20 protected _path: string;
21 protected _headers: Headers;
22 /**
23 * @internal
24 */
25 constructor(db: Database, path?: string, headers?: Headers | Record<string, string>);
26 /**
27 * Creates a new route relative to this route that inherits any of its default
28 * HTTP headers.
29 *
30 * @param path - Path relative to this route.
31 * @param headers - Additional headers that will be sent with each request.
32 *
33 * @example
34 * ```js
35 * const db = new Database();
36 * const foxx = db.route("/my-foxx-service");
37 * const users = foxx.route("/users");
38 * ```
39 */
40 route(path: string, headers?: Headers | Record<string, string>): Route;
41 /**
42 * Performs an arbitrary HTTP request relative to this route and returns the
43 * server response.
44 *
45 * @param options - Options for performing the request.
46 *
47 * @example
48 * ```js
49 * const db = new Database();
50 * const foxx = db.route("/my-foxx-service");
51 * const res = await foxx.request({
52 * method: "POST",
53 * path: "/users",
54 * body: {
55 * username: "admin",
56 * password: "hunter2"
57 * }
58 * });
59 * ```
60 */
61 request(options?: RequestOptions): Promise<ArangojsResponse>;
62 /**
63 * Performs a DELETE request against the given path relative to this route
64 * and returns the server response.
65 *
66 * @param path - Path relative to this route.
67 * @param search - Query string parameters for this request.
68 * @param headers - Additional headers to send with this request.
69 *
70 * @example
71 * ```js
72 * const db = new Database();
73 * const foxx = db.route("/my-foxx-service");
74 * const res = await foxx.delete("/users/admin");
75 * ```
76 */
77 delete(path: string, search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<ArangojsResponse>;
78 /**
79 * Performs a DELETE request against the given path relative to this route
80 * and returns the server response.
81 *
82 * @param search - Query string parameters for this request.
83 * @param headers - Additional headers to send with this request.
84 *
85 * @example
86 * ```js
87 * const db = new Database();
88 * const foxx = db.route("/my-foxx-service");
89 * const user = foxx.roue("/users/admin");
90 * const res = await user.delete();
91 * ```
92 */
93 delete(search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<ArangojsResponse>;
94 /**
95 * Performs a GET request against the given path relative to this route
96 * and returns the server response.
97 *
98 * @param path - Path relative to this route.
99 * @param search - Query string parameters for this request.
100 * @param headers - Additional headers to send with this request.
101 *
102 * @example
103 * ```js
104 * const db = new Database();
105 * const foxx = db.route("/my-foxx-service");
106 * const res = await foxx.get("/users", { offset: 10, limit: 5 });
107 * ```
108 */
109 get(path: string, search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<ArangojsResponse>;
110 /**
111 * Performs a GET request against the given path relative to this route
112 * and returns the server response.
113 *
114 * @param search - Query string parameters for this request.
115 * @param headers - Additional headers to send with this request.
116 *
117 * @example
118 * ```js
119 * const db = new Database();
120 * const foxx = db.route("/my-foxx-service");
121 * const users = foxx.route("/users");
122 * const res = await users.get({ offset: 10, limit: 5 });
123 * ```
124 */
125 get(search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<ArangojsResponse>;
126 /**
127 * Performs a HEAD request against the given path relative to this route
128 * and returns the server response.
129 *
130 * @param path - Path relative to this route.
131 * @param search - Query string parameters for this request.
132 * @param headers - Additional headers to send with this request.
133 *
134 * @example
135 * ```js
136 * const db = new Database();
137 * const foxx = db.route("/my-foxx-service");
138 * const res = await foxx.head("/users", { offset: 10, limit: 5 });
139 * ```
140 */
141 head(path: string, search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<ArangojsResponse>;
142 /**
143 * Performs a HEAD request against the given path relative to this route
144 * and returns the server response.
145 *
146 * @param search - Query string parameters for this request.
147 * @param headers - Additional headers to send with this request.
148 *
149 * @example
150 * ```js
151 * const db = new Database();
152 * const foxx = db.route("/my-foxx-service");
153 * const users = foxx.route("/users");
154 * const res = await users.head({ offset: 10, limit: 5 });
155 * ```
156 */
157 head(search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<ArangojsResponse>;
158 /**
159 * Performs a PATCH request against the given path relative to this route
160 * and returns the server response.
161 *
162 * @param path - Path relative to this route.
163 * @param body - Body of the request object.
164 * @param search - Query string parameters for this request.
165 * @param headers - Additional headers to send with this request.
166 *
167 * @example
168 * ```js
169 * const db = new Database();
170 * const foxx = db.route("/my-foxx-service");
171 * const res = await foxx.patch("/users/admin", { password: "admin" });
172 * ```
173 */
174 patch(path: string, body?: any, search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<ArangojsResponse>;
175 /**
176 * Performs a PATCH request against the given path relative to this route
177 * and returns the server response.
178 *
179 * **Note**: `body` must not be a `string`.
180 *
181 * @param body - Body of the request object. Must not be a string.
182 * @param search - Query string parameters for this request.
183 * @param headers - Additional headers to send with this request.
184 *
185 * @example
186 * ```js
187 * const db = new Database();
188 * const foxx = db.route("/my-foxx-service");
189 * const user = foxx.route("/users/admin")
190 * const res = await user.patch({ password: "admin" });
191 * ```
192 */
193 patch(body?: any, search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<ArangojsResponse>;
194 /**
195 * Performs a POST request against the given path relative to this route
196 * and returns the server response.
197 *
198 * @param path - Path relative to this route.
199 * @param body - Body of the request object.
200 * @param search - Query string parameters for this request.
201 * @param headers - Additional headers to send with this request.
202 *
203 * @example
204 * ```js
205 * const db = new Database();
206 * const foxx = db.route("/my-foxx-service");
207 * const res = await foxx.post("/users", {
208 * username: "admin",
209 * password: "hunter2"
210 * });
211 * ```
212 */
213 post(path: string, body?: any, search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<ArangojsResponse>;
214 /**
215 * Performs a POST request against the given path relative to this route
216 * and returns the server response.
217 *
218 * **Note**: `body` must not be a `string`.
219 *
220 * @param body - Body of the request object. Must not be a string.
221 * @param search - Query string parameters for this request.
222 * @param headers - Additional headers to send with this request.
223 *
224 * @example
225 * ```js
226 * const db = new Database();
227 * const foxx = db.route("/my-foxx-service");
228 * const users = foxx.route("/users");
229 * const res = await users.post({
230 * username: "admin",
231 * password: "hunter2"
232 * });
233 * ```
234 */
235 post(body?: any, search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<ArangojsResponse>;
236 /**
237 * Performs a PUT request against the given path relative to this route
238 * and returns the server response.
239 *
240 * @param path - Path relative to this route.
241 * @param body - Body of the request object.
242 * @param search - Query string parameters for this request.
243 * @param headers - Additional headers to send with this request.
244 *
245 * @example
246 * ```js
247 * const db = new Database();
248 * const foxx = db.route("/my-foxx-service");
249 * const res = await foxx.put("/users/admin/password", { password: "admin" });
250 * ```
251 */
252 put(path: string, body?: any, search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<ArangojsResponse>;
253 /**
254 * Performs a PUT request against the given path relative to this route
255 * and returns the server response.
256 *
257 * **Note**: `body` must not be a `string`.
258 *
259 * @param body - Body of the request object. Must not be a string.
260 * @param search - Query string parameters for this request.
261 * @param headers - Additional headers to send with this request.
262 *
263 * @example
264 * ```js
265 * const db = new Database();
266 * const foxx = db.route("/my-foxx-service");
267 * const password = foxx.route("/users/admin/password");
268 * const res = await password.put({ password: "admin" });
269 * ```
270 */
271 put(body?: any, search?: URLSearchParams | Record<string, any>, headers?: Headers | Record<string, string>): Promise<ArangojsResponse>;
272}
273//# sourceMappingURL=route.d.ts.map
\No newline at end of file