https://github.com/kid-joker/serve-then
After the server starts successfully, then you can ...
https://github.com/kid-joker/serve-then
server start test testing-tools wait
Last synced: 10 months ago
JSON representation
After the server starts successfully, then you can ...
- Host: GitHub
- URL: https://github.com/kid-joker/serve-then
- Owner: KID-joker
- License: mit
- Created: 2023-02-05T01:37:28.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-24T14:10:58.000Z (about 3 years ago)
- Last Synced: 2025-08-09T15:49:22.975Z (10 months ago)
- Topics: server, start, test, testing-tools, wait
- Language: TypeScript
- Homepage:
- Size: 117 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# serve-then
[](https://www.npmjs.com/package/serve-then)
Inspired by [start-server-and-test](https://github.com/bahmutov/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](https://github.com/tapio/live-server), But [it](https://github.com/KID-joker/live-server) 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
```ts
import { serve, serveOptions } from 'serve-then'
serve(options as serveOptions).then(url => {
// serving root at url
}).catch(err => {})
```
### License
[MIT](./LICENSE) License © 2023 [KID-joker](https://github.com/KID-joker)