-
Notifications
You must be signed in to change notification settings - Fork 823
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Better error for opaque streams (#3001)
- Loading branch information
1 parent
9fae132
commit 61d54d7
Showing
5 changed files
with
124 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
Copyright 2021 Google LLC | ||
Use of this source code is governed by an MIT-style | ||
license that can be found in the LICENSE file or at | ||
https://opensource.org/licenses/MIT. | ||
*/ | ||
|
||
const express = require('express'); | ||
|
||
const PORT = 3010; | ||
|
||
let app; | ||
let server; | ||
|
||
function initApp(staticDir) { | ||
app = express(); | ||
app.use(express.static(staticDir)); | ||
} | ||
|
||
function start(staticDir) { | ||
if (!app) { | ||
initApp(staticDir); | ||
} | ||
|
||
return new Promise((resolve, reject) => { | ||
server = app.listen(PORT, (error) => { | ||
if (error) { | ||
reject(error); | ||
} else { | ||
resolve(`http://localhost:${PORT}`); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
function stop() { | ||
if (server) { | ||
server.close(); | ||
} | ||
} | ||
|
||
module.exports = { | ||
start, | ||
stop, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters