Skip to content

Commit

Permalink
chore(package): upgrade packages
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffijoe committed Feb 9, 2021
1 parent e791fa9 commit 1d2df2e
Show file tree
Hide file tree
Showing 11 changed files with 7,921 additions and 5,502 deletions.
3 changes: 2 additions & 1 deletion lib/invokers.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7,862 changes: 7,862 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions package.json
Expand Up @@ -47,31 +47,31 @@
"homepage": "https://github.com/talyssonoc/awilix-express",
"dependencies": {
"awilix-router-core": "^1.6.1",
"tslib": "^1.10.0"
"tslib": "^2.1.0"
},
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-decorators": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@types/express": "^4.17.1",
"@types/glob": "^7.1.1",
"@types/jest": "^24.0.18",
"@types/node": "^12.7.9",
"@types/rimraf": "^2.0.2",
"@types/jest": "^26.0.20",
"@types/node": "^14.14.25",
"@types/rimraf": "^3.0.0",
"assert-request": "^1.0.6",
"awilix": "^4.2.2",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.4.2",
"babel-jest": "^26.6.3",
"coveralls": "^3.0.6",
"express": "^4.17.1",
"jest": "^24.9.0",
"prettier": "^1.18.2",
"jest": "^26.6.3",
"prettier": "^2.2.1",
"rimraf": "^3.0.0",
"ts-jest": "^24.1.0",
"tslint": "^5.20.0",
"ts-jest": "^26.5.1",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0",
"tslint-config-standard": "^8.0.1",
"typescript": "^3.6.3"
"tslint-config-standard": "^9.0.0",
"typescript": "^4.1.3"
},
"peerDependencies": {
"awilix": "^4.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/awilix-express.test.ts
@@ -1,7 +1,7 @@
import * as awilixExpress from '../'

describe('awilix-express', function() {
it('exists', function() {
describe('awilix-express', function () {
it('exists', function () {
expect(awilixExpress).toBeDefined()
expect(awilixExpress.scopePerRequest).toBeDefined()
expect(awilixExpress.makeInvoker).toBeDefined()
Expand Down
22 changes: 7 additions & 15 deletions src/__tests__/controller.test.ts
Expand Up @@ -39,26 +39,17 @@ describe('controller registration', () => {
.okay()
.header('x-root-before', 'ts')
.json({ method: 'POST', id: '123' }),
request
.get('/ts')
.okay()
.json({ message: 'index' }),
request
.get('/ping')
.okay()
.json({ message: 'pong' }),
request
.get('/func')
.okay()
.json({ message: 'func' })
request.get('/ts').okay().json({ message: 'index' }),
request.get('/ping').okay().json({ message: 'pong' }),
request.get('/func').okay().json({ message: 'func' }),
])
})
})

function createServer(): Promise<[http.Server, any]> {
const app = Express()
const container = createContainer().register({
service: asFunction(() => ({ get: (message: string) => ({ message }) }))
service: asFunction(() => ({ get: (message: string) => ({ message }) })),
})
app.use(scopePerRequest(container))
app.use(loadControllers('__fixtures__/1/*.*'))
Expand All @@ -67,14 +58,15 @@ function createServer(): Promise<[http.Server, any]> {
app.use(
controller(
createController(({ service }: any) => ({
func: (req: any, res: Express.Response) => res.send(service.get('func'))
func: (req: any, res: Express.Response) =>
res.send(service.get('func')),
}))
.prefix('/func')
.get('', 'func')
)
)

return new Promise(resolve => {
return new Promise((resolve) => {
const server = app.listen(() => {
const addr = server.address() as AddressInfo
resolve([server, AssertRequest(`http://127.0.0.1:${addr.port}`)])
Expand Down
34 changes: 17 additions & 17 deletions src/__tests__/integration.test.ts
Expand Up @@ -21,12 +21,12 @@ class TestClass {

function testFactoryFunction({
testFactoryFunctionInvocation,
testService
testService,
}: any) {
return {
handle(req: any, res: Express.Response) {
res.send({ success: true })
}
},
}
}

Expand All @@ -36,7 +36,7 @@ function createServer(spies: any) {

const container = createContainer()
.register({
testService: asClass(TestService).scoped()
testService: asClass(TestService).scoped(),
})
// These will be registered as transient.
.register(
Expand All @@ -60,38 +60,38 @@ function createServer(spies: any) {
})
}

describe('integration', function() {
describe('integration', function () {
let request: any
let server: any
let serviceConstructor: any
let testClassConstructor: any
let testFactoryFunctionInvocation: any

beforeEach(function() {
beforeEach(function () {
serviceConstructor = jest.fn()
testClassConstructor = jest.fn()
testFactoryFunctionInvocation = jest.fn()
const spies = {
serviceConstructor,
testClassConstructor,
testFactoryFunctionInvocation
testFactoryFunctionInvocation,
}
return createServer(spies).then(s => {
return createServer(spies).then((s) => {
server = s
const addr = server.address()
request = AssertRequest(`http://127.0.0.1:${addr.port}`)
})
})

afterEach(function() {
afterEach(function () {
server.close()
})

describe('makeInvoker', function() {
it('makes sure the spy is called once for each request', function() {
describe('makeInvoker', function () {
it('makes sure the spy is called once for each request', function () {
return Promise.all([
request.get('/function').okay(),
request.get('/function').okay()
request.get('/function').okay(),
]).then(() => {
expect(testClassConstructor).not.toHaveBeenCalled()
expect(testFactoryFunctionInvocation).toHaveBeenCalledTimes(2)
Expand All @@ -100,11 +100,11 @@ describe('integration', function() {
})
})

describe('makeClassInvoker', function() {
it('makes sure the spy is called once for each request', function() {
describe('makeClassInvoker', function () {
it('makes sure the spy is called once for each request', function () {
return Promise.all([
request.get('/class').okay(),
request.get('/class').okay()
request.get('/class').okay(),
]).then(() => {
expect(testFactoryFunctionInvocation).not.toHaveBeenCalled()
expect(testClassConstructor).toHaveBeenCalledTimes(2)
Expand All @@ -113,12 +113,12 @@ describe('integration', function() {
})
})

describe('Invoker Descriptive Error', function() {
it('throws an error when calling non-existent route handler and returns descriptive message', function() {
describe('Invoker Descriptive Error', function () {
it('throws an error when calling non-existent route handler and returns descriptive message', function () {
return request
.get('/fail')
.status(500)
.assert(function(res: any) {
.assert(function (res: any) {
return res.body.includes('does not exist on the controller')
})
})
Expand Down
26 changes: 13 additions & 13 deletions src/__tests__/invokers.test.ts
Expand Up @@ -2,13 +2,13 @@ import { makeClassInvoker, makeFunctionInvoker, inject } from '../invokers'
import { createContainer, AwilixContainer, asValue, asFunction } from 'awilix'
import * as Express from 'express'

describe('invokers', function() {
describe('invokers', function () {
let container: AwilixContainer
let methodSpy: any
let factorySpy: any
let constructorSpy: any
let request: any
beforeEach(function() {
beforeEach(function () {
factorySpy = jest.fn()
constructorSpy = jest.fn()
methodSpy = jest.fn()
Expand All @@ -17,16 +17,16 @@ describe('invokers', function() {
request = { container }
})

describe('makeFunctionInvoker', function() {
it('returns callable middleware', function() {
describe('makeFunctionInvoker', function () {
it('returns callable middleware', function () {
function target({ param }: any) {
factorySpy()
const obj = {
method(req: any, res: Express.Response) {
methodSpy()
expect(this).toBe(obj)
return [req, param]
}
},
}
return obj
}
Expand All @@ -42,15 +42,15 @@ describe('invokers', function() {
expect(methodSpy).toHaveBeenCalledTimes(2)
})

it('returns callable async middleware', async function() {
it('returns callable async middleware', async function () {
function target({ param }: any) {
factorySpy()
const obj = {
async method(req: any, res: Express.Response) {
methodSpy()
expect(this).toBe(obj)
return [req, param]
}
},
}
return obj
}
Expand All @@ -66,15 +66,15 @@ describe('invokers', function() {
expect(methodSpy).toHaveBeenCalledTimes(2)
})

it('returns callable async middleware that handles errors', async function() {
it('returns callable async middleware that handles errors', async function () {
function target({ param }: any) {
factorySpy()
const obj = {
async method(req: any, res: Express.Response) {
methodSpy()
expect(this).toBe(obj)
throw new Error('42')
}
},
}
return obj
}
Expand All @@ -91,8 +91,8 @@ describe('invokers', function() {
})
})

describe('makeClassInvoker', function() {
it('returns callable middleware', function() {
describe('makeClassInvoker', function () {
it('returns callable middleware', function () {
class Target {
param: any
constructor({ param }: any) {
Expand All @@ -118,7 +118,7 @@ describe('invokers', function() {
expect(methodSpy).toHaveBeenCalledTimes(2)
})

it('returns callable async middleware', async function() {
it('returns callable async middleware', async function () {
class Target {
param: any
constructor({ param }: any) {
Expand All @@ -144,7 +144,7 @@ describe('invokers', function() {
expect(methodSpy).toHaveBeenCalledTimes(2)
})

it('returns callable async middleware that handles errors', async function() {
it('returns callable async middleware that handles errors', async function () {
class Target {
param: any
constructor({ param }: any) {
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/scope-per-request.test.ts
Expand Up @@ -2,8 +2,8 @@ import { scopePerRequest } from '../scope-per-request'
import { createContainer } from 'awilix'
import * as Express from 'express'

describe('scopePerRequest', function() {
it('returns a middleware that creates a scope and attaches it to a context + calls next', function() {
describe('scopePerRequest', function () {
it('returns a middleware that creates a scope and attaches it to a context + calls next', function () {
const container = createContainer()
const middleware = scopePerRequest(container)
const next = jest.fn(() => 42)
Expand Down
8 changes: 4 additions & 4 deletions src/controller.ts
Expand Up @@ -6,7 +6,7 @@ import {
getStateAndTarget,
IStateAndTarget,
IAwilixControllerBuilder,
ClassOrFunctionReturning
ClassOrFunctionReturning,
} from 'awilix-router-core'
import { makeInvoker } from './invokers'
import { Router } from 'express'
Expand All @@ -31,7 +31,7 @@ export function controller(
): Router {
const router = Router()
if (Array.isArray(ControllerClass)) {
ControllerClass.forEach(c =>
ControllerClass.forEach((c) =>
_registerController(router, getStateAndTarget(c))
)
} else {
Expand All @@ -51,7 +51,7 @@ export function loadControllers(pattern: string, opts?: IOptions): Router {
const router = Router()
findControllers(pattern, {
...opts,
absolute: true
absolute: true,
}).forEach(_registerController.bind(null, router))

return router
Expand All @@ -74,7 +74,7 @@ function _registerController(
const { state, target } = stateAndTarget
const rolledUp = rollUpState(state)
rolledUp.forEach((methodCfg, methodName) => {
methodCfg.verbs.forEach(httpVerb => {
methodCfg.verbs.forEach((httpVerb) => {
let method = httpVerb.toLowerCase()
if (httpVerb === HttpVerbs.ALL) {
method = 'all'
Expand Down
2 changes: 1 addition & 1 deletion src/invokers.ts
Expand Up @@ -6,7 +6,7 @@ import {
Constructor,
asClass,
ClassOrFunctionReturning,
FunctionReturning
FunctionReturning,
} from 'awilix'
import { isClass } from 'awilix/lib/utils'
import { NextFunction, Request, Response } from 'express'
Expand Down

0 comments on commit 1d2df2e

Please sign in to comment.