Skip to content

Commit

Permalink
Improved package.json reference
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianRappl committed Mar 8, 2023
1 parent 74ade1e commit 699b8e3
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 20 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.15.4

- Fixed issue with bundled `package.json` reference

## 0.15.3

- Added possibility to specify multiple headers or query parameters
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kras",
"version": "0.15.3",
"version": "0.15.4",
"description": "Efficient server proxying and mocking in Node.js.",
"main": "dist/server/index.js",
"types": "dist/server/index.d.ts",
Expand Down Expand Up @@ -75,7 +75,7 @@
"chokidar": "^3.5.3",
"cookie": "^0.4.2",
"cross-env": "^7.0.3",
"dets": "^0.10.2",
"dets": "^0.12.3",
"enzyme-to-json": "^3.6.2",
"express": "^4.18.2",
"express-ws": "^4.0.0",
Expand Down
11 changes: 1 addition & 10 deletions src/server/injectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import ScriptInjector from './script-injector';
import StoreInjector from './store-injector';

const specialHeaders = ['origin', 'content-type'];
const multipleHeaders = ['set-cookie'];

const coreInjectors: Record<string, any> = {
har: HarInjector,
Expand All @@ -32,15 +31,7 @@ function sendResponse(req: KrasRequest, ans: KrasAnswer, res: Response) {

for (const headerName of Object.keys(ans.headers)) {
if (specialHeaders.indexOf(headerName) === -1) {
const value = ans.headers[headerName];

if (Array.isArray(value) && multipleHeaders.includes(headerName)) {
for (const item of value) {
res.setHeader(headerName, item);
}
} else {
res.setHeader(headerName, value);
}
res.setHeader(headerName, ans.headers[headerName]);
}
}

Expand Down
6 changes: 2 additions & 4 deletions src/server/management/basics.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Request, Response } from 'express';
import { resolve } from 'path';
import { spawn } from 'child_process';
import { version } from '../info';
import { KrasServer, KrasConfiguration } from '../types';

const started = new Date();
Expand All @@ -26,15 +26,13 @@ function restart() {
}

export function configOf(server: KrasServer, config: KrasConfiguration) {
const pkgFile = resolve(__dirname, '..', '..', '..', 'package.json');
const pkgInfo = require(pkgFile);
return (_: Request, res: Response) => {
res.json({
directory: config.directory,
sources: config.sources,
map: config.map,
name: config.name,
version: pkgInfo.version,
version,
started: started.toString(),
mode: 'running',
});
Expand Down

0 comments on commit 699b8e3

Please sign in to comment.