1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-30 08:09:15 +01:00
metamask-extension/development/create-static-server.js
Erik Marks 76a2a9bb8b
@metamask/eslint config@5.0.0 (#10358)
* @metamask/eslint-config@5.0.0
* Update eslintrc and prettierrc
* yarn lint:fix
2021-02-04 10:15:23 -08:00

23 lines
609 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;