Socket
Socket
Sign inDemoInstall

chat-bridge

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.0-alpha to 1.1.0-alpha

dist/core/collections.js

0

CODE_OF_CONDUCT.md

@@ -0,0 +0,0 @@ ## Contributor Covenant Code of Conduct

2

CONTRIBUTING.md
## 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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc