-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dev-server): Add initial nodejs adapter (#167)
* Initial node adapter * format * add changeset
- Loading branch information
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@hono/vite-dev-server': minor | ||
--- | ||
|
||
Add initial nodejs adapter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |