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

statenext-api

v1.2.2

Published

statenext is web server builder.

Downloads

5

Readme

What is statenext-api ? | statenext-api คืออะไร ?

This is package that help you create API server with typescript faster. นี้คือ package ที่จะช่วยให้สร้าง API server ได้เร็วขึ้นด้วย typescript

What can statenext-api do ? | statenext-api ทำอะไรได้บ้าง​ ?

statenext-api is build on top of Express, I try to make developer write less code and more reuse. statenext-api สร้างต่อยอดจาก Express, เราพยายามจะทำให้ developer เขียน code น้อยลง แต่ reuse ได้เยอะขึ้น

features

  • meta-data based | ใช้ meta-data เป็นหลัก
  • one service all trasportation | สร้าง service เดียวใช้ได้ทุกรูปแบบ

Installation

npm i --save statenext-api

then import

import ServerBuilder, {SNRequest} from 'statenext-api'
import { Router, SocketBoardcastPayload } from 'statenext-api/lib/core/SystemManagement';

let routes:Router = {
    index: {
        path: "/",
        method: "get",
        middlewares: [],
        controller: "xs",
        action: "get",
        socket:{
            event_name: "get-xs",
        }
    },
    api: {
        hello: {
            path: "/",
            method: "get",
            middlewares: [],
            controller: "xs",
            action: "get",
        }
    }
}


let services = {
    xs:{
        get: async (req:SNRequest) => {

            req._receivers = [req.body.to]
            return ["hello world", req.body.message];
            
        }
    },

}

let server = new ServerBuilder()

server.setup({
    // services,
}).server.listen(8080, () => {
    console.log("listen on 8080")
})

Usages

use path create routes

example project structure

  • server.ts
  • /routes
    • index.ts
    • /api
      • hello.ts
  • /services
    • /xs
      • get.ts

routes example

export default {
    path: "/",
    method: "get",
    middlewares: [],
    controller: "xs",
    action: "get",
    socket:{
        event_name: "get-xs",
        boardcast:{
            type: "personal",
            event_name: "new-xs"
        }
    }
}

service example

import { SNRequest } from "statenext-api";

export default async (req:SNRequest) => {

    req._receivers = [req.body.to]
    return ["hello world", req.body.message];
            
}

server example

import ServerBuilder from 'statenext-api'

let server = new ServerBuilder()

server.usePath(__dirname + '/routes', __dirname + '/services')

server.setup({
    // services,
}).server.listen(8080, () => {
    console.log("listen on 8080")
})

CORS

you can allow cors by env like คุณสามารถ allow cors ได้เพียงแค่ใช้ env

ALLOW_ORIGIN=http://localhost

or multiple origins ถ้าจะใช้หลายๆอันก็ได้

ALLOW_ORIGIN=<domain1>
ALLOW_ORIGIN0=<domain2>
ALLOW_ORIGIN1=<domain3>
ALLOW_ORIGIN2=<domain4>
ALLOW_ORIGIN3=<domain5>