Skip to content

Commit

Permalink
fix: remove replay
Browse files Browse the repository at this point in the history
  • Loading branch information
dnalborczyk committed Jul 22, 2022
1 parent d175d5d commit d325837
Showing 1 changed file with 1 addition and 38 deletions.
39 changes: 1 addition & 38 deletions src/events/http/HttpServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Buffer } from 'node:buffer'
import { readFileSync } from 'node:fs'
import { createRequire } from 'node:module'
import { join, resolve } from 'node:path'
import process, { exit } from 'node:process'
import { exit } from 'node:process'
import h2o2 from '@hapi/h2o2'
import { Server } from '@hapi/hapi'
import { log } from '@serverless/utils/log.js'
Expand Down Expand Up @@ -35,8 +35,6 @@ const { assign, entries, keys } = Object
export default class HttpServer {
#lambda = null

#lastRequestOptions = null

#options = null

#serverless = null
Expand Down Expand Up @@ -200,14 +198,10 @@ export default class HttpServer {
log.notice(`Server ready: ${server} 🚀`)
log.notice()
log.notice('Enter "rp" to replay the last request')

process.stdin.addListener('data', this.#handleStdin)
}

// stops the server
stop(timeout) {
process.stdin.removeListener('data', this.#handleStdin)
process.stdin.pause()
return this.#server.stop({
timeout,
})
Expand All @@ -221,15 +215,6 @@ export default class HttpServer {
}
}

#handleStdin = (data) => {
// note: data is an object, and when converted to a string it will
// end with a linefeed. so we (rather crudely) account for that
// with toString() and then trim()
if (data.toString().trim() === 'rp') {
this.#injectLastRequest()
}
}

#logPluginIssue() {
log.notice(
'If you think this is an issue with the plugin please submit it, thanks!\nhttps://github.com/dherault/serverless-offline/issues',
Expand Down Expand Up @@ -517,24 +502,11 @@ export default class HttpServer {
hapiOptions.tags = ['api']

const hapiHandler = async (request, h) => {
// Here we go
// Store current request as the last one
this.#lastRequestOptions = {
headers: request.headers,
method: request.method,
payload: request.payload,
url: request.url.href,
}

const requestPath =
endpoint.isHttpApi || this.#options.noPrependStageInUrl
? request.path
: request.path.substr(`/${stage}`.length)

if (request.auth.credentials && request.auth.strategy) {
this.#lastRequestOptions.auth = request.auth
}

// Payload processing
const encoding = detectEncoding(request)

Expand Down Expand Up @@ -1261,15 +1233,6 @@ export default class HttpServer {
.map((line) => line.trim())
}

#injectLastRequest() {
if (this.#lastRequestOptions) {
log.notice('Replaying HTTP last request')
this.#server.inject(this.#lastRequestOptions)
} else {
log.notice('No last HTTP request to replay!')
}
}

writeRoutesTerminal() {
logRoutes(this.#terminalInfo)
}
Expand Down

0 comments on commit d325837

Please sign in to comment.