New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

in-process-request

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

in-process-request - npm Package Compare versions

Comparing version 0.1.0 to 0.2.1

dist/compile/nestHandler.d.ts

2

dist/compile/handler.d.ts

@@ -1,2 +0,1 @@

/// <reference types="node" />
import { RequestListener } from 'http';

@@ -12,3 +11,4 @@ import { MockResponse, MockRequestOptions } from './httpMock';

HapiListener: typeof HapiListener;
nestHandler: (nestApp: any) => Promise<any>;
};
export = handler;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const httpMock_1 = require("./httpMock");
const hapiListener_1 = require("./hapiListener");
const nestHandler_1 = __importDefault(require("./nestHandler"));
const handler = (app) => (reqOptions) => {

@@ -13,2 +17,3 @@ return new Promise((resolve) => {

handler.HapiListener = hapiListener_1.HapiListener;
handler.nestHandler = nestHandler_1.default;
module.exports = handler;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.HapiListener = void 0;
const events_1 = require("events");

@@ -4,0 +5,0 @@ class HapiListener extends events_1.EventEmitter {

@@ -6,2 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.createMockRequest = exports.createMockResponse = void 0;
const http_1 = require("http");

@@ -8,0 +9,0 @@ const getHeaders_1 = __importDefault(require("./getHeaders"));

{
"name": "in-process-request",
"version": "0.1.0",
"version": "0.2.1",
"license": "(MIT OR Apache-2.0)",

@@ -33,9 +33,9 @@ "scripts": {

"devDependencies": {
"@types/jest": "^25.2.1",
"@types/node": "^13.13.4",
"jest": "^25.5.4",
"ts-jest": "^25.4.0",
"ts-node": "^8.9.1",
"typescript": "^3.8.3"
"@types/jest": "^25.2.3",
"@types/node": "^14.0.4",
"jest": "^26.0.1",
"ts-jest": "^26.0.0",
"ts-node": "^8.10.1",
"typescript": "^3.9.3"
}
}

@@ -13,2 +13,3 @@ # in-process-request

* Hapi v19
* NestJS v7
* Connect v3

@@ -157,3 +158,3 @@ * Koa v2

const requestOptions = {
path: '/test',
path: '/',
method: 'GET',

@@ -172,2 +173,53 @@ }

### NestJS example
This library provides a handy adapter for retrieving the underlying Express instance, which is needed for using this library to send requests to NestJS app.
```typescript
import inProcessRequest from 'in-process-request'
import { NestFactory } from '@nestjs/core';
import { Module, Get, Controller } from '@nestjs/common';
import { NestExpressApplication } from '@nestjs/platform-express';
// import nestHandler from '../../../src/nestHandler'
@Controller()
class AppController {
@Get()
render() {
return { hello: 'world' };
}
}
@Module({
imports: [],
controllers: [AppController],
})
class AppModule {}
const getApp = async () => {
const app = await NestFactory.create<NestExpressApplication>(AppModule);
return await inProcessRequest.nestHandler(app);
}
getApp().then((myApp) => {
// The server is initialized and we have access to the request handler - myApp
const myAppHandler = inProcessRequest(myApp);
const requestOptions = {
path: '/',
method: 'GET',
}
myAppHandler(requestOptions).then(response => {
console.log('Body', response.body);
console.log('Headers', response.headers);
console.log('Status Code', response.statusCode);
console.log('Status Message', response.statusMessage);
console.log('Is UTF8 body?', response.isUTF8);
})
})
```
## Usage in integration tests

@@ -174,0 +226,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc