Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

telenode-js

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

telenode-js - npm Package Compare versions

Comparing version 1.1.1 to 1.1.2

2

package.json
{
"name": "telenode-js",
"version": "1.1.1",
"version": "1.1.2",
"description": "Lightweight Telegram API framework for Node.js",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -97,2 +97,4 @@ # Telenode

For local development you should spin up a local express server with the command `bot.createServer()`. More on that will be explained in the <b>Deployment</b> section down below.
The webhook url should be presented in the `.env` file or be exported as an environment variable.

@@ -107,2 +109,27 @@

---
## Deployment:
Since these days it is common to use serverless backend services, you can choose how the bot will work - or with `express` or with the `HTTP` engine of the serverless provider.
In order to spin up an express server you should use the command `bot.createServer()` - this is useful for deployments on VMs / containers / on-premise.
You can pass an object as options for `createServer`. Currently, it supports `port` and `unauthorizedCallback` (if you use secret token) - e.g:
```
bot.createServer({ port: 4000 }) // the default is 3000
```
In the other hand, if you want to deploy on serverless backend you need to use `bot.telenodeHandler` method and pass to it the request object.
You will probably have something like this:
```
functions.https.onCall((req, res) => {
const secretToken = req.headers['x-telegram-bot-api-secret-token'];
bot.telenodeHandler(req.body, secretToken, unauthorizedHandler);
res.end();
});
```
Note that on serverless you should extract by your own the `secretToken` since every serverless service might process the `req` object differently.
## TODO's

@@ -109,0 +136,0 @@

@@ -17,5 +17,5 @@ const { runServer } = require('./server');

createServer(unauthorizedHandler) {
this.unauthorizedHandler = unauthorizedHandler;
runServer(this);
createServer({ port, unauthorizedCallback } = {}) {
this.unauthorizedHandler = unauthorizedCallback;
runServer(this, port);
}

@@ -22,0 +22,0 @@

const express = require('express');
const server = express();
const port = 3000;
const runServer = bot => {
const runServer = (bot, port = 3000) => {
server.use(express.json());

@@ -7,0 +6,0 @@

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