nitro icon indicating copy to clipboard operation
nitro copied to clipboard

feat(kit): add utilities

Open Barbapapazes opened this issue 1 year ago โ€ข 4 comments

๐Ÿ”— Linked issue

fix #2363

โ“ Type of change

  • [ ] ๐Ÿ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • [ ] ๐Ÿž Bug fix (a non-breaking change that fixes an issue)
  • [x] ๐Ÿ‘Œ Enhancement (improving an existing functionality like performance)
  • [ ] โœจ New feature (a non-breaking change that adds functionality)
  • [ ] ๐Ÿงน Chore (updates to the build process or auxiliary tools and libraries)
  • [ ] โš ๏ธ Breaking change (fix or feature that would cause existing functionality to change)

๐Ÿ“š Description

Hello ๐Ÿ‘‹,

This PR introduces some utilities to improve the developer experience when creating a Nitro module. They are based on nuxt/kit.

@huang-julien, happy to have your throughs on this. And maybe you have more ideas of utilities that could be added.

Documentation will come after #2508

Usage exemple:

import { defineNitroConfig } from "nitropack/config";
import {
  addEventHandler,
  addPrerenderRoutes,
  createResolver,
} from "../src/kit/module";

export default defineNitroConfig({
  prerender: {
    routes: ["/"],
  },
  modules: [
    () => {
      const resolve = createResolver(import.meta.url);

      addPrerenderRoutes("/hello");
      addEventHandler({
        handler: resolve("./hello.ts"),
        route: "/hello",
      });
    },
  ],
});

๐Ÿ“ Checklist

  • [x] I have linked an issue or discussion.
  • [ ] I have updated the documentation accordingly.

Barbapapazes avatar Jun 11 '24 07:06 Barbapapazes

Thanks for PR. I will take some time to review and finalize it)

(please please please next times always 1: use separate PRs, 2: use github issues to discuss each. this is clearly written in contribution notes)

pi0 avatar Jun 11 '24 08:06 pi0

What do you mean by "separate PRs"?

Barbapapazes avatar Jun 11 '24 09:06 Barbapapazes

isse>PR per feature /method so we can propely discuss requirements and review each. (also please note i don't plan to accept 1-1 nuxt kit features to nitro)

Context support in particular had to be separated (no worries will work on that)

pi0 avatar Jun 11 '24 09:06 pi0

In the meantime it would be nice if you can help to move all util docs+example to jsdocs so we can render them with automd.

pi0 avatar Jun 11 '24 09:06 pi0

Closing for now but thanks again for putting efforts โค๏ธ . While these are nice utils for users that directly use Nitro as main framework, i really want to be careful about adoption of Nitro modules for higher order frameworks (and prefer configuration over modules for tasks like adding a route)

pi0 avatar Sep 20 '24 12:09 pi0