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

nite-server-side

v1.1.0

Published

Scalable Server side framework for NITE

Readme

Absolutely! Here's a complete, ready-to-use README.md for NITE Server-Side. You can copy it directly into your project.


# NITE Server-Side

**NITE Server-Side** is a scalable, TypeScript-first server-side framework designed to simplify API creation with decorators, action classes, and automatic JSON serialization.  
It enforces best practices by requiring that action methods are explicitly serialized before returning data.

---

## Features

- ⚡ **Decorator-based routing** (`@Get`, `@Post`)  
- 🛡️ **Automatic serialization enforcement** via `@Serialize`  
- 🧩 **Separation of concerns**: Controllers delegate logic to Action classes  
- 🌐 **CORS support**  
- 🔥 **TypeScript-first**, fully typed responses  
- 🚨 **Startup validation** to ensure all action methods are properly decorated  

---

## Installation

```bash
npx nite-server-side

TypeScript is required:

npm install typescript @types/node --save-dev

Project Structure

src/
├─ controllers/
│  └─ UserController.ts
├─ actions/
│  └─ UserAction.ts
├─ types/
│  └─ userType.ts
---

## Getting Started

### **1. Define Action Classes**

Action classes contain the business logic. Every method **must** be decorated with `@Serialize`:

```ts
import { Serialize } from '../../library/modules/decorators/api-route-names';

export class UserAction {
    @Serialize
    async sayHelloWorld() {
        return { success: true, message: 'Hello world', data: null };
    }

    @Serialize
    async createUser(email: string, password: string) {
        return { success: true, message: 'User created', data: { token: 'abc123' } };
    }
}

2. Define Controllers

Controllers define the API routes and delegate logic to actions:

import { Get, Post, ParseBody } from '../../library/modules/decorators/api-route-names';
import { UserAction } from '../actions/UserAction';
import type { CreateUserType } from '../types/userType';

export class UserController {
    constructor(private readonly userAction: UserAction = new UserAction()) {}

    @Get('/api/ping-server')
    async pingServer() {
        return await this.userAction.sayHelloWorld();
    }

    @Post('/api/create-user')
    @ParseBody
    async createUser(body: CreateUserType) {
        return await this.userAction.createUser(body.email, body.password);
    }

    @Get('/')
    async greet() {
        return { message: 'Hello world' };
    }
}

3. Setup the Server

Register controllers and actions with APIHandler, validate serialization, then start the server:

import { ServerHandler } from 'nite-server-side';
import { UserController } from './controllers/UserController';
import { UserAction } from './actions/UserAction';

ServerHandler.registerControllers([UserController]);
ServerHandler.registerActions([UserAction]);

// Validate all registered action methods have @Serialize
ServerHandler.validateSerializedActions();

ServerHandler.listen(3000, { cors: true });

4. Making Requests

Ping the server

const pingServer = async () => {
  const res = await fetch('http://localhost:3000/api/ping-server');
  const json = await res.json();
  console.log(json); // { success: true, message: 'Hello world', data: null }
};

Create a user

const createUser = async () => {
  const res = await fetch('http://localhost:3000/api/create-user', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ email: '[email protected]', password: '123456' })
  });
  const json = await res.json();
  console.log(json);
};

Decorators

| Decorator | Usage | Description | | ------------- | ---------------------- | --------------------------------------------------------------------------------- | | @Get(path) | @Get('/api/ping') | Maps a method to a GET route | | @Post(path) | @Post('/api/create') | Maps a method to a POST route | | @ParseBody | @ParseBody | Automatically parses JSON request body | | @Serialize | @Serialize | Ensures method output is serialized to JSON; mandatory for registered actions | | @Required | @Required | Ensures controller/action registration |

Much More.....

Best Practices

  • Always decorate action methods with @Serialize.
  • Keep controllers thin; delegate business logic to actions.
  • Register all actions using registerActions() to enable serialization validation.
  • Use validateSerializedActions() before listen() to catch missing decorators at startup.

Error Handling

If an action method is missing @Serialize, the server will throw immediately:

🚨 Action method "sayHelloWorld" in "UserAction" must have @Serialize decorator!

This prevents runtime errors and ensures consistent API responses.


License

ISC – Nicholas Johnson


Contributing

  1. Fork the repository
  2. Make your changes in a feature branch
  3. Open a pull request

Summary

NITE Server-Side is designed for:

  • Type-safe, decorator-based API development
  • Strict enforcement of JSON serialization in action methods
  • Clean separation of controllers and actions

It’s perfect for scalable Node.js projects using TypeScript, enforcing consistency and best practices out of the box.