Skip to content

Commit

Permalink
chore: several improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Nov 9, 2024
1 parent 2ab3250 commit f33d379
Show file tree
Hide file tree
Showing 12 changed files with 285 additions and 123 deletions.
4 changes: 1 addition & 3 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"biomejs.biome",
"dbaeumer.vscode-eslint",
"streetsidesoftware.code-spell-checker",
"davidanson.vscode-markdownlint"
]
Expand Down
139 changes: 139 additions & 0 deletions .zed/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
// For a full list of overridable settings, and general information on folder-specific settings,
// see the documentation: https://zed.dev/docs/configuring-zed#settings-files
{
"languages": {
"JavaScript": {
"formatter": {
"code_actions": {
"source.fixAll.eslint": true
}
}
},
"TypeScript": {
"formatter": {
"code_actions": {
"source.fixAll.eslint": true
}
}
},
"HTML": {
"formatter": {
"code_actions": {
"source.fixAll.eslint": true
}
}
},
"CSS": {
"formatter": {
"code_actions": {
"source.fixAll.eslint": true
}
}
},
"Markdown": {
"formatter": {
"code_actions": {
"source.fixAll.eslint": true
}
}
},
"JSON": {
"formatter": {
"code_actions": {
"source.fixAll.eslint": true
}
}
},
"JSONC": {
"formatter": {
"code_actions": {
"source.fixAll.eslint": true
}
}
},
"YAML": {
"formatter": {
"code_actions": {
"source.fixAll.eslint": true
}
}
},
"XML": {
"formatter": {
"code_actions": {
"source.fixAll.eslint": true
}
}
},
"TOML": {
"formatter": {
"code_actions": {
"source.fixAll.eslint": true
}
}
}
},
"lsp": {
"eslint": {
"settings": {
"rulesCustomizations": [
{
"rule": "style/*",
"severity": "off",
"fixable": true
},
{
"rule": "format/*",
"severity": "off",
"fixable": true
},
{
"rule": "*-indent",
"severity": "off",
"fixable": true
},
{
"rule": "*-spacing",
"severity": "off",
"fixable": true
},
{
"rule": "*-spaces",
"severity": "off",
"fixable": true
},
{
"rule": "*-order",
"severity": "off",
"fixable": true
},
{
"rule": "*-dangle",
"severity": "off",
"fixable": true
},
{
"rule": "*-newline",
"severity": "off",
"fixable": true
},
{
"rule": "*quotes",
"severity": "off",
"fixable": true
},
{
"rule": "*semi",
"severity": "off",
"fixable": true
}
]
}
}
},
"file_types": {
"JavaScript": [
"buddy"
]
}
}
Binary file modified bun.lockb
Binary file not shown.
77 changes: 0 additions & 77 deletions commitlint.config.js

This file was deleted.

15 changes: 2 additions & 13 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
import stacks from '@stacksjs/eslint-config'

export default stacks({
// Enable stylistic formatting rules
// stylistic: true,

// Or customize the stylistic rules
stylistic: {
indent: 2, // 4, or 'tab'
quotes: 'single', // or 'double'
indent: 2,
quotes: 'single',
},

typescript: true,
vue: true,
jsonc: true,
yaml: true,
unocss: true,

ignores: [
'**/fixtures',
// ...globs
],
})
29 changes: 16 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,23 @@
"bun-reverse-proxy": "./dist/cli.js",
"reverse-proxy": "./dist/cli.js"
},
"files": ["dist", "scripts", "src"],
"files": [
"dist",
"scripts",
"src"
],
"scripts": {
"build": "bun build.ts && bun run compile",
"compile": "bun build ./bin/cli.ts --compile --minify --outfile dist/reverse-proxy",
"compile:all": "bun run compile:linux-x64 && bun run compile:linux-arm64 && bun run compile:windows-x64 && bun run compile:darwin-x64 && bun run compile:darwin-arm64",
"compile:linux-x64": "bun build ./bin/cli.ts --compile --minify --target=bun-linux-x64 --outfile dist/reverse-proxy-linux-x64",
"compile:linux-arm64": "bun build ./bin/cli.ts --compile --minify --target=bun-linux-arm64 --outfile dist/reverse-proxy-linux-arm64",
"compile:windows-x64": "bun build ./bin/cli.ts --compile --minify --target=bun-windows-x64 --outfile dist/reverse-proxy-windows-x64.exe",
"compile:darwin-x64": "bun build ./bin/cli.ts --compile --minify --target=bun-darwin-x64 --outfile dist/reverse-proxy-darwin-x64",
"compile:darwin-arm64": "bun build ./bin/cli.ts --compile --minify --target=bun-darwin-arm64 --outfile dist/reverse-proxy-darwin-arm64",
"lint": "bunx eslint .",
"lint:fix": "bunx eslint . --fix",
"fresh": "bunx rimraf node_modules/ bun.lock && bun i",
"commit": "git cz",
"changelog": "bunx changelogen --output CHANGELOG.md",
"prepublishOnly": "bun --bun run build",
"release": "bun run changelog && bunx bumpp package.json --all",
Expand All @@ -59,24 +68,18 @@
},
"devDependencies": {
"@stacksjs/cli": "^0.65.0",
"@stacksjs/eslint-config": "^3.7.3-stacks-1.11",
"@stacksjs/eslint-config": "^3.8.1-beta.2",
"@stacksjs/development": "^0.65.0",
"@stacksjs/storage": "^0.65.0",
"@types/bun": "^1.1.10",
"bun-plugin-dts-auto": "^0.20.5",
"c12": "^2.0.1",
"bun-config": "^0.1.5",
"bun-plugin-dtsx": "^0.21.7",
"vitepress": "^1.4.0"
},
"simple-git-hooks": {
"pre-commit": "bun lint-staged",
"commit-msg": "bunx --no -- commitlint --edit $1"
"pre-commit": "bunx lint-staged"
},
"lint-staged": {
"*.{js,jsx,ts,tsx,vue}": "bunx eslint . --fix"
},
"config": {
"commitizen": {
"path": "node_modules/cz-git"
}
"*.{js,ts}": "bunx eslint . --fix"
}
}
2 changes: 1 addition & 1 deletion pkgx.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dependencies:
bun.sh: ^1.0.30
bun.sh: ^1.1.34
9 changes: 7 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { loadConfig } from 'c12'
import type { ReverseProxyConfig } from './types'
import { loadConfig } from 'bun-config'

// Get loaded config
const { config } = await loadConfig({
// eslint-disable-next-line antfu/no-top-level-await
const config: ReverseProxyConfig = await loadConfig({
name: 'reverse-proxy',
defaultConfig: {
'localhost:5173': 'stacks.localhost',
},
})

export { config }
10 changes: 8 additions & 2 deletions src/start.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import type { ReverseProxyOption, ReverseProxyOptions } from './types'
import * as http from 'node:http'
import * as net from 'node:net'
import process from 'node:process'
import { bold, dim, green, log } from '@stacksjs/cli'
import { version } from '../package.json'
import type { ReverseProxyOption, ReverseProxyOptions } from './types'

export async function startServer(
options: ReverseProxyOption = { from: 'localhost:3000', to: 'stacks.localhost' },
Expand Down Expand Up @@ -83,9 +84,13 @@ export function setupReverseProxy(options: ReverseProxyOption): void {
})

httpServer.listen(80, '0.0.0.0', () => {
// eslint-disable-next-line no-console
console.log('')
// eslint-disable-next-line no-console
console.log(` ${green(bold('reverse-proxy'))} ${green(`v${version}`)}`)
// eslint-disable-next-line no-console
console.log('')
// eslint-disable-next-line no-console
console.log(` ${green('➜')} ${dim(from as string)} ${dim('➜')} http://${to}`)
})
})
Expand All @@ -112,7 +117,8 @@ export function startProxies(options?: ReverseProxyOptions): void {
options.forEach((option: ReverseProxyOption) => {
startServer(option)
})
} else {
}
else {
startServer(options)
}
}
Expand Down
23 changes: 12 additions & 11 deletions src/types.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
export interface ReverseProxyOption {
hostname?: string
port?: number
from?: string // domain to proxy from, defaults to localhost:3000
to?: string // domain to proxy to, defaults to stacks.localhost
key?: string // content of the key
keyPath?: string // absolute path to the key
cert?: string // content of the cert
certPath?: string // absolute path to the cert
httpsRedirect?: boolean // redirect http to https, defaults to true
verbose?: boolean
export interface ReverseProxyConfig {
hostname: string
port: number
from: string // domain to proxy from, defaults to localhost:3000
to: string // domain to proxy to, defaults to stacks.localhost
key: string // content of the key
keyPath: string // absolute path to the key
cert: string // content of the cert
certPath: string // absolute path to the cert
httpsRedirect: boolean // redirect http to https, defaults to true
verbose: boolean
}

export type ReverseProxyOption = Partial<ReverseProxyConfig>
export type ReverseProxyOptions = ReverseProxyOption | ReverseProxyOption[]
Loading

0 comments on commit f33d379

Please sign in to comment.