Function
startStaticServer
(
dir: string,
notFoundFile?: string,
fixedPort?: number
)
Source from the content-addressed store, hash-verified
| 731 | } |
| 732 | |
| 733 | export async function startStaticServer( |
| 734 | dir: string, |
| 735 | notFoundFile?: string, |
| 736 | fixedPort?: number |
| 737 | ) { |
| 738 | const app = express() |
| 739 | const server = http.createServer(app) |
| 740 | app.use(express.static(dir)) |
| 741 | |
| 742 | if (notFoundFile) { |
| 743 | app.use((req, res) => { |
| 744 | createReadStream(notFoundFile).pipe(res) |
| 745 | }) |
| 746 | } |
| 747 | |
| 748 | await startListen(server, fixedPort) |
| 749 | return server |
| 750 | } |
| 751 | |
| 752 | export async function startCleanStaticServer(dir: string) { |
| 753 | const app = express() |