Skip to main content
Deno 2 is finally here 🎉️
Learn more

!!! Status: WIP (use at your own risks) !!!

This project is currently experimental and may not work properly!

Pterosaur
Pterosaur

A lightweight router for Deno built with Typescript Decorators.

Licence MIT

Key FeaturesHow To UseExampleCreditsLicense

Key Features

  • Typescript with Decorators
  • Made for Deno
  • Lightweight
  • Zero third party dependencies (only std)
  • Highly customizable
  • Controller nesting (using @Include())
  • Native URLPattern routing

How To Use

Name is available via Deno’s Thrid Party Modules.

import { ... } from 'https://deno.land/x/pterosaur/mod.ts';

Create a simple controller class.

@Controller()
class SomeClass {
    // Methods here
}

Create a simple get method.

@Get()
someMethod() {
    return { success: true }
}

Create the application

const app: Application = new Application({
    controller: [SomeClass],
});

And register the handler. We use Deno’s Standard Library

await serve((request: Request) => app.handle(request), { port: 8080 });

And all together

import { ... } from 'https://deno.land/x/pterosaur/mod.ts';

@Controller()
class SomeClass {
    @Get()
    someMethod() {
        return { success: true }
    }
}

const app: Application = new Application({
    controller: [SomeClass],
});

await serve((request: Request) => app.handle(request), { port: 8080 });

Run the example

$ deno run --allow-net https://deno.land/x/pterosaur/examples/basic.ts

You may also like…

  • Alosaur - Another decorator based router

Credits

This software uses the following open source projects:

License

MIT


Homepage luke.id  ·  GitHub @lkwr  ·  Twitter @wlkrlk