New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@guildedts/rest

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@guildedts/rest - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

6

CHANGELOG.md
# @guildedts/rest
## 0.0.2
### Patch Changes
- All issues with dependencies should now be fixed.
## 0.0.1

@@ -4,0 +10,0 @@

54

lib/GuildedAPIError.js

@@ -1,32 +0,32 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
exports.GuildedAPIError = void 0;
/** Represents an error that occurred while interacting with the Guilded API. */
class GuildedAPIError extends Error {
code;
message;
status;
method;
path;
body;
/**
* @param code The error code.
* @param message The error message.
* @param status The status code.
* @param method The method used.
* @param path The path used.
* @param body The body used.
*/
constructor(code, message, status, method, path, body) {
super(message);
this.code = code;
this.message = message;
this.status = status;
this.method = method;
this.path = path;
this.body = body;
this.name = `GuildedAPIError (${status}) [${code}]`;
}
code;
message;
status;
method;
path;
body;
/**
* @param code The error code.
* @param message The error message.
* @param status The status code.
* @param method The method used.
* @param path The path used.
* @param body The body used.
*/
constructor(code, message, status, method, path, body) {
super(message);
this.code = code;
this.message = message;
this.status = status;
this.method = method;
this.path = path;
this.body = body;
this.name = `GuildedAPIError (${status}) [${code}]`;
}
}
exports.GuildedAPIError = GuildedAPIError;
//# sourceMappingURL=GuildedAPIError.js.map
//# sourceMappingURL=GuildedAPIError.js.map

@@ -1,22 +0,40 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
'use strict';
var __createBinding =
(this && this.__createBinding) ||
(Object.create
? function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = {
enumerable: true,
get: function () {
return m[k];
},
};
}
Object.defineProperty(o, k2, desc);
}
: function (o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar =
(this && this.__exportStar) ||
function (m, exports) {
for (var p in m)
if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p))
__createBinding(exports, m, p);
};
Object.defineProperty(exports, '__esModule', { value: true });
exports.default = void 0;
var RestManager_1 = require("./RestManager");
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return RestManager_1.RestManager; } });
__exportStar(require("./RestManager"), exports);
__exportStar(require("./GuildedAPIError"), exports);
//# sourceMappingURL=index.js.map
var RestManager_1 = require('./RestManager');
Object.defineProperty(exports, 'default', {
enumerable: true,
get: function () {
return RestManager_1.RestManager;
},
});
__exportStar(require('./RestManager'), exports);
__exportStar(require('./GuildedAPIError'), exports);
//# sourceMappingURL=index.js.map

@@ -1,9 +0,11 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
'use strict';
var __importDefault =
(this && this.__importDefault) ||
function (mod) {
return mod && mod.__esModule ? mod : { default: mod };
};
Object.defineProperty(exports, '__esModule', { value: true });
exports.RestManager = void 0;
const _1 = require(".");
const node_fetch_1 = __importDefault(require("node-fetch"));
const _1 = require('.');
const node_fetch_1 = __importDefault(require('node-fetch'));
/**

@@ -14,84 +16,93 @@ * The REST manager for the Guilded API.

class RestManager {
version;
/** The authoization token for the REST api. */
token;
/** @param version The API version for the REST api. */
constructor(version) {
this.version = version;
}
/** The base URL for the REST api. */
get baseUrl() {
return `https://www.guilded.gg/api/v${this.version}/`;
}
/**
* Set the authorization token for the REST api.
* @param token The authorization token.
* @returns The REST manager.
*/
setToken(token) {
this.token = token;
return this;
}
/**
* Make a request to the REST api.
* @param path The path to resource.
* @param method The HTTP method.
* @param options The options for the request.
* @returns The response from the REST api.
*/
async fetch(path, method, options = {}) {
const searchParams = new URLSearchParams();
if (options.params)
Object.entries(options.params).forEach(([key, value]) => searchParams.append(key, value.toString()));
const response = await (0, node_fetch_1.default)(this.baseUrl + path + searchParams, {
method,
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.token}`,
},
body: options.body ? JSON.stringify(options.body) : undefined,
});
const data = await response.json().catch(() => ({}));
if (!response.ok) {
throw new _1.GuildedAPIError(data.code, data.message, response.status, method, path, options.body);
}
return data;
}
/**
* Make a GET request to the REST api.
* @param path The path to the resource.
* @param params The query parameters.
* @returns The response from the REST api.
*/
async get(path, params) {
return this.fetch(path, 'GET', { params });
}
/**
* Make a POST request to the REST api.
* @param path The path to the resource.
* @param body The body of the request.
* @returns The response from the REST api.
*/
async post(path, body) {
return this.fetch(path, 'POST', { body });
}
/**
* Make a PUT request to the REST api.
* @param path The path to the resource.
* @param body The body of the request.
* @returns The response from the REST api.
*/
async put(path, body) {
return this.fetch(path, 'PUT', { body });
}
/**
* Make a DELETE request to the REST api.
* @param path The path to the resource.
* @returns The response from the REST api.
*/
async delete(path) {
return this.fetch(path, 'DELETE');
}
version;
/** The authoization token for the REST api. */
token;
/** @param version The API version for the REST api. */
constructor(version) {
this.version = version;
}
/** The base URL for the REST api. */
get baseUrl() {
return `https://www.guilded.gg/api/v${this.version}/`;
}
/**
* Set the authorization token for the REST api.
* @param token The authorization token.
* @returns The REST manager.
*/
setToken(token) {
this.token = token;
return this;
}
/**
* Make a request to the REST api.
* @param path The path to resource.
* @param method The HTTP method.
* @param options The options for the request.
* @returns The response from the REST api.
*/
async fetch(path, method, options = {}) {
const searchParams = new URLSearchParams();
if (options.params)
Object.entries(options.params).forEach(([key, value]) =>
searchParams.append(key, value.toString()),
);
const response = await (0, node_fetch_1.default)(this.baseUrl + path + searchParams, {
method,
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.token}`,
},
body: options.body ? JSON.stringify(options.body) : undefined,
});
const data = await response.json().catch(() => ({}));
if (!response.ok) {
throw new _1.GuildedAPIError(
data.code,
data.message,
response.status,
method,
path,
options.body,
);
}
return data;
}
/**
* Make a GET request to the REST api.
* @param path The path to the resource.
* @param params The query parameters.
* @returns The response from the REST api.
*/
async get(path, params) {
return this.fetch(path, 'GET', { params });
}
/**
* Make a POST request to the REST api.
* @param path The path to the resource.
* @param body The body of the request.
* @returns The response from the REST api.
*/
async post(path, body) {
return this.fetch(path, 'POST', { body });
}
/**
* Make a PUT request to the REST api.
* @param path The path to the resource.
* @param body The body of the request.
* @returns The response from the REST api.
*/
async put(path, body) {
return this.fetch(path, 'PUT', { body });
}
/**
* Make a DELETE request to the REST api.
* @param path The path to the resource.
* @returns The response from the REST api.
*/
async delete(path) {
return this.fetch(path, 'DELETE');
}
}
exports.RestManager = RestManager;
//# sourceMappingURL=RestManager.js.map
//# sourceMappingURL=RestManager.js.map
{
"name": "@guildedts/rest",
"version": "0.0.1",
"version": "0.0.2",
"description": "The REST API manager for Guilded.TS.",

@@ -38,4 +38,5 @@ "main": "lib/index.js",

"devDependencies": {
"@types/node-fetch": "^2.6.1",
"typescript": "^4.6.3"
}
}
/** Represents an error that occurred while interacting with the Guilded API. */
export declare class GuildedAPIError extends Error {
readonly code: string;
readonly message: string;
readonly status: number;
readonly method: string;
readonly path: string;
readonly body?: any;
/**
* @param code The error code.
* @param message The error message.
* @param status The status code.
* @param method The method used.
* @param path The path used.
* @param body The body used.
*/
constructor(code: string, message: string, status: number, method: string, path: string, body?: any);
readonly code: string;
readonly message: string;
readonly status: number;
readonly method: string;
readonly path: string;
readonly body?: any;
/**
* @param code The error code.
* @param message The error message.
* @param status The status code.
* @param method The method used.
* @param path The path used.
* @param body The body used.
*/
constructor(
code: string,
message: string,
status: number,
method: string,
path: string,
body?: any,
);
}
//# sourceMappingURL=GuildedAPIError.d.ts.map
//# sourceMappingURL=GuildedAPIError.d.ts.map
export { RestManager as default } from './RestManager';
export * from './RestManager';
export * from './GuildedAPIError';
//# sourceMappingURL=index.d.ts.map
//# sourceMappingURL=index.d.ts.map

@@ -6,58 +6,65 @@ /**

export declare class RestManager {
readonly version: number;
/** The authoization token for the REST api. */
token?: string;
/** @param version The API version for the REST api. */
constructor(version: number);
/** The base URL for the REST api. */
get baseUrl(): `https://www.guilded.gg/api/v${number}/`;
/**
* Set the authorization token for the REST api.
* @param token The authorization token.
* @returns The REST manager.
*/
setToken(token?: string): this;
/**
* Make a request to the REST api.
* @param path The path to resource.
* @param method The HTTP method.
* @param options The options for the request.
* @returns The response from the REST api.
*/
fetch<R = any, B = any, P extends Record<string, any> = Record<string, any>>(path: string, method: string, options?: FetchOptions<B, P>): Promise<R>;
/**
* Make a GET request to the REST api.
* @param path The path to the resource.
* @param params The query parameters.
* @returns The response from the REST api.
*/
get<R = any, P extends Record<string, any> = Record<string, any>>(path: string, params?: P): Promise<R>;
/**
* Make a POST request to the REST api.
* @param path The path to the resource.
* @param body The body of the request.
* @returns The response from the REST api.
*/
post<R = any, B = any>(path: string, body: B): Promise<R>;
/**
* Make a PUT request to the REST api.
* @param path The path to the resource.
* @param body The body of the request.
* @returns The response from the REST api.
*/
put<R = any, B = any>(path: string, body: B): Promise<R>;
/**
* Make a DELETE request to the REST api.
* @param path The path to the resource.
* @returns The response from the REST api.
*/
delete<R>(path: string): Promise<R>;
readonly version: number;
/** The authoization token for the REST api. */
token?: string;
/** @param version The API version for the REST api. */
constructor(version: number);
/** The base URL for the REST api. */
get baseUrl(): `https://www.guilded.gg/api/v${number}/`;
/**
* Set the authorization token for the REST api.
* @param token The authorization token.
* @returns The REST manager.
*/
setToken(token?: string): this;
/**
* Make a request to the REST api.
* @param path The path to resource.
* @param method The HTTP method.
* @param options The options for the request.
* @returns The response from the REST api.
*/
fetch<R = any, B = any, P extends Record<string, any> = Record<string, any>>(
path: string,
method: string,
options?: FetchOptions<B, P>,
): Promise<R>;
/**
* Make a GET request to the REST api.
* @param path The path to the resource.
* @param params The query parameters.
* @returns The response from the REST api.
*/
get<R = any, P extends Record<string, any> = Record<string, any>>(
path: string,
params?: P,
): Promise<R>;
/**
* Make a POST request to the REST api.
* @param path The path to the resource.
* @param body The body of the request.
* @returns The response from the REST api.
*/
post<R = any, B = any>(path: string, body: B): Promise<R>;
/**
* Make a PUT request to the REST api.
* @param path The path to the resource.
* @param body The body of the request.
* @returns The response from the REST api.
*/
put<R = any, B = any>(path: string, body: B): Promise<R>;
/**
* Make a DELETE request to the REST api.
* @param path The path to the resource.
* @returns The response from the REST api.
*/
delete<R>(path: string): Promise<R>;
}
/** The options for making a request to the REST api. */
export interface FetchOptions<B = any, P extends Record<string, any> = Record<string, any>> {
/** The URL query parameters. */
params?: P;
/** The body of the request. */
body?: B;
/** The URL query parameters. */
params?: P;
/** The body of the request. */
body?: B;
}
//# sourceMappingURL=RestManager.d.ts.map
//# sourceMappingURL=RestManager.d.ts.map
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc