Skip to content

Commit f25c22b

Browse files
wip
1 parent 6bef39c commit f25c22b

File tree

3 files changed

+25
-33
lines changed

3 files changed

+25
-33
lines changed

package.json

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"main": "index.js",
88
"scripts": {
99
"start": "listhen --public=false ./dist/index.js",
10+
"start:tsx": "tsx ./dist/node.js",
1011
"dev": "listhen -w ./src/index.ts",
1112
"build": "tsup",
1213
"build:fix": "esno scripts/postbuild.ts",
@@ -27,6 +28,7 @@
2728
"h3": "^1.8.0",
2829
"listhen": "^1.4.0",
2930
"ofetch": "^1.3.3",
31+
"tsx": "^3.12.7",
3032
"vue": "^3.3.4"
3133
},
3234
"devDependencies": {

pnpm-lock.yaml

+8-33
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/node.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* eslint-disable n/prefer-global/process */
2+
import { createServer } from 'node:http'
3+
import { toNodeListener } from 'h3'
4+
import { app } from './index'
5+
6+
const port = process.env.PORT || 3000
7+
const host = process.env.HOST || 'localhost'
8+
const isDev = process.env.NODE_ENV === 'development'
9+
let url = `${host}`
10+
if (isDev)
11+
url += `:${port}`
12+
13+
console.error(`Listen on http://${url}`)
14+
15+
createServer(toNodeListener(app)).listen(port)

0 commit comments

Comments
 (0)