Socket
Book a DemoInstallSign in
Socket

@diagramers/api

Package Overview
Dependencies
Maintainers
1
Versions
113
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@diagramers/api

Diagramers API - A comprehensive Node.js API template with TypeScript, Firebase Functions, and Socket.io

4.0.31
latest
Source
npmnpm
Version published
Weekly downloads
44
-84.17%
Maintainers
1
Weekly downloads
ย 
Created
Source

๐Ÿš€ Diagramers API

A comprehensive Node.js API framework built with TypeScript, Express, MongoDB, and built-in authentication and permission management.

๐ŸŽฏ Quick Start

Prerequisites

  • Node.js 18+
  • MongoDB 6+
  • npm or yarn

Installation

# Install dependencies
npm install

# Set up environment variables
cp .env.example .env
# Edit .env with your configuration

# Start development server
npm run dev

Environment Setup

# Database
MONGODB_URI=mongodb://localhost:27017/diagramers
MONGODB_DB=diagramers

# JWT
JWT_SECRET=your-secret-key
JWT_EXPIRES_IN=1h

# Server
PORT=3000
NODE_ENV=development

๐Ÿ—๏ธ Project Structure

src/
โ”œโ”€โ”€ core/                    # Core system components
โ”‚   โ”œโ”€โ”€ app.ts             # Application setup
โ”‚   โ”œโ”€โ”€ server/            # Server management
โ”‚   โ”œโ”€โ”€ database/          # Database connection & seeding
โ”‚   โ””โ”€โ”€ middleware/        # Authentication & permission middleware
โ”œโ”€โ”€ modules/               # Business logic modules
โ”‚   โ”œโ”€โ”€ auth/             # Authentication module
โ”‚   โ”œโ”€โ”€ user/             # User management
โ”‚   โ””โ”€โ”€ permission/       # Permission system
โ”œโ”€โ”€ shared/               # Shared utilities and types
โ”‚   โ”œโ”€โ”€ types/            # TypeScript interfaces
โ”‚   โ”œโ”€โ”€ utils/            # Utility functions
โ”‚   โ””โ”€โ”€ constants/        # System constants
โ””โ”€โ”€ routes/               # Route definitions

๐Ÿ” Authentication & Permissions

The API includes a comprehensive permission system:

  • JWT-based authentication with multiple provider support
  • Role-based access control with fine-grained permissions
  • Dynamic permission middleware for route protection
  • Resource-based permissions for ownership checks

๐Ÿ“š Documentation

For comprehensive development guides, examples, and best practices, see:

๐Ÿš€ Complete Developer Guide

The developer guide covers:

  • Module development from A to Z
  • Database design and entity creation
  • API endpoint development
  • Permission system setup
  • CLI commands and automation
  • Testing and deployment
  • Troubleshooting and best practices

๐ŸŽ›๏ธ Available Scripts

Development

npm run dev              # Start development server
npm run build            # Build for production
npm run start            # Start production server

Database

npm run seed             # Seed database with sample data
npm run setup:permissions # Initialize permission system
npm run setup:admin      # Create admin user

Module Generation

npm run generate:module  # Generate new module
npm run generate:table   # Generate new database table
npm run generate:endpoint # Generate new API endpoint

Utilities

npm run lint             # Run ESLint
npm run type-check       # TypeScript type checking
npm run format           # Format code with Prettier
npm run docs             # Generate API documentation

๐ŸŒ API Endpoints

Base URL

http://localhost:3000/api

Available Endpoints

  • GET /health - Health check
  • POST /auth/login - User authentication
  • GET /users - Get all users (requires authentication)
  • POST /users - Create new user (requires authentication)

Authentication

Include JWT token in Authorization header:

Authorization: Bearer <your-jwt-token>

Request Headers

x-request-id: MODULE_ACTION_UUID (optional)
x-correlation-id: <correlation-id> (optional)

๐Ÿงช Testing

# Run permission tests
npm run test:permissions

# Run all tests
npm test

๐Ÿš€ Deployment

# Build for production
npm run build

# Start production server
npm start

# Docker deployment
npm run docker:build
npm run docker:run

๐Ÿ”ง Configuration

Environment Variables

  • NODE_ENV - Environment (development/production)
  • PORT - Server port
  • MONGODB_URI - MongoDB connection string
  • JWT_SECRET - JWT signing secret
  • JWT_EXPIRES_IN - JWT expiration time

Database Configuration

  • MongoDB with Mongoose ODM
  • Automatic schema management
  • Built-in seeding and migration tools

๐Ÿ“– Examples

Creating a New Module

# Generate complete module structure
npm run generate:module -- --name=products --description="Product management"

# This creates:
# - Entity files (interfaces and schemas)
# - Service with CRUD operations
# - Controller with HTTP handlers
# - Routes with permission middleware
# - Swagger documentation

Permission Setup

# Initialize permission system
npm run setup:permissions

# Create admin user
npm run setup:admin

๐Ÿ†˜ Support

  • Documentation: Complete Developer Guide
  • Issues: Create issues in the project repository
  • Examples: Check existing modules in src/modules/

๐Ÿ“„ License

This project is licensed under the MIT License.

For complete development guides and examples, see the Developer Guide

Keywords

diagramers

FAQs

Package last updated on 23 Aug 2025

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.