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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@studious-lms/server

v1.2.47

Published

Backend server for Studious application

Readme

Studious Backend Server

This is the backend server for the Studious application. It provides a RESTful and real-time API for managing users, classes, assignments, attendance, and more, supporting both HTTP (via tRPC) and WebSocket (via Socket.IO) communication.

Features

  • Express.js server with CORS support
  • tRPC for type-safe API endpoints
  • Socket.IO for real-time features
  • Prisma ORM with PostgreSQL for database management
  • User authentication and session management
  • Class, assignment, attendance, and file management
  • Structured logging for requests and server events

Getting Started

Prerequisites

  • Node.js (v18+ recommended)
  • npm (v9+ recommended)
  • PostgreSQL database

Installation

  1. Clone the repository:

    git clone <repo-url>
    cd server
  2. Install dependencies:

    npm install
  3. Set up environment variables: Copy the example environment file and update with your values:

    cp .env.example .env

    Then edit .env with your configuration. See .env.example for all required variables.

  4. Set up the database:

    • Create a PostgreSQL database named easy_lms
    • Run the Prisma migrations:
      npx prisma migrate dev --name init
    • Generate the Prisma client:
      npx prisma generate

Running the Server

  • Development mode (with hot reload):

    npm run dev
  • Production build:

    npm run build
    npm start

The server will start on the port specified in your .env file (default: 3001).

API Overview

  • tRPC endpoints: Available at /trpc
  • WebSocket: Available at /socket.io/
  • CORS: Configured to allow requests from the frontend app URL via NEXT_PUBLIC_APP_URL

Project Structure

src/
  index.ts         # Main server entry point
  routers/         # tRPC routers for API endpoints
  socket/          # Socket.IO event handlers
  middleware/      # Express and tRPC middleware
  utils/           # Utility functions (e.g., logger)
  lib/             # Shared libraries
  types/           # TypeScript types
prisma/
  schema.prisma    # Prisma database schema
  migrations/      # Database migrations

Database

  • Database: PostgreSQL
  • ORM: Prisma
  • Schema: Defined in prisma/schema.prisma
  • Migrations: Stored in prisma/migrations/

Database Commands

# Generate Prisma client
npx prisma generate

# Run migrations
npx prisma migrate dev

# Reset database
npx prisma migrate reset

# Open Prisma Studio (database GUI)
npx prisma studio

Scripts

  • npm run dev — Start in development mode with hot reload
  • npm run build — Compile TypeScript to JavaScript
  • npm start — Start the compiled server
  • npm test — Run tests with Vitest
  • npm run test:run — Run tests once
  • npm run test:watch — Run tests in watch mode
  • npm run test:coverage — Run tests with coverage report

Environment Variables

| Variable | Description | Default | |----------|-------------|---------| | DATABASE_URL | PostgreSQL connection string | Required | | PORT | Server port | 3001 | | NEXT_PUBLIC_APP_URL | Frontend app URL for CORS | http://localhost:3000 | | NODE_ENV | Environment mode | development | | LOG_MODE | Logging level | info |

Development

The server uses TypeScript and includes:

  • tRPC for type-safe API development
  • Socket.IO for real-time communication
  • Prisma for database operations
  • Express middleware for CORS and logging

Testing

Tests use a separate environment configuration:

  1. Set up test environment:

    cp .env.test.example .env.test

    Update .env.test with your test database configuration.

  2. Create test database:

    createdb easy_lms_test
  3. Run tests:

    npm test

The test environment:

  • Uses a separate database (easy_lms_test)
  • Runs on a different port (3002)
  • Has minimal logging (error level only)
  • Mocks external services (Google Cloud, Pusher, etc.)

License

MIT