Skip to content

Commit

Permalink
feat: 配置 bun 类型检查
Browse files Browse the repository at this point in the history
  • Loading branch information
ikxin committed Jul 16, 2023
1 parent 6ae7c1b commit 6adc607
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"author": "一纸忘忧 <i@ikxin.com>",
"type": "module",
"scripts": {
"build": "vue-tsc && vite build",
"dev": "vite",
"build": "vue-tsc && vite build"
"start": "bun --watch service/server.ts"
},
"dependencies": {
"@arco-design/web-vue": "^2.48.1",
Expand All @@ -31,6 +32,7 @@
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"@vitejs/plugin-vue": "^4.2.3",
"bun-types": "^0.6.14",
"eslint": "^8.44.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-vue": "^9.15.1",
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 2 additions & 9 deletions service/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,7 @@ import { createServer } from 'http'
import { platform } from 'os'
import { execFile } from 'child_process'

type Body = {
port: string
host: string
app: string
protocol: '4' | '5' | '6'
}

const getResult = (body: Body) => {
const getResult = body => {
const { port, host, app, protocol } = body

return new Promise(resolve => {
Expand All @@ -35,7 +28,7 @@ const getResult = (body: Body) => {
const server = createServer(async (req, res) => {
const url = new URL(req.url, `http://${req.headers.host}`)

const body = Object.fromEntries(url.searchParams) as Body
const body = Object.fromEntries(url.searchParams)

if (url.pathname === '/check') {
res.end(JSON.stringify(await getResult(body)))
Expand Down
5 changes: 5 additions & 0 deletions service/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"types": ["bun-types"]
}
}

0 comments on commit 6adc607

Please sign in to comment.