fastify-session-better-sqlite3-store 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,36 +2,25 @@ name: ci
2
2
 
3
3
  on:
4
4
  push:
5
- branches: [ main ]
5
+ branches: [ "main" ]
6
6
  pull_request:
7
- branches: [ main ]
7
+ branches: [ "main" ]
8
8
 
9
9
  jobs:
10
+ ci:
11
+ runs-on: ${{ matrix.os }}
10
12
 
11
- tests-ubuntu:
13
+ strategy:
14
+ matrix:
15
+ os: [ubuntu-latest, windows-latest, macOs-latest]
16
+ node-version: [12.x, 14.x, 16.x, 18.x]
12
17
 
13
- runs-on: ubuntu-latest
14
-
15
18
  steps:
16
-
17
- - uses: actions/checkout@v2
18
-
19
- - name: Install Dependencies
20
- run: npm install
21
-
22
- - name: run tests
23
- run: npm run test
24
-
25
- tests-windows:
26
-
27
- runs-on: windows-latest
28
-
29
- steps:
30
-
31
- - uses: actions/checkout@v2
32
-
33
- - name: Install Dependencies
34
- run: npm install
35
-
36
- - name: run tests
37
- run: npm run test
19
+ - uses: actions/checkout@v3
20
+ - name: Use Node.js ${{ matrix.node-version }}
21
+ uses: actions/setup-node@v3
22
+ with:
23
+ node-version: ${{ matrix.node-version }}
24
+ cache: 'npm'
25
+ - run: npm ci
26
+ - run: npm test
@@ -20,4 +20,4 @@ jobs:
20
20
  run: npm i -D standard
21
21
 
22
22
  - name: Check code style format
23
- run: npx standard *.js
23
+ run: npm run lint
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "fastify-session-better-sqlite3-store",
3
- "version": "1.0.6",
3
+ "version": "1.0.7",
4
4
  "description": "A simple session store for fastify-session using better-sqlite3",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "lint": "npx standard *.js",
7
+ "lint": "npx standard *.js test/*.js",
8
+ "lint-fix": "npx standard --fix *.js test/*.js",
8
9
  "test": "node test/first.test && node test/second.test"
9
10
  },
10
11
  "repository": {
@@ -1,4 +1,4 @@
1
- const fastify = require('fastify')({ logger: true })
1
+ const fastify = require('fastify')({ logger: false })
2
2
  const fastifyCookie = require('@fastify/cookie')
3
3
  const fastifySession = require('@fastify/session')
4
4
  const sqlite3db = require('better-sqlite3')('./test/sqlite.db')
@@ -53,20 +53,27 @@ async function start () {
53
53
 
54
54
  const subject1 = await httpGetRequest(fastify, '/session')
55
55
  const subject2 = await httpGetRequest(fastify, '/set/subject2')
56
+
56
57
  const cookie1 = {
57
58
  sessionId: subject2.cookies[0].value
58
59
  }
60
+
59
61
  const subject3 = await httpGetRequest(fastify, '/session', cookie1)
60
62
  const subject4 = await httpGetRequest(fastify, '/destroy', cookie1)
61
63
  const subject5 = await httpGetRequest(fastify, '/session', cookie1)
62
64
  const subject6 = await httpGetRequest(fastify, '/set/subject6')
65
+
63
66
  const cookie2 = {
64
67
  sessionId: subject6.cookies[0].value
65
68
  }
69
+
66
70
  const subject7 = await httpGetRequest(fastify, '/session', cookie2)
67
- await setTimeoutAsync(8000)
71
+
72
+ await setTimeoutAsync(6000)
73
+
68
74
  const subject8 = await httpGetRequest(fastify, '/session', cookie2)
69
75
  const subject9 = await httpGetRequest(fastify, '/set/subject9')
76
+
70
77
  const cookie3 = {
71
78
  sessionId: subject9.cookies[0].value
72
79
  }
@@ -85,13 +92,13 @@ async function start () {
85
92
  await saveJsonFile('test/cookie.json', cookie3)
86
93
 
87
94
  if (t.results()) {
88
- console.log(t.testName, '=> PASSED ALL TEST\n')
95
+ console.log('\n', t.testName, '=> PASSED ALL TEST\n')
89
96
  } else {
90
- console.log(t.testName, '=> FAILED SOME TEST\n')
97
+ console.log('\n', t.testName, '=> FAILED SOME TEST\n')
91
98
  process.exit(1)
92
99
  }
93
100
  } catch (err) {
94
- fastify.log.error(err)
101
+ console.error(err)
95
102
  process.exit(1)
96
103
  }
97
104
  }
@@ -1,4 +1,4 @@
1
- const fastify = require('fastify')({ logger: true })
1
+ const fastify = require('fastify')({ logger: false })
2
2
  const fastifyCookie = require('@fastify/cookie')
3
3
  const fastifySession = require('@fastify/session')
4
4
  const sqlite3db = require('better-sqlite3')('./test/sqlite.db')
@@ -24,7 +24,7 @@ fastify.get('/session', (request, reply) => {
24
24
  }
25
25
  })
26
26
 
27
- const { SmallTest, httpGetRequest, readJsonFile } = require('./SmallTest')
27
+ const { SmallTest, httpGetRequest, readJsonFile, setTimeoutAsync } = require('./SmallTest')
28
28
 
29
29
  async function start () {
30
30
  const t = new SmallTest('TEST SET CASE 2')
@@ -33,18 +33,24 @@ async function start () {
33
33
 
34
34
  const cookie = await readJsonFile('test/cookie.json')
35
35
  const subject9 = await httpGetRequest(fastify, '/session', cookie)
36
+
37
+ await setTimeoutAsync(6000)
38
+
39
+ const subject10 = await httpGetRequest(fastify, '/session', cookie)
40
+
36
41
  t.assertEqual('session existing after server restart', subject9.payload, 'session:subject9')
42
+ t.assertEqual('session expired', subject10.payload, 'session:no-user')
37
43
 
38
44
  await fastify.close()
39
45
 
40
46
  if (t.results()) {
41
- console.log(t.testName, '=> PASSED ALL TEST\n')
47
+ console.log('\n', t.testName, '=> PASSED ALL TEST\n')
42
48
  } else {
43
- console.log(t.testName, '=> FAILED SOME TEST\n')
49
+ console.log('\n', t.testName, '=> FAILED SOME TEST\n')
44
50
  process.exit(1)
45
51
  }
46
52
  } catch (err) {
47
- fastify.log.error(err)
53
+ console.error(err)
48
54
  process.exit(1)
49
55
  }
50
56
  }