From 81b2a716d9d1e24a33212583787d5ea061c361cd Mon Sep 17 00:00:00 2001 From: Diego Plascencia Date: Thu, 27 Jul 2017 10:42:58 -0500 Subject: [PATCH 1/5] modifies inversify chat badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 46765b7..0d82e0c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # inversify-koa-utils -[![Join the chat at https://gitter.im/inversify/InversifyJS](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/inversify/InversifyJS?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) +[![inversify chat https://gitter.im/inversify/InversifyJS](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/inversify/InversifyJS?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://secure.travis-ci.org/diego-d5000/inversify-koa-utils.svg?branch=master)](https://travis-ci.org/diego-d5000/inversify-koa-utils) [![Test Coverage](https://codeclimate.com/github/diego-d5000/inversify-koa-utils/badges/coverage.svg)](https://codeclimate.com/github/diego-d5000/inversify-koa-utils/coverage) [![npm version](https://badge.fury.io/js/inversify-koa-utils.svg)](http://badge.fury.io/js/inversify-koa-utils) From 1bc491d1b3d874dc29eedd1ff41ab128e10baf28 Mon Sep 17 00:00:00 2001 From: Diego Plascencia Date: Thu, 27 Jul 2017 10:44:22 -0500 Subject: [PATCH 2/5] added context decorator use to readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 0d82e0c..f15ce1d 100644 --- a/README.md +++ b/README.md @@ -237,6 +237,9 @@ Binds a method parameter to the request headers. ### `@cookies()` Binds a method parameter to the request cookies. +### `@context()` +Binds a method parameter to the koa context object. + ### `@next()` Binds a method parameter to the next() function. From da24fbeafa447a025763cdc5212fb794fb7a714b Mon Sep 17 00:00:00 2001 From: Edmund Stroh Date: Sun, 28 Oct 2018 19:19:08 +0100 Subject: [PATCH 3/5] Export context --- src/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 07b7e53..009a05e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ import { InversifyKoaServer } from "./server"; import { controller, httpMethod, httpGet, httpPut, httpPost, httpPatch, httpHead, all, httpDelete, request, response, requestParam, queryParam, - requestBody, requestHeaders, cookies, next } from "./decorators"; + requestBody, requestHeaders, cookies, next, context } from "./decorators"; import { TYPE } from "./constants"; import { interfaces } from "./interfaces"; @@ -25,5 +25,6 @@ export { requestBody, requestHeaders, cookies, - next + next, + context }; From 8cd9bd234879021bcd13cc117c8a425b82ffd416 Mon Sep 17 00:00:00 2001 From: Edmund Stroh Date: Sun, 28 Oct 2018 19:26:17 +0100 Subject: [PATCH 4/5] Add readme entry for context --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 46765b7..30bf581 100644 --- a/README.md +++ b/README.md @@ -234,6 +234,9 @@ Binds a method parameter to request.body or to a specific body property if a nam ### `@requestHeaders(name?: string)` Binds a method parameter to the request headers. +### `@context()` +Binds a method parameter to the koa context object. + ### `@cookies()` Binds a method parameter to the request cookies. From 97190baecb6d56a7d55cdd12fa8be924c9035fa4 Mon Sep 17 00:00:00 2001 From: 1a35e1 <0042ef@protonmail.com> Date: Thu, 28 Feb 2019 15:00:13 +1100 Subject: [PATCH 5/5] Symbol.for('Controller') is actually a better approach See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/for --- package.json | 2 +- src/constants.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b9df731..0a5a912 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "inversify-koa-utils", - "version": "1.0.0", + "version": "1.0.1", "description": "Some utilities for the development of koa applications with Inversify", "main": "lib/index.js", "jsnext:main": "es/index.js", diff --git a/src/constants.ts b/src/constants.ts index efb1203..7c66f5f 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,5 +1,5 @@ const TYPE = { - Controller: Symbol("Controller") + Controller: Symbol.for("Controller") }; const METADATA_KEY = {