Skip to content

Commit

Permalink
Export originCallback and originFunction
Browse files Browse the repository at this point in the history
Fixes #62 #63
  • Loading branch information
ghostd committed May 2, 2020
1 parent 5f3ec69 commit e1607fd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { Http2SecureServer, Http2Server, Http2ServerRequest, Http2ServerResponse

import fastify = require('fastify');

type originCallback = (err: Error | null, allow: boolean) => void;
export type originCallback = (err: Error | null, allow: boolean) => void;

type originFunction = (origin: string, callback: originCallback) => void;
export type originFunction = (origin: string | undefined, callback: originCallback) => void;

type originType = string | boolean | RegExp;

Expand Down
4 changes: 2 additions & 2 deletions test/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,8 @@ appHttp2.register(fastifyCors, {
})

appHttp2.register(fastifyCors, {
origin: (origin: string, cb: (err: Error | null, allow: boolean) => void) => {
if (/localhost/.test(origin) || typeof origin === 'undefined') {
origin: (origin: string | undefined, cb: (err: Error | null, allow: boolean) => void) => {
if (typeof origin === 'undefined' || /localhost/.test(origin)) {
cb(null, true)
return
}
Expand Down

0 comments on commit e1607fd

Please sign in to comment.