feathersjs / feathers

The API and real-time application framework
https://feathersjs.com
MIT License
15.06k stars 752 forks source link

[v4] Custom class extending LocalStrategy error #1395

Closed periabyte closed 5 years ago

periabyte commented 5 years ago

Steps to reproduce

Registering a custom strategy which extends an existing one throws an error

// Custom Class
class MyLocalStrategy extends LocalStrategy {
    getEntityQuery(query, params) {
        // Query for user but only include users marked as `active`
        return {
            ...query,
            active: true,
            $limit: 1,
        };
    }
}
// authentication.js
export default app => {
    const authentication = new AuthenticationService(app);
    authentication.register("jwt", new JWTStrategy());
    authentication.register("local", new MyLocalStrategy(););

    app.use("/authentication", authentication);
    app.configure(expressOauth());
}

Expected behavior

Actual behavior

TypeError: Class constructor LocalStrategy cannot be invoked without 'new' at new MyLocalStrategy

### System configuration

Tell us about the applicable parts of your setup.

**Module versions** (especially the part that's not working):
"@feathersjs/authentication": "^4.0.0-pre.3",
"@feathersjs/authentication-jwt": "^2.0.9",
"@feathersjs/authentication-local": "^4.0.0-pre.3",
"@feathersjs/authentication-oauth": "^4.0.0-pre.3",
"@feathersjs/configuration": "^4.0.0-pre.3",
"@feathersjs/errors": "^4.0.0-pre.3",
"@feathersjs/express": "^4.0.0-pre.3",
"@feathersjs/feathers": "^4.0.0-pre.3",
"@feathersjs/socketio": "^4.0.0-pre.3",


**NodeJS version**:
`10.16.0`

**Operating System**:
WSL (UBUNTU)
periabyte commented 5 years ago

sorry, found out that this issue is related to my babel setting