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

@avisenaalwi/express-permission

v1.0.3

Published

A lightweight and customizable role and permission management library for Express.js with OracleDB support, inspired by Spatie Laravel Permission.

Downloads

71

Readme

express-permission

OracleDB Role and Permission Service for Express.js, inspired by Spatie Laravel Permission. Allows flexible and scoped role-permission management directly in your service layer.

  • ✅ Framework-agnostic – suitable for Express or any Node.js app
  • ✅ OracleDB native – no abstraction, no ORM
  • ✅ Scoped permissions – supports multi-tenancy (e.g. organization, team)
  • ✅ Simple API – check with hasPermission() or hasRole()

📦 Installation

npm install @avisenaalwi/express-permission oracledb

⚙️ Configuration

Create a permission.config.ts in your project root:

import { PermissionConfig } from '@avisenaalwi/express-permission';

const config: PermissionConfig = {
  userTable: 'USERS',
  userPrimaryKey: 'ID',

  roleTable: 'ROLES',
  rolePrimaryKey: 'ID',
  roleNameColumn: 'NAME',

  permissionTable: 'PERMISSIONS',
  permissionPrimaryKey: 'ID',
  permissionNameColumn: 'NAME',

  userRolesTable: 'USER_ROLE',
  userRolesUserId: 'USER_ID',
  userRolesRoleId: 'ROLE_ID',
  userRolesScopeParams: [
    { name: 'orgId', column: 'ORG_ID' }
  ],

  rolePermissionsTable: 'ROLE_PERMISSION',
  rolePermissionsRoleId: 'ROLE_ID',
  rolePermissionsPermissionId: 'PERMISSION_ID',
  rolePermissionsScopeParams: []
};

export default config;

🛠 Usage

1. Setup Oracle pool

import oracledb from 'oracledb';
import { PermissionService } from '@avisenaalwi/express-permission';

const pool = await oracledb.createPool({
  user: 'your_user',
  password: 'your_password',
  connectString: 'your_connect_string'
});

const permissionService = new PermissionService(pool);

2. Check Permission or Role

const userId = 42;

const hasEdit = await permissionService.hasPermission(userId, 'edit-post');
if (!hasEdit) {
  return res.status(403).json({ message: 'Forbidden' });
}

const isAdmin = await permissionService.hasRole(userId, 'admin');

With scope:

await permissionService.hasPermission(userId, 'edit-post', { orgId: 1001 });

3. Get all permissions or roles

const permissions = await permissionService.getPermissions(userId);
const roles = await permissionService.getRoles(userId);

✅ Table Requirements

You must provide:

  • users table with id
  • roles and permissions tables
  • user_roles relation table
  • role_permissions relation table

The names and columns can be fully customized via permission.config.ts.


📌 Optional Features

  • Multi-tenancy: Use scoped permission by adding columns like ORG_ID and declaring them in config.
  • You can extend PermissionService with caching (e.g. Redis) or override methods as needed.

🧪 Testing

// Example test
expect(await permissionService.hasPermission(1, 'read-dashboard')).toBe(true);

📤 Planned Features

  • CLI for migration and schema check
  • Middleware helpers for Express
  • Caching support (Redis)
  • Role/Permission sync like Spatie

📄 License

MIT © 2025 Avisena Alwi