Skip to content

Commit

Permalink
feat(dev-server): Add initial nodejs adapter (#167)
Browse files Browse the repository at this point in the history
* Initial node adapter

* format

* add changeset
  • Loading branch information
arisris authored Aug 28, 2024
1 parent 714951c commit 044a023
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-rings-sneeze.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@hono/vite-dev-server': minor
---

Add initial nodejs adapter
19 changes: 19 additions & 0 deletions packages/dev-server/src/adapter/node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { Adapter } from '../types'
export const nodeAdapter = (): Adapter => {
if (typeof globalThis.navigator === 'undefined') {
// @ts-expect-error not typed well
globalThis.navigator = {
userAgent: 'Node.js',
}
} else {
Object.defineProperty(globalThis.navigator, 'userAgent', {
value: 'Node.js',
writable: false,
})
}
return {
env: process.env,
}
}

export default nodeAdapter

0 comments on commit 044a023

Please sign in to comment.