Skip to content

Commit

Permalink
Rewrite/classes (#10)
Browse files Browse the repository at this point in the history
* Rewrote memory.js to classes

* Rewrote memory.js to classes

* Remove older node versions.

* Add express again.

* Make eslint work again.

* Remove shrinkwrap.

* Use latest ecmaVersion.

* Convert cookie to class.

* Updated dependencies.

* Use after.

* Use package json 3.

* Added scoped nyc.

* Fixed.

* Use v3 checkout.

* Moved store to class based approach.

* Fixed indentation.

* Converted session to class based approach.
  • Loading branch information
SamTV12345 committed Jul 28, 2023
1 parent 880c6e8 commit b2082b4
Show file tree
Hide file tree
Showing 16 changed files with 3,500 additions and 1,992 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Expand Up @@ -6,6 +6,6 @@ charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true

[{*.js,*.json,*.yml}]
[{*.js,*.json,*.yml,*.ts}]
indent_size = 2
indent_style = space
2 changes: 2 additions & 0 deletions .eslintrc.yml
@@ -1,4 +1,6 @@
root: true
parserOptions:
ecmaVersion: latest
extends:
- plugin:markdown/recommended
plugins:
Expand Down
94 changes: 7 additions & 87 deletions .github/workflows/ci.yml
Expand Up @@ -10,94 +10,13 @@ jobs:
strategy:
matrix:
name:
- Node.js 0.10
- Node.js 0.12
- io.js 1.x
- io.js 2.x
- io.js 3.x
- Node.js 4.x
- Node.js 5.x
- Node.js 6.x
- Node.js 7.x
- Node.js 8.x
- Node.js 9.x
- Node.js 10.x
- Node.js 11.x
- Node.js 12.x
- Node.js 13.x
- Node.js 14.x
- Node.js 15.x
- Node.js 16.x
- Node.js 17.x
- Node.js 18.x
- Node.js 19.x
- Node.js 20.x

include:
- name: Node.js 0.10
node-version: "0.10"
npm-i: mocha@2.5.3 nyc@10.3.2 supertest@2.0.0

- name: Node.js 0.12
node-version: "0.12"
npm-i: mocha@2.5.3 nyc@10.3.2 supertest@2.0.0

- name: io.js 1.x
node-version: "1.8"
npm-i: mocha@2.5.3 nyc@10.3.2 supertest@2.0.0

- name: io.js 2.x
node-version: "2.5"
npm-i: mocha@2.5.3 nyc@10.3.2 supertest@2.0.0

- name: io.js 3.x
node-version: "3.3"
npm-i: mocha@2.5.3 nyc@10.3.2 supertest@2.0.0

- name: Node.js 4.x
node-version: "4.9"
npm-i: mocha@5.2.0 nyc@11.9.0 supertest@3.4.2

- name: Node.js 5.x
node-version: "5.12"
npm-i: mocha@5.2.0 nyc@11.9.0 supertest@3.4.2

- name: Node.js 6.x
node-version: "6.17"
npm-i: mocha@6.2.2 nyc@14.1.1 supertest@6.1.6

- name: Node.js 7.x
node-version: "7.10"
npm-i: mocha@6.2.2 nyc@14.1.1 supertest@6.1.6

- name: Node.js 8.x
node-version: "8.17"
npm-i: mocha@7.2.0

- name: Node.js 9.x
node-version: "9.11"
npm-i: mocha@7.2.0

- name: Node.js 10.x
node-version: "10.24"
npm-i: mocha@8.4.0

- name: Node.js 11.x
node-version: "11.15"
npm-i: mocha@8.4.0

- name: Node.js 12.x
node-version: "12.22"
npm-i: mocha@9.2.2

- name: Node.js 13.x
node-version: "13.14"
npm-i: mocha@9.2.2

- name: Node.js 14.x
node-version: "14.19"

- name: Node.js 15.x
node-version: "15.14"

- name: Node.js 16.x
node-version: "16.15"

Expand All @@ -106,19 +25,20 @@ jobs:

- name: Node.js 18.x
node-version: "18.0"
- name: Node.js 19.x
node-version: "19.0"
- name: Node.js 20.x
node-version: "20.0"

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install Node.js ${{ matrix.node-version }}
shell: bash -eo pipefail -l {0}
run: |
nvm install --default ${{ matrix.node-version }}
dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH"
- name: Configure npm
run: npm config set shrinkwrap false

- name: Remove npm module(s) ${{ matrix.npm-rm }}
run: npm rm --silent --save-dev ${{ matrix.npm-rm }}
if: matrix.npm-rm != ''
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@
coverage
node_modules
npm-debug.log
.idea
15 changes: 15 additions & 0 deletions README.md
Expand Up @@ -541,6 +541,21 @@ This is primarily used when the store will automatically delete idle sessions
and this method is used to signal to the store the given session is active,
potentially resetting the idle timer.

## Typescript usage
A TypeScript definition file is included in this package so you should be ready to go right away.

You can define the type for your own session data using [declaration merging](https://www.typescriptlang.org/docs/handbook/declaration-merging.html). Just put the following code in a `.d.ts` file and your custom properties will be recognized by the compiler:
```ts
interface SessionData {
// You can define your own properties here like this:
userId: string;
viewCount: number;
// ...and the list goes on...
}
```

It should also be noted that although the injected `session` and `sessionID` fields on the express [`Request`](https://expressjs.com/en/api.html#req) interface aren't defined as optional, they won't exist until you actually [use](#example) the middleware.

## Compatible Session Stores

The following modules implement a session store that is compatible with this
Expand Down

0 comments on commit b2082b4

Please sign in to comment.