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

dinoco

v0.1.2

Published

A flexible, type-safe server-side router for meta-frameworks

Downloads

278

Readme

🦕 Dinoco

npm version npm downloads license

A flexible, type-safe server-side router for meta-frameworks like Next.js and Nuxt.js, inspired by Hono.js. Build powerful dynamic routes for [...slug] or [[...slug]] with ease.

This is basically a smaller and more focused version of Hono.js, with a focus on dynamic routes and server-side routing. But the API is very similar, so if you are familiar with Hono.js, you should feel right at home.

[!Note] This package is still in development and your feedback is highly appreciated. If you have any suggestions or issues, please let us know by creating an issue on GitHub.

Usage

Installation

Install the package using your package manager of choice.

npm install dinoco

Basic Usage

You can define routes using the Dinoco class and the get method. The get method accepts a path and a handler function. The handler function should return a the component that should be rendered for the given path.

Here we are using next@15 as an example, but this package can be used with any meta-framework that supports dynamic routes.

// [[...segments]].tsx or [...segments].tsx
import { Dinoco } from "dinoco";

const app = new Dinoco();

app.get("/about", () => {
  return <div>About Page</div>;
});

app.get("/", () => {
  return <div>Home Page</div>;
});

type Args = {
  params: Promise<{
    segments?: string[];
  }>;
  searchParams: Promise<{
    [key: string]: string | string[];
  }>;
};

export default async function IdPage(props: Args) {
  const segments = (await props.params).segments;
  const searchParams = await props.searchParams;

  return app.fetch(segments, searchParams);
}

Middlewares

You can use middlewares to run code before the handler function is called. Middlewares can be used to check if a user is authenticated, fetch data, or any other logic you need to run before the handler function is called.

app.use(async (c, next) => {
  // Some auth logic
  const user = await fetchUser();
  c.set("user", user);

  await next();
}, async (c, next) => {
  const user = c.get("user");

  if (!user) notFound();

  await next();
});

Error Handling & 404

app.notFound(() => {
  // For Nextjs
  return notFound();
});

app.onError((err, c) => {
  // Handle errors here
})

Contributing

We would love to have more contributors involved!

To get started, please read our Contributing Guide.

Credits

  • This project would not have been possible without the work of Yusuke Wada and Honojs's Community, on HonoJS package.