mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 18:00:18 +01:00
46675f78ae
The `createStaticServer` function was split from the `static-server.js` script, so that the static server could be constructed programmatically. `static-server.js` remains responsible for the CLI. This was done to make it easier to programmatically start the test dapp from e2e tests.
23 lines
600 B
JavaScript
23 lines
600 B
JavaScript
const http = require('http')
|
|
const path = require('path')
|
|
|
|
const serveHandler = require('serve-handler')
|
|
|
|
const createStaticServer = (rootDirectory) => {
|
|
return http.createServer((request, response) => {
|
|
if (request.url.startsWith('/node_modules/')) {
|
|
request.url = request.url.substr(14)
|
|
return serveHandler(request, response, {
|
|
directoryListing: false,
|
|
public: path.resolve('./node_modules'),
|
|
})
|
|
}
|
|
return serveHandler(request, response, {
|
|
directoryListing: false,
|
|
public: rootDirectory,
|
|
})
|
|
})
|
|
}
|
|
|
|
module.exports = createStaticServer
|