Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(kit): add utilities #2509

Closed
wants to merge 4 commits into from

Conversation

Barbapapazes
Copy link
Member

@Barbapapazes Barbapapazes commented Jun 11, 2024

πŸ”— 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)
  • πŸ‘Œ 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

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

src/core/nitro.ts Outdated Show resolved Hide resolved
@pi0
Copy link
Member

pi0 commented Jun 11, 2024

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 pi0 marked this pull request as draft June 11, 2024 08:44
@Barbapapazes
Copy link
Member Author

What do you mean by "separate PRs"?

@pi0
Copy link
Member

pi0 commented Jun 11, 2024

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
Copy link
Member

pi0 commented Jun 11, 2024

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 pi0 changed the base branch from main to v2 June 13, 2024 14:04
@pi0
Copy link
Member

pi0 commented Sep 20, 2024

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 pi0 closed this Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

provide helpers for module authors
2 participants