app -> www
This commit is contained in:
parent
7c37ba9e80
commit
43fbe0ad1d
|
|
@ -3,4 +3,4 @@ import { resolve, join } from "node:path"
|
||||||
export const NOSE_ICON = ` ͡° ͜ʖ ͡°`
|
export const NOSE_ICON = ` ͡° ͜ʖ ͡°`
|
||||||
export const NOSE_DIR = resolve("./nose")
|
export const NOSE_DIR = resolve("./nose")
|
||||||
export const NOSE_BIN = resolve(join(NOSE_DIR, "bin"))
|
export const NOSE_BIN = resolve(join(NOSE_DIR, "bin"))
|
||||||
export const NOSE_APP = resolve(join(NOSE_DIR, "app"))
|
export const NOSE_WWW = resolve(join(NOSE_DIR, "www"))
|
||||||
|
|
@ -3,7 +3,7 @@ import { serveStatic } from "hono/bun"
|
||||||
import { prettyJSON } from "hono/pretty-json"
|
import { prettyJSON } from "hono/pretty-json"
|
||||||
import color from "kleur"
|
import color from "kleur"
|
||||||
|
|
||||||
import { NOSE_ICON, NOSE_DIR, NOSE_BIN, NOSE_APP } from "./config"
|
import { NOSE_ICON, NOSE_DIR, NOSE_BIN, NOSE_WWW } from "./config"
|
||||||
import { transpile, isFile } from "./utils"
|
import { transpile, isFile } from "./utils"
|
||||||
import { apps, serveApp } from "./webapp"
|
import { apps, serveApp } from "./webapp"
|
||||||
|
|
||||||
|
|
@ -104,7 +104,7 @@ if (process.env.BUN_HOT) {
|
||||||
console.log(color.cyan(NOSE_ICON))
|
console.log(color.cyan(NOSE_ICON))
|
||||||
console.log(color.blue("NOSE_DIR:"), color.yellow(NOSE_DIR))
|
console.log(color.blue("NOSE_DIR:"), color.yellow(NOSE_DIR))
|
||||||
console.log(color.blue("NOSE_BIN:"), color.yellow(NOSE_BIN))
|
console.log(color.blue("NOSE_BIN:"), color.yellow(NOSE_BIN))
|
||||||
console.log(color.blue("NOSE_APP:"), color.yellow(NOSE_APP))
|
console.log(color.blue("NOSE_WWW:"), color.yellow(NOSE_WWW))
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
port: process.env.PORT || 3000,
|
port: process.env.PORT || 3000,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import type { Child } from "hono/jsx"
|
||||||
import { renderToString } from "hono/jsx/dom/server"
|
import { renderToString } from "hono/jsx/dom/server"
|
||||||
import { join } from "node:path"
|
import { join } from "node:path"
|
||||||
import { readdirSync } from "node:fs"
|
import { readdirSync } from "node:fs"
|
||||||
import { NOSE_APP } from "./config"
|
import { NOSE_WWW } from "./config"
|
||||||
import { isFile } from "./utils"
|
import { isFile } from "./utils"
|
||||||
|
|
||||||
export type Handler = (r: Context) => string | Child | Response | Promise<Response>
|
export type Handler = (r: Context) => string | Child | Response | Promise<Response>
|
||||||
|
|
@ -23,26 +23,26 @@ export async function serveApp(c: Context, subdomain: string): Promise<Response>
|
||||||
export function apps(): string[] {
|
export function apps(): string[] {
|
||||||
const apps: string[] = []
|
const apps: string[] = []
|
||||||
|
|
||||||
for (const entry of readdirSync(NOSE_APP))
|
for (const entry of readdirSync(NOSE_WWW))
|
||||||
apps.push(entry.replace(/\.tsx?/, ""))
|
apps.push(entry.replace(/\.tsx?/, ""))
|
||||||
|
|
||||||
return apps
|
return apps
|
||||||
}
|
}
|
||||||
|
|
||||||
async function findApp(name: string): Promise<App | undefined> {
|
async function findApp(name: string): Promise<App | undefined> {
|
||||||
let path = join(NOSE_APP, `${name}.ts`)
|
let path = join(NOSE_WWW, `${name}.ts`)
|
||||||
let app = await loadApp(path)
|
let app = await loadApp(path)
|
||||||
if (app) return app
|
if (app) return app
|
||||||
|
|
||||||
path = join(NOSE_APP, `${name}.tsx`)
|
path = join(NOSE_WWW, `${name}.tsx`)
|
||||||
app = await loadApp(path)
|
app = await loadApp(path)
|
||||||
if (app) return app
|
if (app) return app
|
||||||
|
|
||||||
path = join(NOSE_APP, name, "index.ts")
|
path = join(NOSE_WWW, name, "index.ts")
|
||||||
app = await loadApp(path)
|
app = await loadApp(path)
|
||||||
if (app) return app
|
if (app) return app
|
||||||
|
|
||||||
path = join(NOSE_APP, name, "index.tsx")
|
path = join(NOSE_WWW, name, "index.tsx")
|
||||||
app = await loadApp(path)
|
app = await loadApp(path)
|
||||||
if (app) return app
|
if (app) return app
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user