serve-then
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

serve-then

NPM version

Inspired by start-server-and-test, but this isn't a cli tool. It will run a server in the child_process, and return the URL, then you can do what you want. When the current process ends, the child_process will also end.

features

  1. Based on and offering all features of live-server, But it has a few changes:
    • convert start/shutdown into Promise style.
    • reject if port is specified and already in use. (0 means random)
  2. Ships ESM and CJS bundles.
  3. Can get the server URL.
  4. Destroy child_process following the current process.

usage

import { serve, serveOptions } from 'serve-then'

serve(options as serveOptions).then(url => {
  // serving root at url
}).catch(err => {})

License

MIT License © 2023 KID-joker

Readme

Keywords

Package Sidebar

Install

npm i serve-then

Weekly Downloads

2

Version

1.0.0

License

MIT

Unpacked Size

7.86 kB

Total Files

9

Last publish

Collaborators

  • kid-joker