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

@rgwch/mikrorest

v0.8.1

Published

A minimal REST server

Downloads

37

Readme

MikroRest Server

A minimal, but fully functional REST server in TypeScript for Node.js. Use for proof-of-concepts, simple private servers, and more.

Install

npm i --save @rgwch/mikrorest

Use

// Make sure environment variables MIKROREST_API_KEYS or MIKROREST_JWT_SECRET are set.

import {MikroRest} from '@rgwch/mikrorest'
import path from 'path'

// Create server
const server=new MikroRest()

// Add open routes
server.addRoute("get", "/api/sayhello",async (req,res)=>{
  server.sendPlain(res,"Hello, world")
  return false
})
// Add protected routes (optional)
server.addRoute("get", "/api/tellme", server.authorize,async (req,res)=>{
  server.sendPlain(res,"it's a secret")
  return false
})
// Add static files directory (optional, directory must exist)
server.addStaticDir(path.join(__dirname, "../../client/dist"));

// Implement login (optional)
server.handleLogin("/api/login",async (username,password)=>{
  // Do some checks to verify
  return {checkeduser: username}
})

// Start server
server.start()

See also src/demo.ts. Run with npm run demo or npx ts-node src/demo.ts

Built-in authentication

You can use MikroRest's built-in authorization system (of course you can use your own as well). There are two possible ways:

(1) Provide a MIKROREST_API_KEYS environment variable with a comma-separated list of valid API keys. The client must then send an "Authorization: Bearer <key>" header with every request.

(2) Call the handleLogin() method with a route and an authentication function as parameters. If you do so, MikroRest will create a login route at the specified location and call the authentication function if the user POSTs to that login route with username and password in the JSON body. If the authentication function returns an object, a JWT token is created and returned together with that object to the client. Note: You must provide a MIKROREST_JWT_SECRET environment variable which gives the secret key to sign the JWT token. The client must then include an "Authorization: Token <token>" header with every request.

SSL

If you need an SSL server, you can pass pathnames for key and certificate to the constructor options.

API

See docs

Tests

Tests were mostly created by GitHub Copilot. See tests/README.md

Limitations

No path parameters, only query parameters. Things like http://localhost:3339/user/{name}/any?/load will not work with MikroRest. Use http://localhost:3339/user/load?name=name&any=thing instead. Or use a full-featured framework like Express.js or Koa.js.