From 329bf5da38b21c5785ba3069372bc25568be648c Mon Sep 17 00:00:00 2001 From: Aleksey Klimenko Date: Sat, 24 Mar 2018 04:29:35 +0300 Subject: [PATCH 1/3] [feathersjs__express] clarified definitions and tests --- .../feathersjs__express-tests.ts | 11 +++++++---- types/feathersjs__express/index.d.ts | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/types/feathersjs__express/feathersjs__express-tests.ts b/types/feathersjs__express/feathersjs__express-tests.ts index 687191d0c6..6120ed483f 100644 --- a/types/feathersjs__express/feathersjs__express-tests.ts +++ b/types/feathersjs__express/feathersjs__express-tests.ts @@ -1,8 +1,11 @@ import feathers, { Application } from '@feathersjs/feathers'; -import feathersExpress, { original, rest, notFound, errorHandler } from '@feathersjs/express'; +import feathersExpress, * as express from "@feathersjs/express"; const app = feathersExpress(feathers()); -app.configure(rest()); -app.use(notFound()); -app.use(errorHandler()); +app.use(express.json()); +app.use(express.urlencoded({ extended: true })); +app.use('/', express.static('./public')); +app.configure(express.rest()); +app.use(express.notFound()); +app.use(express.errorHandler({ logger: console })); diff --git a/types/feathersjs__express/index.d.ts b/types/feathersjs__express/index.d.ts index f50203432f..7e1eea1a1d 100644 --- a/types/feathersjs__express/index.d.ts +++ b/types/feathersjs__express/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for @feathersjs/express 1.1 // Project: http://feathersjs.com/ // Definitions by: Jan Lohage +// Aleksey Klimenko // Definitions: https://github.com/feathersjs-ecosystem/feathers-typescript // TypeScript Version: 2.3 @@ -10,12 +11,18 @@ import * as express from 'express'; export default function feathersExpress(app: FeathersApplication): Application; export type Application = express.Application & FeathersApplication; -export function errorHandler(options?: any): express.ErrorRequestHandler; +export function errorHandler(options?: { + public?: string, + logger?: { error?: (msg: string) => void }, + html?: any, + json?: any, +}): express.ErrorRequestHandler; export function notFound(): express.RequestHandler; -export const rest: { - (): () => void; - formatter: express.RequestHandler; -}; + +export function rest(): (handler?: express.RequestHandler) => void; +export namespace rest { + export let formatter: express.RequestHandler; +} /* * Re-export of the express package. From 240454d11c296e054d5b4ccf29a902d064d7918f Mon Sep 17 00:00:00 2001 From: Aleksey Klimenko Date: Sat, 24 Mar 2018 11:33:15 +0300 Subject: [PATCH 2/3] fix(@feathersjs/express): removed redudant export --- types/feathersjs__express/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/feathersjs__express/index.d.ts b/types/feathersjs__express/index.d.ts index 7e1eea1a1d..16bff00cd4 100644 --- a/types/feathersjs__express/index.d.ts +++ b/types/feathersjs__express/index.d.ts @@ -21,7 +21,7 @@ export function notFound(): express.RequestHandler; export function rest(): (handler?: express.RequestHandler) => void; export namespace rest { - export let formatter: express.RequestHandler; + let formatter: express.RequestHandler; } /* From f113a24a8c3783fa8c773c78af72981e4d37f0d2 Mon Sep 17 00:00:00 2001 From: Aleksey Klimenko Date: Mon, 26 Mar 2018 02:13:46 +0300 Subject: [PATCH 3/3] fix(@feathersjs/express): defined 'rest' as calllable-object and fixed codystyle --- types/feathersjs__express/feathersjs__express-tests.ts | 2 +- types/feathersjs__express/index.d.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/types/feathersjs__express/feathersjs__express-tests.ts b/types/feathersjs__express/feathersjs__express-tests.ts index 6120ed483f..1bd1f5221a 100644 --- a/types/feathersjs__express/feathersjs__express-tests.ts +++ b/types/feathersjs__express/feathersjs__express-tests.ts @@ -1,5 +1,5 @@ import feathers, { Application } from '@feathersjs/feathers'; -import feathersExpress, * as express from "@feathersjs/express"; +import feathersExpress, * as express from '@feathersjs/express'; const app = feathersExpress(feathers()); diff --git a/types/feathersjs__express/index.d.ts b/types/feathersjs__express/index.d.ts index 16bff00cd4..d526a3db0c 100644 --- a/types/feathersjs__express/index.d.ts +++ b/types/feathersjs__express/index.d.ts @@ -19,10 +19,10 @@ export function errorHandler(options?: { }): express.ErrorRequestHandler; export function notFound(): express.RequestHandler; -export function rest(): (handler?: express.RequestHandler) => void; -export namespace rest { - let formatter: express.RequestHandler; -} +export const rest: { + (handler?: express.RequestHandler): () => void; + formatter: express.RequestHandler; +}; /* * Re-export of the express package.