Skip to content

Commit

Permalink
Fixed cli issues
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed Feb 4, 2018
1 parent f1cb701 commit 4124357
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 40 deletions.
10 changes: 10 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
src/
docs/
test/
.editorconfig
.gitignore
.travis.yml
jest.config.js
tsconfig.client.json
tsconfig.server.json
tsconfig.json
webpack.config.js
*.tgz
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 0.1.1

- Improved release automation
- Fixed binary creation
- Deliver typings in package
- Optimized package content

## 0.1.0

- Initial release
2 changes: 0 additions & 2 deletions bin/kras

This file was deleted.

12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
{
"name": "kras",
"version": "0.1.0",
"version": "0.1.1",
"description": "Efficient server proxying and mocking in Node.js.",
"main": "./dist/server/kras.js",
"bin": "./dist/server/kras-cli.js",
"main": "dist/server/kras.js",
"types": "dist/server/kras.d.ts",
"bin": {
"kras": "dist/server/kras-cli.js"
},
"engines": {
"node": ">=8.0.0"
},
"repository": {
"type": "git",
"url": "https://github.com/FlorianRappl/kras.git"
},
"bugs": {
"url": "https://github.com/FlorianRappl/kras/issues"
},
"scripts": {
"test:unit": "cross-env NODE_ENV=test jest src",
"test:watch": "npm run test:unit -- --watch",
Expand Down
33 changes: 0 additions & 33 deletions src/server/core/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,36 +41,3 @@ export function corsHandler(req: Request, res: Response) {
res.setHeader('Access-Control-Allow-Credentials', 'true');
return res.end();
}

export function httpHandler(req: Request, res: Response) {
proxyRequest(req, (err, ans) => {
if (err) {
console.error(err);
} else {
sendResponse(req, ans, res);
}
});
}

export function createWsConnector(target: string) {
const wsProxy = createProxyServer({});
const options = {
target: `wss://${target}`,
secure: false,
};
return {
open(req: IncomingMessage, socket: any, head: any) {
wsProxy.ws(req, socket, head, options);
return wsProxy;
},
close() {
wsProxy.close();
return wsProxy;
},
at(proxy: EventEmitter) {
proxy.on('close', () => wsProxy.close());
wsProxy.on('error', err => proxy.emit('error', err));
return this;
},
};
}
2 changes: 1 addition & 1 deletion src/server/injectors/har-injector.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { asJson, watch } from '../helpers/io';
import { fromHar, HarResponse, HarRequest, HarHeaders } from '../helpers/build-response';
import { compareRequests } from '../helpers/compare-requests';
import { KrasInjector, KrasInjectorConfig, KrasConfiguration, KrasRequest , Headers, StoredFileEntry, KrasInjectorOptions } from '../types';
import { KrasInjector, KrasInjectorConfig, KrasConfiguration, KrasRequest, KrasAnswer, Headers, StoredFileEntry, KrasInjectorOptions } from '../types';

function delay<T>(value: T, time: number) {
if (time) {
Expand Down
2 changes: 2 additions & 0 deletions src/server/kras-cli.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env node

import chalk from 'chalk';
import { MockServer } from './kras';
import { homedir } from 'os';
Expand Down
3 changes: 2 additions & 1 deletion tsconfig.server.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"compilerOptions": {
"jsx": "preserve",
"sourceMap": true,
"outDir": "dist/server"
"outDir": "dist/server",
"declaration": true
},
"include": [
"src/server/**/*"
Expand Down

0 comments on commit 4124357

Please sign in to comment.