Functions and Classes for handle session with @nano/sqlite in Bun.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
HerrHase 4c870a46e1
adding
3 months ago
src adding 3 months ago
test adding 3 months ago
.env.test adding 3 months ago
.gitignore adding 3 months ago
LICENSE adding 3 months ago
README.md adding 3 months ago
bun.lockb adding 3 months ago
bunfig.toml adding 3 months ago
index.ts adding 3 months ago
package.json adding 3 months ago

README.md

Nano Session

Functions and Classes for handle session with @nano/sqlite in Bun.

API

Session

import { getOrCreateSqlite } from '@nano/sqlite'
const db = getOrCreateSqlite({ 'name': ':memory:', 'create': true, 'readwrite': true })
const session = new Session(db)

create(userId: number, agent: string, language: string, ip = '')

Create a new Session for User. Agent and Language from User will be used to create a Hmac value in the DB. The IP is optional. If one of these values are changed, the session is invalid. After Creating the session you get a Random Token, and the userId as hash.

get(userHash: string, token: string, agent: string, language: string, ip = '')

Get Session for User. If session has expired, the entry will be removed from Database.

destroy(sessionId: number)

Remove single Session for User with id of Session.

destroyAll(userId: number)

Remove all session for a User with UserId.