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 🙏

© 2024 – Pkg Stats / Ryan Hefner

osprey-js

v0.2.7

Published

modern fast and lightweight backend framework

Downloads

22

Readme

Simple toolkit to boost your Bun Server development.

osprey-logo

So simple So familiar!

  • [x] Clean architecture. This package does not add something new to Bun, it just adds syntax sugar;
  • [x] Number of Decorators to create Controllers, Endpoints and Action Filters (like Nest.JS);
  • [x] Blazing fast router is faster than any you can find;
  • [ ] Work with WebSockets as with API (in progress);
  • [ ] Supports Swagger (in progress);
  • [x] Built-in logger;

Try it right now bun i osprey-js, pnpm i osprey-js.


Let's check it out!

Dependencies. Bun has a lot of built-in functions and this allows to exclude all dependencies from the package. It protects your projects from slow development of packages that you can't change. Each line of code is implemented just with Bun and TypeScript. The only dependency is router. Let's read about it next.

Router. For now npm has 3 fast routers: httprouter, koa-tree-router and road-runner. They all pretty fast, but koa-tree-router works only with koa and httprouter is implemented for Go. That's why I chose the road-runner. It has simplicity of koa-tree-router and speed of httprouter.

Here are the benchmark results: benchmark results

For the insane speed of the bun, we need an insane fast router, right?

Supported Path Syntax:

  • /foo
  • /:foo
  • /*
  • /foo/:bar
  • /foo/*
  • /foo/:bar/baz
  • /foo/*/baz
  • /foo/:bar/baz/:bum
  • /foo//baz/
  • /foo/:bar/baz/*
  • /foo/*/baz/:bum

Syntax sugar. To get started, you need to know how it works. Decorators have a lot of power in terms of route handling and parameters processing. But one huge disadvantage is their behaviour. Decorators runs once and developer need to figure out how to store some date to use it in root method. For this purpose a lot of packages use reflect-metadata package. That's ok for data storage but this solution has drawback: reflect is used in runtime and your code spends unnecessary memory and amount of time just to obtain some data from reflect. Osprey solves this problem. It updates decorated methods and even can edit it a bit. As a result, in runtime Osprey only calls methods that you wrote yourself!

Methods description and Examples

Decorators are divided into several groups.

  • @Controller
  • Methods: @Get, @Post, @Put, @Patch, @Delete,
  • Action Filters: CreateAuthorisationFilter, CreateResourceFilter, CreateBeforeFilter, CreateAfterFilter, CreateExceptionFilter
  • Request parameters: @Body, @Param, @Params, @Query, @FormData, @Request