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

fix Application.addMiddleware #143

Closed
wants to merge 1 commit into from
Closed

fix Application.addMiddleware #143

wants to merge 1 commit into from

Conversation

artem-burlakov-ext-orion
Copy link

@artem-burlakov-ext-orion artem-burlakov-ext-orion commented Mar 8, 2021

before:

 addMiddleware(filepath) {
    const filename = path.basename(filepath);
    const middlewareName = filename.replace(path.extname(filename), '');
    log('addMiddleware', middlewareName, filepath);
    // FIXME: check uniqueness
    this.middlewares[middlewareName] = filepath;
  }

after:

addMiddleware(filepath) {
    const filename = path.basename(filepath);
    const middlewareName = filename.replace(path.extname(filename), '');
    log('addMiddleware', middlewareName, filepath);
    if (has(this.middlewares, middlewareName)) {
      throw new Error(`Middleware ${middlewareName} already exists`);
    }
    this.middlewares[middlewareName] = filepath;
  }

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 this pull request may close these issues.

None yet

1 participant