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

nixle

v0.22.6

Published

Universal Server-Side Framework. Backend for everyone and everywhere.

Downloads

699

Readme

Overview

Nixle is a framework for building HTTP servers. It is designed to be simple, fast, and extensible. It is built on top of existing frameworks, such as Express, Fastify, and Nitro.

  • ✨ Simple and intuitive API.
  • 🚀 Supports multiple providers such as Express, Fastify, and Hono.
  • 🌐 Supports SSR frameworks such as Nuxt.
  • 💪 Incredible TypeScript support.
  • 🎯 Easy to use and extend.

Documentation

You can find the documentation on the website.

Installation

npm install nixle

Usage

To set up your app, use the createApp function. Create a router with the createRouter function. Additionally, you can create services with module-specific logic using the createService function.

// usersRouter.ts
import { createRouter, createService } from 'nixle';

declare global {
  namespace Nixle {
    interface Env {
      USERS_SERVICE: string;
    }
  }
}

const usersService = createService('users', ({ log, env, ofetch }) => {
  const getUsers = async (limit: number) => {
    log.info('Getting users...');

    const users = await ofetch<{ name: string; email: string }[]>(`${env.USERS_SERVICE}/users`);

    log.success(`Got ${users.length} users`);

    return users;
  };

  return {
    getUsers,
  };
});

export const usersRouter = createRouter('/users', ({ route, zodObject }) => [
  route.get('/', {
    queryValidation: zodObject({
      limit: zod.number().default(10),
    }).validate,
    handler: ({ query }) => {
      return usersService().getUsers(query.limit);
    },
  }),
]);

Providers

We have several providers that you can use to create your app such as Nuxt, Express, Fastify, and Elysia (Bun). Choose the one that suits you best and install packages for it. More information about providers can be found in the docs.

For example, if you want to use Fastify, install the @nixle/fastify package besides the nixle package:

npm install @nixle/fastify

Then, import the fastifyProvider function and pass it to the createApp function:

import fastify from 'fastify';
import { createApp } from 'nixle';
import { fastifyProvider } from '@nixle/fastify';
import { zodPlugin } from '@nixle/zod';
import { ofetchPlugin } from '@nixle/ofetch';
import { usersRouter } from './usersRouter';

const { app, $inferRouters } = createApp({
  provider: fastifyProvider(fastify()),
  router: [usersRouter],
  plugins: [zodPlugin, ofetchPlugin()],
});

app.listen({ port: 4000 });

type NixleRouters = typeof $inferRouters;
// {
//   '/users': {
//     '/': {
//       GET: {
//         query: {
//           limit: number;
//         };
//         response: { name: string; email: string }[]
//       }
//     }
//   };
// }

Author

© letstri, released under the MIT license.