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

Feat: Added CORS to config #302

Merged
merged 5 commits into from
Aug 10, 2016
Merged

Feat: Added CORS to config #302

merged 5 commits into from
Aug 10, 2016

Conversation

adampash
Copy link
Contributor

This pull request adds the ability to configure CORS headers via the config. There's a lot of new-to-me work on this one in terms of Flow, so I'm including some notes.

Closes #282

]
}
},

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it might be useful to show the CORS config in an example project, so I've left this in here for now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea!

@@ -103,7 +104,8 @@ export default async function initialize<T: Application>(app: T, {

const server = new Server({
Copy link
Contributor

@zacharygolba zacharygolba Aug 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be beneficial to spread the serverOpts here:

  const server = new Server({
    ...serverOpts,
    router,
    logger
  });

@zacharygolba
Copy link
Contributor

👏 Awesome work! I have a few suggestions regarding style and structure but functionally speaking this on point!


import type { Writable } from 'stream';
import type { IncomingMessage, Server as HTTPServer } from 'http';

import type { Request } from './request/interfaces';
import type { Response } from './response/interfaces';
import type { Server$opts } from './interfaces';
import type { Server$config } from './interfaces';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can condense this import down to a single line:

import type { Server$opts, Server$config } from './interfaces';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, yes!

@zacharygolba
Copy link
Contributor

Almost there!

@zacharygolba
Copy link
Contributor

This LGTM. Awesome work! 😃

@zacharygolba
Copy link
Contributor

P.S:
I tested this pretty vigorously with the fetch api in CORS mode and it works great. Even 500's can be gracefully handled when using CORS. Way to go man!

@adampash adampash merged commit fd1d01e into master Aug 10, 2016
@adampash adampash deleted the feat-add-cors-config branch August 10, 2016 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants