Skip to content
This repository was archived by the owner on Apr 27, 2021. It is now read-only.

Commit cbdfbd6

Browse files
committed
Update npm packages
1 parent 4fed250 commit cbdfbd6

File tree

8 files changed

+3347
-2288
lines changed

8 files changed

+3347
-2288
lines changed

.babelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"presets": ["env", "stage-2"],
3-
"plugins": ["transform-runtime"]
2+
"presets": ["@babel/preset-env"],
3+
"plugins": ["@babel/plugin-transform-runtime", "@babel/plugin-proposal-class-properties"]
44
}

.eslintrc.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
"object-curly-spacing": [
4040
"error",
4141
"always"
42-
]
42+
],
43+
"no-prototype-builtins": "off",
44+
"require-atomic-updates": "off"
4345
}
4446
}

package.json

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,20 @@
3434
],
3535
"license": "MIT",
3636
"dependencies": {
37-
"babel-runtime": "^6.26.0"
37+
"@babel/runtime": "^7.4.5"
3838
},
3939
"devDependencies": {
40+
"@babel/cli": "^7.4.4",
41+
"@babel/core": "^7.4.5",
42+
"@babel/plugin-proposal-class-properties": "^7.4.4",
43+
"@babel/plugin-transform-runtime": "^7.4.4",
44+
"@babel/preset-env": "^7.4.5",
4045
"@redirectionio/proxy": "file:./.",
41-
"babel-cli": "^6.26.0",
42-
"babel-eslint": "^8.2.1",
43-
"babel-plugin-transform-runtime": "^6.23.0",
44-
"babel-preset-env": "^1.6.1",
45-
"babel-preset-stage-2": "^6.24.1",
46-
"eslint": "^4.14.0",
47-
"express": "^4.16.2",
48-
"jest": "^22.0.4",
49-
"pm2": "^2.9.3"
46+
"babel-eslint": "^10.0.2",
47+
"eslint": "^6.0.1",
48+
"esm": "^3.2.25",
49+
"express": "^4.17.1",
50+
"jest": "^24.8.0",
51+
"pm2": "^3.5.1"
5052
}
5153
}

src/Client.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,11 +130,7 @@ export default class Client {
130130

131131
let socket = null
132132

133-
try {
134-
socket = await this.getConnection()
135-
} catch (error) {
136-
throw error
137-
}
133+
socket = await this.getConnection()
138134

139135
let response = null
140136

src/RedirectionIO.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,7 @@ export default class RedirectionIO {
7272

7373
let response = null
7474

75-
try {
76-
response = await client.findRedirect(request)
77-
} catch (error) {
78-
throw error
79-
}
75+
response = await client.findRedirect(request)
8076

8177
return response
8278
}
@@ -93,11 +89,7 @@ export default class RedirectionIO {
9389
const response = req.rio.response || new Response(res.statusCode)
9490
const client = new Client(this.connections, 10, false)
9591

96-
try {
97-
await client.log(request, response)
98-
} catch (error) {
99-
throw error
100-
}
92+
await client.log(request, response)
10193
})
10294
}
10395
}

tests/Client.test.js

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,32 @@ import { spawn } from 'child_process'
33
import AgentNotFoundError from '../src/Error/AgentNotFoundError'
44
import BadConfigurationError from '../src/Error/BadConfigurationError'
55
import Client from '../src/Client'
6-
import RedirectResponse from '../src/HttpMessage/RedirectResponse'
76
import Request from '../src/HttpMessage/Request'
87
import Response from '../src/HttpMessage/Response'
98

109
let agent = null
1110
let client = null
1211

1312
beforeAll(done => {
14-
agent = spawn('./node_modules/.bin/babel-node', [__dirname + '/../src/Resources/fake_agent.js'], { detached: true })
13+
agent = spawn('node', ['-r', 'esm', __dirname + '/../src/Resources/fake_agent.js'], { detached: true })
1514
agent.stdout.on('data', () => done())
1615

1716
client = new Client({ 'fake_agent': 'tcp://localhost:3100' })
1817
})
1918

2019
afterAll(() => {
21-
process.kill(-agent.pid)
20+
try {
21+
process.kill(-agent.pid)
22+
} catch (error) {
23+
// Fake agent already stopped
24+
}
2225
})
2326

2427
it('find redirect when rule exist', async () => {
2528
const request = createRequest({ path: '/foo' })
2629
const response = await client.findRedirect(request)
2730

28-
expect(response).toBeInstanceOf(RedirectResponse)
31+
expect(response).toBeInstanceOf(Response)
2932
expect(response.statusCode).toBe(301)
3033
expect(response.location).toBe('/bar')
3134
})
@@ -42,13 +45,13 @@ it('find twice redirect when rule exist', async () => {
4245
const request = createRequest({ path: '/foo' })
4346
let response = await client.findRedirect(request)
4447

45-
expect(response).toBeInstanceOf(RedirectResponse)
48+
expect(response).toBeInstanceOf(Response)
4649
expect(response.statusCode).toBe(301)
4750
expect(response.location).toBe('/bar')
4851

4952
response = await client.findRedirect(request)
5053

51-
expect(response).toBeInstanceOf(RedirectResponse)
54+
expect(response).toBeInstanceOf(Response)
5255
expect(response.statusCode).toBe(301)
5356
expect(response.location).toBe('/bar')
5457
})
@@ -107,7 +110,7 @@ it('find redirect in multiple hosts array', async () => {
107110
const request = createRequest({ path: '/foo' })
108111
const response = await customClient.findRedirect(request)
109112

110-
expect(response).toBeInstanceOf(RedirectResponse)
113+
expect(response).toBeInstanceOf(Response)
111114
expect(response.statusCode).toBe(301)
112115
expect(response.location).toBe('/bar')
113116
})
@@ -119,7 +122,7 @@ it('find nothing when agent goes down', async () => {
119122
return new Promise(resolve => {
120123
const env = Object.create(process.env)
121124
env.RIO_PORT = 3101
122-
customAgent = spawn('./node_modules/.bin/babel-node', [__dirname + '/../src/Resources/fake_agent.js'], { env: env, detached: true })
125+
customAgent = spawn('node', ['-r', 'esm', __dirname + '/../src/Resources/fake_agent.js'], { env: env, detached: true })
123126
customAgent.stdout.on('data', () => resolve())
124127
customAgent.stderr.on('data', data => console.log(data.toString()))
125128
})
@@ -134,11 +137,15 @@ it('find nothing when agent goes down', async () => {
134137
const request = createRequest({ path: '/foo' })
135138
let response = await customClient.findRedirect(request)
136139

137-
expect(response).toBeInstanceOf(RedirectResponse)
140+
expect(response).toBeInstanceOf(Response)
138141
expect(response.statusCode).toBe(301)
139142
expect(response.location).toBe('/bar')
140143

141-
process.kill(-customAgent.pid)
144+
try {
145+
process.kill(-customAgent.pid)
146+
} catch (error) {
147+
// Fake agent already stopped
148+
}
142149

143150
await expect(customClient.findRedirect(request)).resolves.toBeFalsy()
144151
})

tests/RedirectionIO.test.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,17 @@ const config = { 'fake_agent': 'tcp://127.0.0.1:3200' }
99
beforeAll(done => {
1010
const env = Object.create(process.env)
1111
env.RIO_PORT = 3200
12-
agent = spawn('./node_modules/.bin/babel-node', [__dirname + '/../src/Resources/fake_agent.js'], { env: env, detached: true })
12+
agent = spawn('node', ['-r', 'esm', __dirname + '/../src/Resources/fake_agent.js'], { env: env, detached: true })
1313
agent.stdout.on('data', () => done())
1414
})
1515

16-
afterAll(() => process.kill(-agent.pid))
16+
afterAll(() => {
17+
try {
18+
process.kill(-agent.pid)
19+
} catch (error) {
20+
// Fake agent already stopped
21+
}
22+
})
1723

1824
it('find redirect in express server when rule exist', done => {
1925
// Mocks all needed functions/objects
@@ -135,7 +141,7 @@ it('find nothing in express server when agent is down', done => {
135141
try {
136142
process.kill(-agent.pid)
137143
} catch (error) {
138-
// do nothing
144+
// Fake agent already stopped
139145
}
140146

141147
// Mocks all needed functions/objects

0 commit comments

Comments
 (0)