chat-bridge
Advanced tools
Comparing version 1.0.0-alpha to 1.1.0-alpha
@@ -0,0 +0,0 @@ ## Contributor Covenant Code of Conduct |
## Contributing to Chat Bridge | ||
Thank you for your interest in contributing to Your Library Name! — We appreciate your help in making this project better. | ||
Thank you for your interest in contributing to Chat Bridge! — We appreciate your help in making this project better. | ||
@@ -5,0 +5,0 @@ ### Code of Conduct |
@@ -70,5 +70,5 @@ "use strict"; | ||
var fastify_1 = __importDefault(require("fastify")); | ||
var static_1 = require("@fastify/static"); | ||
var constants_1 = require("@/core/constants"); | ||
var events_1 = require("events"); | ||
var static_1 = require("@fastify/static"); | ||
var undici_1 = require("undici"); | ||
@@ -79,2 +79,3 @@ /** | ||
* const { Client } = require('@badend/chatbridge'); | ||
* | ||
* const client = new Client({ | ||
@@ -84,4 +85,4 @@ * accessToken: "YOUR_ACCESS_TOKEN", // required | ||
* // webHookPath: "/webhook", // default | ||
* // port: 3000, // default | ||
* // host: "localhost", // default (only for development) or " | ||
* // port: 8080, // default | ||
* // host: "localhost", // default (only for development) or 0.0.0.0 (for production) | ||
* }); | ||
@@ -194,45 +195,2 @@ */ | ||
/** | ||
* Stop the server | ||
* @memberof Client | ||
* @example | ||
* client.shutdown(async () => console.log(`Server stopped`)); | ||
* @param {Function} [callback] | ||
*/ | ||
Client.prototype.shutdown = function (callback) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var shutdownServer; | ||
var _this = this; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
shutdownServer = function () { return __awaiter(_this, void 0, void 0, function () { | ||
var err_2; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, this.server.close()]; | ||
case 1: | ||
_a.sent(); | ||
if (callback) | ||
callback(); | ||
return [3 /*break*/, 3]; | ||
case 2: | ||
err_2 = _a.sent(); | ||
console.error(err_2); | ||
process.exit(1); | ||
return [3 /*break*/, 3]; | ||
case 3: return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
return [4 /*yield*/, shutdownServer()]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Create a static file server | ||
@@ -258,5 +216,4 @@ * @memberof Client | ||
* @example | ||
* client.register(import("@fastify/static"), { | ||
* root: `${__dirname}/public`, | ||
* prefix: "/", | ||
* client.register(require('fastify-cors'), { | ||
* origin: '*', | ||
* }); | ||
@@ -298,3 +255,3 @@ * @param {Function} ...args | ||
if (statusCode !== 200) { | ||
throw new Error("Request failed: ".concat(statusCode)); | ||
throw new Error("Request failed: ".concat(statusCode, "\n").concat(response)); | ||
} | ||
@@ -309,2 +266,19 @@ return [4 /*yield*/, response.json()]; | ||
}; | ||
/** | ||
* Send an API message | ||
* @memberof Client | ||
* @example | ||
* client.sendApiMessage("USER_ID", { | ||
* text: "Hello, World!", | ||
* quick_replies: [ | ||
* { | ||
* content_type: "text", | ||
* title: "Hello", | ||
* payload: "HELLO", | ||
* } | ||
* ] | ||
* }); | ||
* @param {string} recipientId | ||
* @param {object} message | ||
*/ | ||
Client.prototype.sendApiMessage = function (recipientId, message) { | ||
@@ -359,4 +333,98 @@ var body = { | ||
}; | ||
/** | ||
* Send an attachment | ||
* @memberof Client | ||
* @example | ||
* client.sendAttachment("USER_ID", "image", "https://example.com/image.png"); | ||
* @param {string} recipientId | ||
* @param {string} type | ||
* @param {string} url | ||
* @param {boolean} [isReusable=false] | ||
*/ | ||
Client.prototype.sendAttachment = function (recipientId, type, url, isReusable) { | ||
if (isReusable === void 0) { isReusable = false; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.sendApiMessage(recipientId, { | ||
attachment: { | ||
type: type, | ||
payload: { | ||
url: url, | ||
is_reusable: isReusable | ||
} | ||
} | ||
})]; | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Send an image | ||
* @memberof Client | ||
* @example | ||
* client.sendImage("USER_ID", "https://example.com/image.png"); | ||
* @param {string} recipientId | ||
* @param {string} url | ||
* @param {boolean} [isReusable=false] | ||
*/ | ||
Client.prototype.sendImage = function (recipientId, url, isReusable) { | ||
if (isReusable === void 0) { isReusable = false; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.sendAttachment(recipientId, 'image', url, isReusable)]; | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Send an audio | ||
* @memberof Client | ||
* @example | ||
* client.sendAudio("USER_ID", "https://example.com/audio.mp3"); | ||
* @param {string} recipientId | ||
* @param {string} url | ||
* @param {boolean} [isReusable=false] | ||
*/ | ||
Client.prototype.sendAudio = function (recipientId, url, isReusable) { | ||
if (isReusable === void 0) { isReusable = false; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.sendAttachment(recipientId, 'audio', url, isReusable)]; | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Send a video | ||
* @memberof Client | ||
* @example | ||
* client.sendVideo("USER_ID", "https://example.com/video.mp4"); | ||
* @param {string} recipientId | ||
* @param {string} url | ||
* @param {boolean} [isReusable=false] | ||
*/ | ||
Client.prototype.sendVideo = function (recipientId, url, isReusable) { | ||
if (isReusable === void 0) { isReusable = false; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.sendAttachment(recipientId, 'video', url, isReusable)]; | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Send a file | ||
* @memberof Client | ||
* @example | ||
* client.sendFile("USER_ID", "https://example.com/file.pdf"); | ||
* @param {string} recipientId | ||
* @param {string} url | ||
* @param {boolean} [isReusable=false] | ||
*/ | ||
Client.prototype.sendFile = function (recipientId, url, isReusable) { | ||
if (isReusable === void 0) { isReusable = false; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
return [2 /*return*/, this.sendAttachment(recipientId, 'file', url, isReusable)]; | ||
}); | ||
}); | ||
}; | ||
return Client; | ||
}(events_1.EventEmitter)); | ||
exports.Client = Client; |
@@ -8,6 +8,7 @@ "use strict"; | ||
* Constants | ||
* @namespace Constants | ||
* @example | ||
* Constants.BASE_URL | ||
* Constants.MESSAGE_URL | ||
* const { Constants } = require('chat-bridge'); | ||
* | ||
* console.log(Constants.BASE_URL); // https://graph.facebook.com/ | ||
* console.log(Constants.MESSAGE_URL); // https://graph.facebook.com/v18.0/me/ | ||
*/ | ||
@@ -14,0 +15,0 @@ exports.Constants = { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Constants = exports.Collection = exports.Client = void 0; | ||
exports.Constants = exports.Collections = exports.Client = void 0; | ||
require("module-alias/register"); | ||
var client_1 = require("@/core/client"); | ||
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } }); | ||
var collection_1 = require("@/core/collection"); | ||
Object.defineProperty(exports, "Collection", { enumerable: true, get: function () { return collection_1.Collection; } }); | ||
var collections_1 = require("@/core/collections"); | ||
Object.defineProperty(exports, "Collections", { enumerable: true, get: function () { return collections_1.Collections; } }); | ||
var constants_1 = require("@/core/constants"); | ||
Object.defineProperty(exports, "Constants", { enumerable: true, get: function () { return constants_1.Constants; } }); |
@@ -17,5 +17,2 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
__exportStar(require("./client"), exports); | ||
__exportStar(require("./http"), exports); | ||
__exportStar(require("./page"), exports); | ||
__exportStar(require("./webhook"), exports); |
{ | ||
"name": "chat-bridge", | ||
"version": "1.0.0-alpha", | ||
"version": "1.1.0-alpha", | ||
"description": "Chat Bridge simplifies the integration of Facebook Messenger webhook handling into your Node.js applications.", | ||
"module": "dist/index.js", | ||
"type": "module", | ||
"scripts": { | ||
"build": "rimraf dist && tsc --skipLibCheck", | ||
"lint": "eslint --ext .ts src", | ||
"format": "prettier --write \"src/**/*.ts\"", | ||
"dev": "bun test/development.ts", | ||
"pre-commit": "lint-staged && bun run build" | ||
}, | ||
"lint-staged": { | ||
"src/**/*.ts": [ | ||
"eslint --fix", | ||
"prettier --write" | ||
] | ||
}, | ||
"repository": { | ||
@@ -24,2 +9,3 @@ "type": "git", | ||
}, | ||
"author": "Onyx Innovators", | ||
"keywords": [ | ||
@@ -39,3 +25,2 @@ "facebook", | ||
], | ||
"author": "Onyx Innovators", | ||
"license": "MIT", | ||
@@ -46,19 +31,3 @@ "bugs": { | ||
"homepage": "https://onyx-innovators.github.io/Chat-Bridge/", | ||
"dependencies": { | ||
"@fastify/static": "^6.12.0", | ||
"fastify": "^4.25.2", | ||
"undici": "^6.2.1" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.10.7", | ||
"@typescript-eslint/eslint-plugin": "^6.18.0", | ||
"dotenv": "^16.3.1", | ||
"eslint": "^8.56.0", | ||
"lint-staged": "^15.2.0", | ||
"prettier": "^3.1.1", | ||
"rimraf": "^5.0.5" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^5.0.0" | ||
} | ||
"main": "dist/index.js" | ||
} |
@@ -28,2 +28,3 @@ <div align="center" id="about"> | ||
- [Usage](#usage) | ||
- [Documentation](#documentation) | ||
- [Contributing](#contributing) | ||
@@ -76,2 +77,6 @@ - [Acknowledgments](#acknowledgments) | ||
### Documentation | ||
You can read additional documents at [Chat Bridge](https://chat-bridge.pages.dev/) | ||
### Contributing | ||
@@ -78,0 +83,0 @@ |
Sorry, the diff of this file is not supported yet
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
0
0
557
98
35804
1
No
- Removed@fastify/static@^6.12.0
- Removedfastify@^4.25.2
- Removedundici@^6.2.1
- Removed@fastify/accept-negotiator@1.1.0(transitive)
- Removed@fastify/ajv-compiler@3.5.0(transitive)
- Removed@fastify/error@3.4.1(transitive)
- Removed@fastify/fast-json-stringify-compiler@4.3.0(transitive)
- Removed@fastify/merge-json-schemas@0.1.1(transitive)
- Removed@fastify/send@2.1.0(transitive)
- Removed@fastify/static@6.12.0(transitive)
- Removed@lukeed/ms@2.0.2(transitive)
- Removedabort-controller@3.0.0(transitive)
- Removedabstract-logging@2.0.1(transitive)
- Removedajv@8.16.0(transitive)
- Removedajv-formats@2.1.13.0.1(transitive)
- Removedatomic-sleep@1.0.0(transitive)
- Removedavvio@8.3.2(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbase64-js@1.5.1(transitive)
- Removedbrace-expansion@2.0.1(transitive)
- Removedbuffer@6.0.3(transitive)
- Removedcontent-disposition@0.5.4(transitive)
- Removedcookie@0.6.0(transitive)
- Removeddepd@2.0.0(transitive)
- Removedescape-html@1.0.3(transitive)
- Removedevent-target-shim@5.0.1(transitive)
- Removedevents@3.3.0(transitive)
- Removedfast-content-type-parse@1.1.0(transitive)
- Removedfast-decode-uri-component@1.0.1(transitive)
- Removedfast-deep-equal@3.1.3(transitive)
- Removedfast-json-stringify@5.16.0(transitive)
- Removedfast-querystring@1.1.2(transitive)
- Removedfast-redact@3.5.0(transitive)
- Removedfast-uri@2.4.0(transitive)
- Removedfastify@4.27.0(transitive)
- Removedfastify-plugin@4.5.1(transitive)
- Removedfastq@1.17.1(transitive)
- Removedfind-my-way@8.2.0(transitive)
- Removedforwarded@0.2.0(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedglob@8.1.0(transitive)
- Removedhttp-errors@2.0.0(transitive)
- Removedieee754@1.2.1(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedipaddr.js@1.9.1(transitive)
- Removedjson-schema-ref-resolver@1.0.1(transitive)
- Removedjson-schema-traverse@1.0.0(transitive)
- Removedlight-my-request@5.13.0(transitive)
- Removedmime@3.0.0(transitive)
- Removedminimatch@5.1.6(transitive)
- Removedon-exit-leak-free@2.1.2(transitive)
- Removedonce@1.4.0(transitive)
- Removedp-limit@3.1.0(transitive)
- Removedpino@9.2.0(transitive)
- Removedpino-abstract-transport@1.2.0(transitive)
- Removedpino-std-serializers@7.0.0(transitive)
- Removedprocess@0.11.10(transitive)
- Removedprocess-warning@3.0.0(transitive)
- Removedproxy-addr@2.0.7(transitive)
- Removedpunycode@2.3.1(transitive)
- Removedquick-format-unescaped@4.0.4(transitive)
- Removedreadable-stream@4.5.2(transitive)
- Removedreal-require@0.2.0(transitive)
- Removedrequire-from-string@2.0.2(transitive)
- Removedret@0.4.3(transitive)
- Removedreusify@1.0.4(transitive)
- Removedrfdc@1.3.1(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedsafe-regex2@3.1.0(transitive)
- Removedsafe-stable-stringify@2.4.3(transitive)
- Removedsecure-json-parse@2.7.0(transitive)
- Removedsemver@7.6.2(transitive)
- Removedset-cookie-parser@2.6.0(transitive)
- Removedsetprototypeof@1.2.0(transitive)
- Removedsonic-boom@4.0.1(transitive)
- Removedsplit2@4.2.0(transitive)
- Removedstatuses@2.0.1(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedthread-stream@3.0.2(transitive)
- Removedtoad-cache@3.7.0(transitive)
- Removedtoidentifier@1.0.1(transitive)
- Removedtypescript@5.4.5(transitive)
- Removedundici@6.18.2(transitive)
- Removeduri-js@4.4.1(transitive)
- Removedwrappy@1.0.2(transitive)
- Removedyocto-queue@0.1.0(transitive)