Skip to content

Commit

Permalink
feat: add server
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardoboucas committed Feb 2, 2022
1 parent e43e2f8 commit 36a89f5
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@ import { tmpName } from 'tmp-promise'
import { DenoBridge } from './bridge.js'
import { preBundle } from './bundler.js'
import type { Declaration } from './declaration.js'
import { generateManifest } from './manifest.js'

const serve = async (port: number, sourceDirectories: string[], declarations: Declaration[]) => {
const deno = new DenoBridge()
const distDirectory = await tmpName()
const { preBundlePath } = await preBundle(sourceDirectories, distDirectory)
const { handlers, preBundlePath } = await preBundle(sourceDirectories, distDirectory)
const manifest = generateManifest(preBundlePath, handlers, declarations)

console.log({ port, declarations })
// TODO: Add `--no-clear-screen` when https://github.com/denoland/deno/pull/13454 is released.
deno.run(['run', '-A', '--unstable', '--watch', preBundlePath, port.toString()], { wait: false })

return deno.run(['run', '-A', '--unstable', preBundlePath, port.toString()], { wait: false })
return {
manifest,
}
}

export { serve }

0 comments on commit 36a89f5

Please sign in to comment.