New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

har-express

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

har-express

Use HAR file to create a mock server

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
38
increased by35.71%
Maintainers
1
Weekly downloads
 
Created
Source

har-express

Travis CI NPM dependencies devdependencies

First be sure to know what is HAR file reading wikipedia.

This package expose a CLI to create an HTTP mock server and a library API to integrate it in webpack devServer

Use case

So you have an HAR file ? You can either:

  • configure webpack to use the har file directly
  • start a server using the CLI

using only webpack

So in your webpack.config.dev.js file you can do the following:

const har = require('har-express');

if (process.env.HAR) {
	devServer.before = app => {
		app.use(har.getMiddleware(process.env.HAR));
	};
} else {
    // fallback for dev in your proxy to the real backend
	devServer.proxy = {
		'/api': process.env.API_URL || 'http://localhost:8000',
	};
}

module.exports = {
	devServer,
};

then you can start your project using

HAR='./use-case.har' yarn start

Using CLI

In the context your webpack config use API_URL env to configure the proxy just do

API_URL=http://localhost:8000 yarn start
har-express -p 8000 ./use-case.har

Keywords

FAQs

Package last updated on 28 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc