Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@applitools/test-server

Package Overview
Dependencies
Maintainers
23
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@applitools/test-server - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

src/middlewares/cookies-middleware.js

6

CHANGELOG.md

@@ -6,2 +6,8 @@ # Changelog

## 1.0.7 - 2021/11/10
- add built-in middlewares
- add multiple middlewares support
- add https support
## 1.0.6 - 2021/10/30

@@ -8,0 +14,0 @@

3

package.json
{
"name": "@applitools/test-server",
"version": "1.0.6",
"version": "1.0.7",
"homepage": "https://github.com/applitools/eyes.sdk.javascript1#readme",

@@ -41,2 +41,3 @@ "bugs": {

"express": "4.17.1",
"handlebars": "4.7.7",
"morgan": "1.10.0",

@@ -43,0 +44,0 @@ "yargs": "17.0.1"

@@ -7,6 +7,9 @@ 'use strict'

const {resolve} = require('path')
const fs = require('fs')
const cors = require('cors')
const https = require('https')
const utils = require('@applitools/utils')
function testServer(argv = {}) {
const {staticPath = resolve('./test/fixtures'), port = 0, allowCors, showLogs, middlewareFile} = argv
let {staticPath = resolve('./test/fixtures'), port = 0, allowCors, showLogs, middlewares, key, cert} = argv

@@ -19,5 +22,11 @@ const app = express()

if (middlewareFile) {
const middleware = require(middlewareFile)
app.use(middleware.generateMiddleware ? middleware.generateMiddleware(argv) : middleware)
if (middlewares) {
middlewares = utils.types.isString(middlewares) ? JSON.parse(middlewares) : middlewares
middlewares.forEach(data => {
const middleware = utils.types.isFunction(data)
? data
: require(utils.types.isString(data) ? `./middlewares/${data}-middleware.js` : data.path)
app.use(utils.types.isFunction(middleware.create) ? middleware.create(argv) : middleware)
})
}

@@ -55,21 +64,43 @@

return new Promise((resolve, reject) => {
const server = app.listen(port, err => {
if (err) {
log('error starting test server', err)
reject(err)
} else {
const serverPort = server.address().port
const close = server.close.bind(server)
log(`test server running at port: ${serverPort}`)
resolve({port: serverPort, close})
}
server.on('error', err => {
if (err.code === 'EADDRINUSE') {
log(`error: test server could not start at port ${server.address().port}: port is already in use.`)
let server
if (key && cert) {
server = https
.createServer(
{
key: fs.readFileSync(key),
cert: fs.readFileSync(cert),
},
app,
)
.listen(port, err => {
if (err) {
log('error starting test server', err)
reject(err)
} else {
const close = server.close.bind(server)
log(`test server running at port: ${port}`)
resolve({port, close})
}
})
} else {
server = app.listen(port, err => {
if (err) {
log('error starting test server', err)
reject(err)
} else {
log('error in test server:', err)
const serverPort = server.address().port
const close = server.close.bind(server)
log(`test server running at port: ${serverPort}`)
resolve({port: serverPort, close})
}
reject(err)
})
}
server.on('error', err => {
if (err.code === 'EADDRINUSE') {
log(`error: test server could not start at port ${server.address().port}: port is already in use.`)
} else {
log('error in test server:', err)
}
reject(err)
})

@@ -76,0 +107,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