Movatterモバイル変換


[0]ホーム

URL:


connect-session-knex
TypeScript icon, indicating that this package has built-in type declarations

5.0.0 • Public • Published

NPM VersionNPM DownloadsNode.js VersionNPM

connect-session-knex is anexpress-session store backed by PostgreSQL, MySQL, MariaDB, MSSQL, Oracle or SQLite3, via theknex.js library.

Installation

$ npm install connect-session-knex

History

SeeChangelog.md

Usage

Example application using the defaults

Example application with PostgreSQL

Options

  • cleanupInterval milliseconds between clearing expired sessions. Defaults to 60000. 0 disables the automatic clearing of expired sessions.
  • createTable if the table for sessions should be created automatically or not.
  • knex knex instance to use. Defaults to a new knex instance, using sqlite3 with a file named 'connect-session-knex.sqlite'
  • tableName='sessions' Tablename to use. Defaults to 'sessions'.
  • sidFieldName='sid' Field name in table to use for storing session ids. Defaults to 'sid'.

If the table does not exist in the schema, this module will attempt to create it unless thecreateTable option is false.

If a knex instance is not provided, this module will attempt to create a sqlite3 database, with a file namedconnect-session-knex.sqlite, in the working directory of the process.

Schema

PostgreSQL or SQLite

Table Name "sessions"

ColumnTypeModifiersStorage
sidcharacter varying(255)not nullextended
sessjsonnot nullextended
expiredtimestamp with time zonenot nullplain

Indexes:

    "sessions_pkey" PRIMARY KEY, btree (sid)    "sessions_expired_index" btree (expired)

MySQL

Table Namesessions.

ColumnTypeModifiers
sidVARCHAR(255)NOT NULL, PK
sessJSONNOT NULL
expiredDATETIMENOT NULL

Command to manually create table:

CREATETABLE `sessions` (`sid`VARCHAR(255)NOT NULL,`sess` JSONNOT NULL,`expired` DATETIMENOT NULL,PRIMARY KEY (`sid`));

Testing

Install Postgresql

Instructions for Ubuntu after intalling the db:

sudo -u postgres psql
CREATEDATABASEtravis_ci_test OWNER postgres;
GRANT all privilegesON DATABASE travis_ci_test TO postgres;
ALTERUSER postgres WITH PASSWORD'postgres';
\q

Install Mysql

Instructions for Ubuntu after installing the db:

sudo mysql -u root
createuser 'travis' identified by'travis';
ALTERUSER'travis'@'localhost' IDENTIFIED BY'travis';
createdatabasetravis_ci_test;
grant allon travis_ci_test.* to'travis';
\q
sudo service mysql restart

Make sure both the MySQL and Postgres services are running

npm runtest

Readme

Keywords

none

Package Sidebar

Install

npm i connect-session-knex

Weekly Downloads

173,419

Version

5.0.0

License

ISC

Unpacked Size

50.2 kB

Total Files

13

Last publish

Collaborators

  • omarryhan
  • gx0r

[8]ページ先頭

©2009-2025 Movatter.jp