nestjs-session
Advanced tools
Comparing version 2.0.0 to 3.0.0
import { AsyncOptions, SyncOptions } from 'create-nestjs-middleware-module'; | ||
import * as expressSession from 'express-session'; | ||
import expressSession from 'express-session'; | ||
import { createRetriesMiddleware } from './retriesMiddleware'; | ||
@@ -4,0 +4,0 @@ interface Options { |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SessionModule = void 0; | ||
const create_nestjs_middleware_module_1 = require("create-nestjs-middleware-module"); | ||
const expressSession = require("express-session"); | ||
const express_session_1 = __importDefault(require("express-session")); | ||
const retriesMiddleware_1 = require("./retriesMiddleware"); | ||
exports.SessionModule = (0, create_nestjs_middleware_module_1.createModule)((options) => { | ||
const { retries, session, retriesStrategy } = options; | ||
let middleware = expressSession(session); | ||
let middleware = (0, express_session_1.default)(session); | ||
if (retries !== undefined) { | ||
@@ -11,0 +14,0 @@ middleware = (0, retriesMiddleware_1.createRetriesMiddleware)(middleware, retries, retriesStrategy); |
{ | ||
"name": "nestjs-session", | ||
"version": "2.0.0", | ||
"description": "", | ||
"version": "3.0.0", | ||
"description": "Idiomatic NestJS module for session", | ||
"main": "index.js", | ||
@@ -9,3 +9,3 @@ "typings": "index.d.ts", | ||
"test": "jest --verbose -i --detectOpenHandles", | ||
"lint": "eslint \"{src,__tests__}/**/*.ts\" --fix", | ||
"lint": "tsc --noemit && eslint \"{src,__tests__}/**/*.ts\" --fix", | ||
"prebuild": "rimraf dist", | ||
@@ -17,7 +17,9 @@ "build": "tsc -p tsconfig.build.json", | ||
"files": [ | ||
"*.{js,d.ts}" | ||
"*.{js,d.ts}", | ||
"!jest.config.js", | ||
"!.eslintrc.js" | ||
], | ||
"engineStrict": true, | ||
"engines": { | ||
"node": ">=12.0.0" | ||
"node": ">=16" | ||
}, | ||
@@ -36,3 +38,3 @@ "repository": { | ||
], | ||
"author": "Oleg Repin <iamolegga@gmail.com> (http://github.com/iamolegga)", | ||
"author": "iamolegga <iamolegga@gmail.com> (http://github.com/iamolegga)", | ||
"license": "MIT", | ||
@@ -44,29 +46,28 @@ "bugs": { | ||
"dependencies": { | ||
"create-nestjs-middleware-module": "^0.2.1" | ||
"create-nestjs-middleware-module": "^0.3.0" | ||
}, | ||
"devDependencies": { | ||
"@nestjs/common": "^8.0.0", | ||
"@nestjs/core": "^8.0.0", | ||
"@nestjs/platform-express": "^8.0.0", | ||
"@nestjs/platform-fastify": "^8.0.0", | ||
"@types/express-session": "^1.17.4", | ||
"@types/jest": "^27.0.1", | ||
"@types/node": "^16.0.0", | ||
"@types/supertest": "^2.0.11", | ||
"@typescript-eslint/eslint-plugin": "^4.29.3", | ||
"@typescript-eslint/parser": "^4.29.3", | ||
"eslint": "^7.32.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-import": "^2.24.2", | ||
"eslint-plugin-prettier": "^3.4.1", | ||
"express-session": "^1.17.2", | ||
"jest": "27.1.0", | ||
"prettier": "^2.3.2", | ||
"@nestjs/common": "^10.1.3", | ||
"@nestjs/core": "^10.1.3", | ||
"@nestjs/platform-express": "^10.1.3", | ||
"@types/express-session": "^1.17.7", | ||
"@types/jest": "^29.5.3", | ||
"@types/node": "^20.5.0", | ||
"@types/supertest": "^2.0.12", | ||
"@typescript-eslint/eslint-plugin": "^6.4.0", | ||
"@typescript-eslint/parser": "^6.4.0", | ||
"eslint": "^8.47.0", | ||
"eslint-config-prettier": "^9.0.0", | ||
"eslint-plugin-import": "^2.28.0", | ||
"eslint-plugin-prettier": "^5.0.0", | ||
"express-session": "^1.17.3", | ||
"jest": "29.6.2", | ||
"prettier": "^3.0.2", | ||
"reflect-metadata": "^0.1.13", | ||
"rimraf": "^3.0.2", | ||
"rxjs": "^7.2.0", | ||
"supertest": "^6.1.3", | ||
"ts-jest": "^27.0.3", | ||
"ts-loader": "^9.2.3", | ||
"ts-node": "^10.0.0", | ||
"rimraf": "^5.0.1", | ||
"rxjs": "^7.8.1", | ||
"supertest": "^6.3.3", | ||
"ts-jest": "^29.1.1", | ||
"ts-loader": "^9.4.4", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.3.5" | ||
@@ -77,19 +78,3 @@ }, | ||
"express-session": "^1.17.2" | ||
}, | ||
"jest": { | ||
"moduleFileExtensions": [ | ||
"js", | ||
"ts" | ||
], | ||
"testRegex": ".spec.ts$", | ||
"transform": { | ||
"^.+\\.(t|j)s$": "ts-jest" | ||
}, | ||
"collectCoverage": true, | ||
"coverageDirectory": "./coverage", | ||
"collectCoverageFrom": [ | ||
"src/**/*.ts" | ||
], | ||
"testEnvironment": "node" | ||
} | ||
} |
@@ -7,22 +7,22 @@ <h1 align="center">NestJS-Session</h1> | ||
</a> | ||
<img alt="GitHub branch checks state" src="https://badgen.net/github/checks/iamolegga/nestjs-session" /> | ||
<a href="https://www.npmjs.com/package/nestjs-session"> | ||
<img alt="npm" src="https://img.shields.io/npm/dm/nestjs-session" /> | ||
</a> | ||
<a href="https://github.com/iamolegga/nestjs-session/actions"> | ||
<img alt="GitHub branch checks state" src="https://badgen.net/github/checks/iamolegga/nestjs-session" /> | ||
</a> | ||
<a href="https://codeclimate.com/github/iamolegga/nestjs-session/test_coverage"> | ||
<img src="https://api.codeclimate.com/v1/badges/08bcbca7b2da14b3bbfd/test_coverage" /> | ||
</a> | ||
<img alt="Supported platforms: Express" src="https://img.shields.io/badge/platforms-Express-green" /> | ||
</p> | ||
<p align="center"> | ||
<a href="https://snyk.io/test/github/iamolegga/nestjs-session"> | ||
<img alt="Snyk Vulnerabilities for npm package" src="https://img.shields.io/snyk/vulnerabilities/npm/nestjs-session" /> | ||
<img alt="Known Vulnerabilities" src="https://snyk.io/test/github/iamolegga/nestjs-session/badge.svg" /> | ||
</a> | ||
<a href="https://david-dm.org/iamolegga/nestjs-session"> | ||
<img alt="Dependencies status" src="https://badgen.net/david/dep/iamolegga/nestjs-session"> | ||
<a href="https://libraries.io/npm/nestjs-session"> | ||
<img alt="Libraries.io" src="https://img.shields.io/librariesio/release/npm/nestjs-session" /> | ||
</a> | ||
<img alt="Dependabot" src="https://badgen.net/dependabot/iamolegga/nestjs-session/?icon=dependabot"> | ||
<a href="https://codeclimate.com/github/iamolegga/nestjs-session"> | ||
<img alt="Maintainability" src="https://badgen.net/codeclimate/maintainability/iamolegga/nestjs-session"> | ||
</a> | ||
<img alt="Dependabot" src="https://badgen.net/github/dependabot/iamolegga/nestjs-session" /> | ||
<img alt="Supported platforms: Express" src="https://img.shields.io/badge/platforms-Express-green" /> | ||
</p> | ||
<p align="center">Idiomatic Session Module for NestJS. Built on top of <a href="https://npm.im/express-session">express-session</a>😎</p> | ||
<p align="center">Idiomatic Session Module for NestJS. Built on top of <a href="https://npm.im/express-session">express-session</a> 😎</p> | ||
@@ -156,76 +156,4 @@ This module implements a session with storing data in one of [external stores](https://github.com/expressjs/session#compatible-session-stores) and passing ID of session to client via `Cookie`/`Set-Cookie` headers. | ||
--- | ||
<h2 align="center">Do you use this library?<br/>Don't be shy to give it a star! ★</h2> | ||
Also if you are into NestJS ecosystem you may be interested in one of my other libs: | ||
[nestjs-pino](https://github.com/iamolegga/nestjs-pino) | ||
[![GitHub stars](https://img.shields.io/github/stars/iamolegga/nestjs-pino?style=flat-square)](https://github.com/iamolegga/nestjs-pino) | ||
[![npm](https://img.shields.io/npm/dm/nestjs-pino?style=flat-square)](https://www.npmjs.com/package/nestjs-pino) | ||
Platform agnostic logger for NestJS based on [pino](http://getpino.io/) with request context in every log | ||
--- | ||
[nestjs-session](https://github.com/iamolegga/nestjs-session) | ||
[![GitHub stars](https://img.shields.io/github/stars/iamolegga/nestjs-session?style=flat-square)](https://github.com/iamolegga/nestjs-session) | ||
[![npm](https://img.shields.io/npm/dm/nestjs-session?style=flat-square)](https://www.npmjs.com/package/nestjs-session) | ||
Idiomatic session module for NestJS. Built on top of [express-session](https://www.npmjs.com/package/express-session) | ||
--- | ||
[nestjs-cookie-session](https://github.com/iamolegga/nestjs-cookie-session) | ||
[![GitHub stars](https://img.shields.io/github/stars/iamolegga/nestjs-cookie-session?style=flat-square)](https://github.com/iamolegga/nestjs-cookie-session) | ||
[![npm](https://img.shields.io/npm/dm/nestjs-cookie-session?style=flat-square)](https://www.npmjs.com/package/nestjs-cookie-session) | ||
Idiomatic cookie session module for NestJS. Built on top of [cookie-session](https://www.npmjs.com/package/cookie-session) | ||
--- | ||
[nestjs-roles](https://github.com/iamolegga/nestjs-roles) | ||
[![GitHub stars](https://img.shields.io/github/stars/iamolegga/nestjs-roles?style=flat-square)](https://github.com/iamolegga/nestjs-roles) | ||
[![npm](https://img.shields.io/npm/dm/nestjs-roles?style=flat-square)](https://www.npmjs.com/package/nestjs-roles) | ||
Type safe roles guard and decorator made easy | ||
--- | ||
[nestjs-injectable](https://github.com/segmentstream/nestjs-injectable) | ||
[![GitHub stars](https://img.shields.io/github/stars/segmentstream/nestjs-injectable?style=flat-square)](https://github.com/segmentstream/nestjs-injectable) | ||
[![npm](https://img.shields.io/npm/dm/nestjs-injectable?style=flat-square)](https://www.npmjs.com/package/nestjs-injectable) | ||
`@Injectable()` on steroids that simplifies work with inversion of control in your hexagonal architecture | ||
--- | ||
[nest-ratelimiter](https://github.com/iamolegga/nestjs-ratelimiter) | ||
[![GitHub stars](https://img.shields.io/github/stars/iamolegga/nestjs-ratelimiter?style=flat-square)](https://github.com/iamolegga/nestjs-ratelimiter) | ||
[![npm](https://img.shields.io/npm/dm/nest-ratelimiter?style=flat-square)](https://www.npmjs.com/package/nest-ratelimiter) | ||
Distributed consistent flexible NestJS rate limiter based on Redis | ||
--- | ||
[create-nestjs-middleware-module](https://github.com/iamolegga/create-nestjs-middleware-module) | ||
[![GitHub stars](https://img.shields.io/github/stars/iamolegga/create-nestjs-middleware-module?style=flat-square)](https://github.com/iamolegga/create-nestjs-middleware-module) | ||
[![npm](https://img.shields.io/npm/dm/create-nestjs-middleware-module?style=flat-square)](https://www.npmjs.com/package/create-nestjs-middleware-module) | ||
Create simple idiomatic NestJS module based on Express/Fastify middleware in just a few lines of code with routing out of the box | ||
--- | ||
[nestjs-configure-after](https://github.com/iamolegga/nestjs-configure-after) | ||
[![GitHub stars](https://img.shields.io/github/stars/iamolegga/nestjs-configure-after?style=flat-square)](https://github.com/iamolegga/nestjs-configure-after) | ||
[![npm](https://img.shields.io/npm/dm/nestjs-configure-after?style=flat-square)](https://www.npmjs.com/package/nestjs-configure-after) | ||
Declarative configuration of NestJS middleware order | ||
<h3 align="center">Also if you are into NestJS you might be interested in one of my <a href="https://github.com/iamolegga#nestjs">other NestJS libs</a>.</h3> |
@@ -6,3 +6,3 @@ "use strict"; | ||
function createRetriesMiddleware(sessionMiddleware, retries, retiesStrategy = () => 0) { | ||
return (req, res, next) => { | ||
return async (req, res, next) => { | ||
let attempt = 0; | ||
@@ -25,3 +25,3 @@ async function lookupSession(error) { | ||
} | ||
lookupSession(); | ||
await lookupSession(); | ||
}; | ||
@@ -28,0 +28,0 @@ } |
24
76
13255
158
+ Added@nestjs/common@10.4.15(transitive)
+ Addedcreate-nestjs-middleware-module@0.3.1(transitive)
- Removed@nestjs/common@11.0.7(transitive)
- Removedcreate-nestjs-middleware-module@0.2.2(transitive)