Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

Commit

Permalink
chore(package): update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Aug 30, 2019
1 parent 435f038 commit 558b4c7
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 47 deletions.
18 changes: 13 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,22 @@
"author": "virk,poppinss",
"license": "MIT",
"devDependencies": {
"@adonisjs/mrm-preset": "^2.0.3",
"@adonisjs/mrm-preset": "^2.1.0",
"@types/content-disposition": "^0.5.2",
"@types/destroy": "^1.0.0",
"@types/etag": "^1.8.0",
"@types/fresh": "^0.5.0",
"@types/mime-types": "^2.1.0",
"@types/node": "^12.7.2",
"@types/on-finished": "^2.3.1",
"@types/supertest": "^2.0.8",
"@types/vary": "^1.1.0",
"commitizen": "^4.0.3",
"cz-conventional-changelog": "^3.0.2",
"del-cli": "^2.0.0",
"doctoc": "^1.4.0",
"husky": "^3.0.4",
"japa": "^2.0.10",
"japa": "^3.0.0",
"mrm": "^1.2.2",
"np": "^5.0.3",
"supertest": "^4.0.2",
Expand All @@ -44,7 +52,7 @@
"typedoc": "^0.15.0",
"typedoc-plugin-external-module-name": "^2.1.0",
"typedoc-plugin-markdown": "^2.1.4",
"typescript": "^3.5.3"
"typescript": "^3.6.2"
},
"nyc": {
"exclude": [
Expand All @@ -66,8 +74,8 @@
}
},
"dependencies": {
"@poppinss/cookie": "^1.0.1",
"@poppinss/dev-utils": "^1.0.0",
"@poppinss/cookie": "^1.0.2",
"@poppinss/dev-utils": "^1.0.1",
"content-disposition": "^0.5.3",
"destroy": "^1.0.4",
"etag": "^1.8.1",
Expand Down
24 changes: 12 additions & 12 deletions src/Response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
* file that was distributed with this source code.
*/

import { ServerResponse, IncomingMessage } from 'http'
import { DeepReadonly } from 'ts-essentials'
import etag from 'etag'
import vary from 'vary'
import fresh from 'fresh'
import { parse } from 'url'
import * as etag from 'etag'
import * as onFinished from 'on-finished'
import * as destroy from 'destroy'
import { createReadStream, stat, Stats } from 'fs'
import mime from 'mime-types'
import destroy from 'destroy'
import { extname } from 'path'
import * as mime from 'mime-types'
import * as contentDisposition from 'content-disposition'
import * as vary from 'vary'
import * as fresh from 'fresh'
import onFinished from 'on-finished'
import { Macroable } from 'macroable'
import { DeepReadonly } from 'ts-essentials'
import { createReadStream, stat, Stats } from 'fs'
import contentDisposition from 'content-disposition'
import { ServerResponse, IncomingMessage } from 'http'
import { serialize, CookieOptions } from '@poppinss/cookie'

import {
Expand Down Expand Up @@ -226,7 +226,7 @@ export class Response extends Macroable implements ResponseContract {
/**
* Stream the body to the response and handles cleaning up the stream
*/
private _streamBody (body: ResponseStream, errorCallback?: ((error) => any)) {
private _streamBody (body: ResponseStream, errorCallback?: ((error: NodeJS.ErrnoException) => any)) {
return new Promise((resolve) => {
let finished = false

Expand Down Expand Up @@ -281,7 +281,7 @@ export class Response extends Macroable implements ResponseContract {
private async _download (
filePath: string,
generateEtag: boolean,
errorCallback?: ((error) => any),
errorCallback?: ((error: NodeJS.ErrnoException) => any),
) {
try {
const stats = await statFn(filePath)
Expand Down
60 changes: 30 additions & 30 deletions test/response.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
* file that was distributed with this source code.
*/

import * as test from 'japa'
import * as supertest from 'supertest'
import test from 'japa'
import etag from 'etag'
import { join } from 'path'
import { Filesystem } from '@poppinss/dev-utils'
import { createWriteStream, createReadStream } from 'fs'
import supertest from 'supertest'
import { createServer } from 'http'
import * as etag from 'etag'
import { parse } from '@poppinss/cookie'
import { Filesystem } from '@poppinss/dev-utils'
import { createWriteStream, createReadStream } from 'fs'

import { ResponseConfigContract } from '../src/contracts'
import { Response } from '../src/Response'
import { ResponseConfigContract } from '../src/contracts'

const SECRET = Math.random().toFixed(36).substring(2, 38)

Expand Down Expand Up @@ -88,8 +88,8 @@ test.group('Response', (group) => {
res.end()
})

const { headers } = await supertest(server).get('/')
assert.deepEqual(headers['set-cookie'], ['username=virk', 'age=22'])
const { header } = await supertest(server).get('/')
assert.deepEqual(header['set-cookie'], ['username=virk', 'age=22'])
})

test('add header via append when header doesn\'t exists already', async (assert) => {
Expand All @@ -102,8 +102,8 @@ test.group('Response', (group) => {
res.end()
})

const { headers } = await supertest(server).get('/')
assert.deepEqual(headers['set-cookie'], ['age=22'])
const { header } = await supertest(server).get('/')
assert.deepEqual(header['set-cookie'], ['age=22'])
})

test('append to the header value when it\'s an array', async (assert) => {
Expand All @@ -117,8 +117,8 @@ test.group('Response', (group) => {
res.end()
})

const { headers } = await supertest(server).get('/')
assert.deepEqual(headers['set-cookie'], ['username=virk', 'age=22'])
const { header } = await supertest(server).get('/')
assert.deepEqual(header['set-cookie'], ['username=virk', 'age=22'])
})

test('do not set header when value is non-existy', async (assert) => {
Expand All @@ -131,8 +131,8 @@ test.group('Response', (group) => {
res.end()
})

const { headers } = await supertest(server).get('/')
assert.isUndefined(headers['set-cookie'])
const { header } = await supertest(server).get('/')
assert.isUndefined(header['set-cookie'])
})

test('do not set header when already exists', async () => {
Expand Down Expand Up @@ -160,8 +160,8 @@ test.group('Response', (group) => {
res.end()
})

const { headers } = await supertest(server).get('/')
assert.notProperty(headers, 'content-type')
const { header } = await supertest(server).get('/')
assert.notProperty(header, 'content-type')
})

test('set HTTP status', async () => {
Expand Down Expand Up @@ -667,8 +667,8 @@ test.group('Response', (group) => {
response.finish()
})

const { headers } = await supertest(server).get('/').redirects(1)
assert.equal(headers.location, '/foo')
const { header } = await supertest(server).get('/').redirects(1)
assert.equal(header.location, '/foo')
})

test('redirect to given url with query string', async (assert) => {
Expand All @@ -679,8 +679,8 @@ test.group('Response', (group) => {
response.finish()
})

const { headers } = await supertest(server).get('/?username=virk').redirects(1)
assert.equal(headers.location, '/foo?username=virk')
const { header } = await supertest(server).get('/?username=virk').redirects(1)
assert.equal(header.location, '/foo?username=virk')
})

test('redirect to given url and set custom statusCode', async () => {
Expand Down Expand Up @@ -738,8 +738,8 @@ test.group('Response', (group) => {
response.finish()
})

const { headers } = await supertest(server).get('/').expect(204)
assert.isUndefined(headers['content-type'])
const { header } = await supertest(server).get('/').expect(204)
assert.isUndefined(header['content-type'])
})

test('generate etag when set to true', async () => {
Expand Down Expand Up @@ -878,8 +878,8 @@ test.group('Response', (group) => {
response.finish()
})

const { headers } = await supertest(server).get('/').expect(200)
const cookies = headers['set-cookie'].map((cookie: string) => {
const { header } = await supertest(server).get('/').expect(200)
const cookies = header['set-cookie'].map((cookie: string) => {
const [value, ...options] = cookie.split(';')
return { value: parse(value, SECRET), options: options.map((option) => option.trim()) }
})
Expand All @@ -903,8 +903,8 @@ test.group('Response', (group) => {
response.finish()
})

const { headers } = await supertest(server).get('/').expect(200)
const cookies = headers['set-cookie'].map((cookie: string) => {
const { header } = await supertest(server).get('/').expect(200)
const cookies = header['set-cookie'].map((cookie: string) => {
const [value, ...options] = cookie.split(';')
return { value: parse(value, SECRET), options: options.map((option) => option.trim()) }
})
Expand All @@ -928,8 +928,8 @@ test.group('Response', (group) => {
response.finish()
})

const { headers } = await supertest(server).get('/').expect(200)
const cookies = headers['set-cookie'].map((cookie: string) => {
const { header } = await supertest(server).get('/').expect(200)
const cookies = header['set-cookie'].map((cookie: string) => {
const [value, ...options] = cookie.split(';')
return { value: parse(value, SECRET), options: options.map((option) => option.trim()) }
})
Expand All @@ -953,8 +953,8 @@ test.group('Response', (group) => {
response.finish()
})

const { headers } = await supertest(server).get('/').expect(200)
const cookies = headers['set-cookie'].map((cookie: string) => {
const { header } = await supertest(server).get('/').expect(200)
const cookies = header['set-cookie'].map((cookie: string) => {
const [value, ...options] = cookie.split(';')
return { value: parse(value, SECRET), options: options.map((option) => option.trim()) }
})
Expand Down

0 comments on commit 558b4c7

Please sign in to comment.