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

node-telegram-bot-api-middleware-context

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-telegram-bot-api-middleware-context - npm Package Compare versions

Comparing version 0.0.1 to 0.1.0

.prettierrc

22

index.js

@@ -1,2 +0,14 @@

module.exports = function createContextMiddleware() {
/**
* @typedef {Object} MiddlewareContext
*
* @property {Object<string, any>} msg
* @property {number} chatId
* @property {Object<string, any>} ctx - Added context property
*/
/**
* Creates context middleware function.
* @return {function(this: MiddlewareContext)} Context middleware function
*/
function createContextMiddleware() {
const contextStore = new WeakMap()

@@ -9,2 +21,3 @@

get() {
/** @type T */
let ctx = contextStore.get(key)

@@ -22,2 +35,3 @@

set: function(obj, prop, val) {
obj[prop] = val
contextStore.set(key, obj)

@@ -31,3 +45,3 @@ return true

throw new Error(
"Values cannot be assigned directly to 'this.ctx'. Use custom properties to save data, e.g. 'this.ctx.myProperty = myValue'."
"Value cannot be assigned directly to 'this.ctx'. Use custom properties to save data, e.g. 'this.ctx.myProperty = myValue'."
)

@@ -38,2 +52,4 @@ },

}
}
}
module.export = createContextMiddleware

2

package.json
{
"name": "node-telegram-bot-api-middleware-context",
"version": "0.0.1",
"version": "0.1.0",
"description": "Request context creation middleware for 'node-telegram-bot-api-middleware'.",

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

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