feat(kit): add utilities
๐ 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.
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)
What do you mean by "separate PRs"?
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)
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.
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)