0.2.7 • Published 8 months ago

osprey-js v0.2.7

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Simple toolkit to boost your Bun Server development.

osprey-logo

So simple So familiar!

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

8 months ago

0.2.0

8 months ago

0.2.7

8 months ago

0.2.6

8 months ago

0.2.3

8 months ago

0.2.2

8 months ago

0.2.5

8 months ago

0.2.4

8 months ago

0.0.74

1 year ago

0.0.76

1 year ago

0.0.79

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.4

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.0.73

1 year ago

0.0.72

1 year ago

0.0.71

1 year ago

0.0.70

1 year ago

0.0.69

1 year ago

0.0.68

1 year ago

0.0.66

1 year ago

0.0.65

1 year ago

0.0.64

1 year ago

0.0.62

1 year ago

0.0.61

1 year ago

0.0.60

1 year ago

0.0.59

1 year ago

0.0.58

1 year ago

0.0.57

1 year ago

0.0.56

1 year ago

0.0.55

1 year ago

0.0.54

1 year ago

0.0.53

1 year ago

0.0.52

1 year ago

0.0.51

1 year ago

0.0.48

1 year ago

0.0.47

1 year ago

0.0.46

1 year ago

0.0.45

1 year ago

0.0.44

1 year ago

0.0.43

1 year ago

0.0.42

1 year ago

0.0.41

1 year ago

0.0.40

1 year ago

0.0.39

1 year ago

0.0.38

1 year ago

0.0.36

1 year ago

0.0.35

1 year ago

0.0.34

1 year ago

0.0.33

1 year ago

0.0.32

1 year ago

0.0.31

1 year ago

0.0.28

1 year ago

0.0.27

1 year ago

0.0.26

1 year ago

0.0.25

1 year ago

0.0.24

1 year ago

0.0.23

1 year ago

0.0.22

1 year ago

0.0.21

1 year ago

0.0.20

1 year ago

0.0.19

1 year ago

0.0.18

1 year ago

0.0.17

1 year ago

0.0.16

1 year ago

0.0.15

1 year ago

0.0.14

1 year ago

0.0.13

1 year ago

0.0.12

1 year ago

0.0.11

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago