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

@praveenkumar-s/nexus-core

v1.0.13

Published

An opinionated backend framework for MERN + Prisma

Readme

Nexus Core Framework 🚀

@praveenkumar-s/nexus-core

Nexus Core is an opinionated, zero-boilerplate backend framework for MERN Stack + Prisma applications. It abstracts away Controllers, Services, and Routes, allowing you to build production-ready CRUD APIs with Authentication, File Uploads, and Role-Based Access Control (RBAC) in minutes.


✨ Features

  • Zero Boilerplate: No more writing repetitive Controllers, Services, or Routes.
  • Auto-CRUD: Instantly generates GET, POST, PUT, DELETE endpoints for any Prisma model.
  • Built-in Auth: JWT Authentication (Login, Register, Me) out of the box.
  • RBAC (Role-Based Access Control): Granular permission control (e.g., "Only Managers can Create").
  • File Uploads: Automatic FormData handling, local storage, and type sanitization.
  • Modular Architecture: Keep your logic clean with resource-based configuration.
  • Type-Safe: Built with TypeScript.

📦 Installation

# 1. Install the framework
npm install @praveenkumar-s/nexus-core

# 2. Install required peer dependencies
npm install prisma @prisma/client express cors bcryptjs jsonwebtoken multer uuid
npm install -D typescript ts-node @types/node @types/express @types/cors

⚡️ Quick Start

  1. Setup Database (prisma/schema.prisma) You must have a User model for authentication to work.
    datasource db {
    provider = "mongodb"
    url      = env("DATABASE_URL")
}

    generator client {
    provider = "prisma-client-js"
}

// REQUIRED: User model for Auth
model User {
    id       String @id @default(auto()) @map("_id") @db.ObjectId
    email    String @unique
    password String
    role     String @default("user") // admin, manager, user
}

// YOUR DATA: Example Resource
model Project {
    model Project {
  id          String   @id @default(auto()) @map("_id") @db.ObjectId
  name        String
  budget      Int
  proposalUrl String[]
  isActive    Boolean  @default(true)
}
}
  1. Create the Server (src/server.ts)
import { PrismaClient } from '@prisma/client';
import { NexusApp } from '@praveenkumar-s/nexus-core';

const prisma = new PrismaClient();

const app = new NexusApp({
prisma: prisma,
jwtSecret: process.env.JWT_SECRET || "super-secret-key",
port: 4000,

// Auth Settings
auth: {
    registrationStrategy: 'open', // 'open' or 'admin_only'
},

// Resource Definitions
resources: {
    Project: {
    publicMethods: ['GET'], // GET is open to everyone
    enableUpload: true,     // Enable file uploads
    uploadField: 'proposalUrl', // Database field to store file path
    
    // Role-Based Access Control
    methodRoles: {
        POST: ['admin', 'manager'], // Only Admin/Manager can Create
        DELETE: ['admin']           // Only Admin can Delete
    }
    }
}
});

app.start();

Run it: npx nodemon src/server.ts

📖 Advanced Usage

  1. Modular Resources (Best Practice) For larger apps, define resources in separate files.

src/resources/TicketResource.ts

import { ResourceDefinition } from '@praveenkumar-s/nexus-core';
import { Router, Request, Response } from 'express';

export const TicketResource: ResourceDefinition = {
  methodRoles: {
    POST: ['user', 'admin'], // Users can create tickets
    DELETE: ['admin']        // Only admin can delete
  },
  
  // Add Custom Endpoints
  extend: (router: Router, model: any) => {
    router.get('/stats/count', async (req: Request, res: Response) => {
      const count = await model.count();
      res.json({ success: true, count });
    });
  }
};

src/server.ts

import { TicketResource } from './resources/TicketResource';

const app = new NexusApp({
  // ...
  resources: {
    Ticket: TicketResource
  }
});
  1. Handling File Uploads (Frontend) When enableUpload: true is set, the backend expects multipart/form-data.

React Example:

const handleCreate = async () => {
  const formData = new FormData();
  formData.append('name', 'New Project');
  formData.append('budget', 5000); 
  // Nexus Core automatically converts "5000" (string) -> 5000 (int)
  
  formData.append('file', fileInput.files[0]); // Key must be 'file'

  await fetch('http://localhost:4000/api/projects', {
    method: 'POST',
    headers: { Authorization: `Bearer ${token}` }, // Do NOT set Content-Type
    body: formData
  });
};

🔌 API Reference

Once you register a resource (e.g., Project), these endpoints are auto-generated:

| Method | Endpoint | Access Control | Description | | :--- | :--- | :--- | :--- | | GET | /api/projects | Configurable | Get all projects | | GET | /api/projects/:id | Configurable | Get one project | | POST | /api/projects | Configurable | Create project (supports Upload) | | PUT | /api/projects/:id | Configurable | Update project | | DELETE | /api/projects/:id | Configurable | Delete project |

Auth Endpoints

| Method | Endpoint | Description | | :--- | :--- | :--- | | POST | /api/auth/register | Register (Email, Password, Role) | | POST | /api/auth/login | Login (Returns Token + User) | | GET | /api/auth/me | Get Current User Profile |

⚛️ React Context Adapter

Copy this file into your frontend to instantly connect with Nexus Core.

src/context/NexusAuthContext.tsx

import React, { createContext, useContext, useState, useEffect } from 'react';

const AuthContext = createContext<any>(null);

export const NexusAuthProvider = ({ children, apiUrl }: any) => {
  const [user, setUser] = useState(null);
  const [token, setToken] = useState(localStorage.getItem('token'));

  const login = async (email: string, pass: string) => {
    const res = await fetch(`${apiUrl}/api/auth/login`, {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ email, password: pass }),
    });
    const json = await res.json();
    if (json.success) {
      localStorage.setItem('token', json.data.token);
      setToken(json.data.token);
      setUser(json.data.user);
    } else {
      throw new Error(json.message);
    }
  };

  const logout = () => {
    localStorage.removeItem('token');
    setToken(null);
    setUser(null);
  };

  return (
    <AuthContext.Provider value={{ user, token, login, logout }}>
      {children}
    </AuthContext.Provider>
  );
};

export const useNexusAuth = () => useContext(AuthContext);

📄 License

Copyright © 2025 Praveenkumar S.

This project is licensed under the MIT License. You are free to use, modify, and distribute this software for any purpose, including commercial applications.

See the LICENSE file for more details.


👨‍💻 Developer & Maintainer

Nexus Core is built and maintained by Praveen Kumar.

I created this framework to solve the frustration of writing repetitive boilerplate code for every new MERN project. My goal is to help developers go from "Idea" to "Deployment" in minutes, not days.

GitHub

LinkedIn

NPM

Portfolio


🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

⭐️ Show your support

Give a ⭐️ if this project helped you!