GithubHelp home page GithubHelp logo

prmdk / har-express Goto Github PK

View Code? Open in Web Editor NEW

This project forked from toutpt/har-express

0.0 0.0 0.0 703 KB

Use HAR file to create a mock server

Home Page: https://www.npmjs.com/package/har-express

JavaScript 100.00%

har-express's Introduction

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

har-express's People

Contributors

toutpt avatar dependabot[bot] avatar jmfrancois avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.