Socket
Socket
Sign inDemoInstall

connect-typeorm

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

connect-typeorm

A TypeORM-based session store


Version published
Weekly downloads
5.7K
decreased by-1.19%
Maintainers
1
Weekly downloads
 
Created
Source

connect-typeorm

A TypeORM-based session store.

Usage

Configure TypeORM with back end of your choice:

yarn add @types/express-session connect-typeorm express-session typeorm sqlite3

Implement the Session entity:

// src/domain/Session/Session.ts

import { ISession } from "connect-typeorm";
import { Column, Entity, Index, PrimaryColumn } from "typeorm";
import { Bigint } from "typeorm-static";

@Entity()
export class Session implements ISession {
  @Index()
  @Column("bigint", { transformer: Bigint })
  public expiredAt: number;

  @PrimaryColumn("varchar", { length: 255 })
  public id: string;

  @Column()
  public json: string;
}

Pass repository to TypeormStore:

// src/app/Api/Api.ts

import * as Express from "express";
import * as ExpressSession from "express-session";
import { Db } from "typeorm-static";
import { Session } from "../../domain/Session/Session";

export class Api {
  public sessionRepository = Db.connection.getRepository(Session);

  public express = Express()
    .use(ExpressSession({
      store: new TypeormStore({ ttl: 86400 }).connect(this.sessionRepository),
      secret: "keyboard cat",
    }));
}

Options

Constructor receives an object. Following properties may be included:

  • ttl Session time to live (expiration) in seconds. Defaults to session.maxAge (if set), or one day. This may also be set to a function of the form (store, sess, sessionID) => number.

License

MIT

FAQs

Package last updated on 06 Nov 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc