Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Different types of Application from @feathersjs/feathers and @feathersjs/express (dove) #2533

Closed
idaho opened this issue Jan 17, 2022 · 0 comments · Fixed by #2539
Closed

Comments

@idaho
Copy link
Contributor

idaho commented Jan 17, 2022

Steps to reproduce

During the usage of the Application, we get some incompatibility between the types of @feathersjs/feathers and @feathersjs/express.

  1. Getting incorrect settings types if we are using the Application of @feathersjs/express, but with @feathersjs/feathers we get.
import * as express from '@feathersjs/express';
import { feathers } from '@feathersjs/feathers';

interface Configuration {
  foo: boolean;
  bar: string;
}

type Application = express.Application<any, { configuration: Configuration }>;

const configuration: Configuration = {
  foo: true,
  bar: 'baz'
};

const expressify = express.default;

const application: Application = expressify(feathers());

application.set('configuration', configuration);

const { foo } = application.get('configuration')

no-setting-types

import * as express from '@feathersjs/express';
import { feathers , Application as FeathersApplication } from '@feathersjs/feathers';

interface Configuration {
  foo: boolean;
  bar: string;
}

type Application = FeathersApplication<any, { configuration: Configuration }>;

const configuration: Configuration = {
  foo: true,
  bar: 'baz'
};

const expressify = express.default;

const application: Application = expressify(feathers());

application.set('configuration', configuration);

const { foo } = application.get('configuration')

settings-type

  1. cannot use express middleware with Application type of @feathersjs/feathers
import * as express from '@feathersjs/express';
import { feathers , Application as FeathersApplication } from '@feathersjs/feathers';
import { NextFunction, Request, Response } from 'express-serve-static-core';
import { IncomingMessage, ServerResponse } from 'http';

type Application = FeathersApplication<any, any>;

const expressify = express.default;

const application: Application = expressify(feathers());

application.use(`*/_next`, async (req: Request, res: Response, next: NextFunction): Promise<void> => {
   next();
});

application.all('*', async (req: IncomingMessage, res: ServerResponse, next: NextFunction): Promise<void> => {
  next();
});

Getting error:

  • Type '(req: Request<ParamsDictionary, any, any, ParsedQs, Record<string, any>>, res: Response<any, Record<string, any>, number>, next: NextFunction) => Promise<...>' has no properties in common with type 'Partial<ServiceMethods<any, Partial>>
  • Property 'all' does not exist on type 'Application'.ts(2339)

But if we are using the @feathers/express Application type, it works, but then the settings types of the Application aren't available any more.

Expected behavior

In the @feathersjs/feathers Application type, it should be possible to add a custom express middleware if we are using express. Even the all method should be available, because of the different behaviour to use.

System configuration

Module versions (especially the part that's not working):

@feathersjs/express: 5.0.0-pre.15
@feathersjs/feathers: 5.0.0-pre.15
typescript: 4.5.4

NodeJS version:
16.13.3

Operating System:

macOS: 10.15.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant