npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

node-django-sessions

v0.1.0

Published

A lightweight TypeScript/Node.js library that allows you to decode and use Django session data in your Node.js applications. Perfect for scenarios where you need to share authentication between Django and Node.js services.

Downloads

32

Readme

node-django-sessions

A lightweight TypeScript/Node.js library that allows you to decode and use Django session data in your Node.js applications. Perfect for scenarios where you need to share authentication between Django and Node.js services.

npm version License: MIT

Features

  • Decode Django session data in Node.js applications
  • TypeScript support out of the box
  • Handles both compressed and uncompressed session data
  • Easy integration with Express.js middleware
  • Supports custom secret keys and salt configurations

Installation

npm install node-django-sessions
# or
yarn add node-django-sessions

Usage

Basic Usage

import { decodeSession } from 'node-django-sessions';

// Session data from django_sessions table
const sessionData = "your_session_data_here";

try {
  const sessionInfo = await decodeSession(sessionData, {
    secretKey: 'your_django_secret_key'
  });
  
  console.log(sessionInfo);
  // Output:
  // {
  //   _auth_user_backend: "django.contrib.auth.backends.ModelBackend",
  //   _auth_user_hash: "test",
  //   _auth_user_id: "1",
  //   test: "test"
  // }
} catch (error) {
  console.error('Failed to decode session:', error);
}

Express Middleware Example

import { decodeSession } from 'node-django-sessions';
import express from 'express';

const app = express();

const djangoSessionMiddleware = async (req: any, res: any, next: any) => {
  try {
    const sessionId = req.cookies['sessionid'];  // or however you store your session ID

    // TODO: Add your own session data retrieval logic here
    const sessionData = await getSessionData(sessionId);

    if (!sessionData) {
      return res.status(401).json({ error: 'No session provided' });
    }

    const session = await decodeSession(sessionData);
    req.djangoSession = session;
    next();
  } catch (error) {
    res.status(401).json({ error: 'Invalid session' });
  }
};

app.use(djangoSessionMiddleware);

Configuration

The decodeSession function accepts the following options:

interface SessionOptions {
  secretKey?: string;  // Django's SECRET_KEY (can also be set via DJANGO_SECRET_KEY env var)
  salt?: string;       // Custom salt if your Django config uses one
}

Environment Variables

  • DJANGO_SECRET_KEY: Your Django project's secret key. This can be used instead of passing the key in options.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT

Credits

Inspired by the need to bridge Django and Node.js applications in modern microservice architectures.