![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
hono-autoloader
Advanced tools
Plugin for [Hono](https://hono.dev/) that autoloads all routes in a directory.
Plugin for Hono that autoloads all routes in a directory.
Inspired by elysia-autoload.
yarn add hono-autoloader
import { serve } from '@hono/node-server'
import { Hono } from 'hono'
import { autoloadRoutes } from 'hono-autoloader'
const port = +(process.env.PORT || 3000)
const app = await autoloadRoutes(new Hono(), {
// Pattern to scan route files
pattern: '**/*.ts',
// Prefix to add to routes
prefix: '/api',
// Source directory of route files: use "relative" path
routesDir: './src/api'
})
serve(
{
fetch: app.fetch,
port
},
() => console.log(`Server running at http://localhost:${port}`)
)
// /routes/index.ts
import type { Context } from 'hono'
export default (c: Context) => {
return c.text('Hello World!')
}
Guide on how hono-autoloader
matches routes:
├── app.ts
├── routes
│ ├── index.ts // index routes
│ ├── posts
│ │ ├── index.ts
│ │ └── [id].ts // dynamic params
│ ├── likes
│ │ └── [...].ts // wildcard
│ ├── domains
│ │ ├── @[...] // wildcard with @ prefix
│ │ │ └── index.ts
│ ├── frontend
│ │ └── index.tsx // usage of tsx extension
│ ├── events
│ │ ├── (post).ts // post and get will not be in the link
│ │ └── (get).ts
│ └── users.ts
└── package.json
/routes/index.ts
→ /
/routes/posts/index.ts
→ /posts
/routes/posts/[id].ts
→ /posts/:id
/routes/users.ts
→ /users
/routes/likes/[...].ts
→ /likes/*
/routes/domains/@[...]/index.ts
→ /domains/@*
/routes/frontend/index.tsx
→ /frontend
/routes/events/(post).ts
→ /events
/routes/events/(get).ts
→ /events
Key | Type | Default | Description |
---|---|---|---|
failGlob? | boolean | true | Throws an error if no matches are found |
importKey? | string | default | The key (name) of the exported function of route files |
pattern? | string | **/*.{ts,tsx,js,jsx,mjs,cjs} | Glob patterns |
prefix? | string | | Prefix to be added to each route |
routesDir? | string | ./routes | The folder where routes are located (use a relative path) |
skipImportErrors? | boolean | false | Throws an error if there is an import error of a route file |
For Vite
+ Node.js and similar use cases, where .ts
or .tsx
files aren't transpiled, install esbuild.
Note:
Bun
internally transpiles every file it executes (both .js and .ts) → Read more
This project is licensed under the MIT License.
FAQs
Plugin for [Hono](https://hono.dev/) that autoloads all routes in a directory.
The npm package hono-autoloader receives a total of 0 weekly downloads. As such, hono-autoloader popularity was classified as not popular.
We found that hono-autoloader demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.