Skip to content

v7.1.0

Compare
Choose a tag to compare
@github-actions github-actions released this 08 Feb 10:37
· 236 commits to master since this release

npm version npm bundle size

npm i kkt@7.1.0

v7.0.7...v7.1.0

New Features

import express from 'express';
import { WebpackConfiguration, MockerAPIOptions } from 'kkt';
export default (conf: WebpackConfiguration, evn: 'development' | 'production') => {
  //....
+  conf.proxySetup = (app: express.Application): MockerAPIOptions => {
+    return {
+      path: path.resolve('./mocker/index.js'),
+    };
+  };
  return conf;
}

Or:

Or use another way to manually configure the proxy.

import express from 'express';
import { createProxyMiddleware } from 'http-proxy-middleware';
import { MockerAPIOptions } from 'kkt';
/**
 * Still available, may be removed in the future. (仍然可用,将来可能会被删除。) 
 */
export const proxySetup = (app: express.Application): MockerAPIOptions => {
  app.use('/api', createProxyMiddleware({
    target: 'http://localhost:5000',
    changeOrigin: true,
  }));
  /**
   * Mocker API Options
   * https://www.npmjs.com/package/mocker-api
   */
  return {
    path: path.resolve('./mocker/index.js'),
    option: {
      proxy: {
        '/repos/(.*)': 'https://api.github.com/',
      },
      changeHost: true,
    }
  }
}