Socket
Socket
Sign inDemoInstall

har-express

Package Overview
Dependencies
63
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    har-express

Use HAR file to create a mock server


Version published
Weekly downloads
22
decreased by-64.52%
Maintainers
1
Install size
2.03 MB
Created
Weekly downloads
 

Readme

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

Last updated on 28 Feb 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc