Skip to content

Commit d1c31ee

Browse files
authored
make startRedirectPath optional (#184)
1 parent 53ebe19 commit d1c31ee

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export interface FastifyOAuth2Options {
2727
tokenRequestParams?: Object;
2828
generateStateFunction?: Function;
2929
checkStateFunction?: Function;
30-
startRedirectPath: string;
30+
startRedirectPath?: string;
3131
tags?: string[];
3232
schema?: object;
3333
}

test/types/index.test-d.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import fastify from 'fastify';
22
import { expectAssignable, expectError, expectType } from 'tsd';
3-
import fastifyOauth2, { Credentials, OAuth2Namespace, OAuth2Token, ProviderConfiguration } from '../..';
3+
import fastifyOauth2, { FastifyOAuth2Options, Credentials, OAuth2Namespace, OAuth2Token, ProviderConfiguration } from '../..';
44

55
/**
66
* Preparing some data for testing.
@@ -15,7 +15,7 @@ const credentials: Credentials = {
1515
},
1616
auth: auth,
1717
};
18-
const OAuth2Options = {
18+
const OAuth2Options: FastifyOAuth2Options = {
1919
name: 'testOAuthName',
2020
scope: scope,
2121
credentials: credentials,
@@ -30,6 +30,23 @@ const server = fastify();
3030

3131
server.register(fastifyOauth2, OAuth2Options);
3232

33+
server.register(fastifyOauth2, {
34+
name: 'testOAuthName',
35+
scope: scope,
36+
credentials: credentials,
37+
callbackUri: 'http://localhost/testOauth/callback',
38+
checkStateFunction: () => {},
39+
})
40+
41+
expectError(server.register(fastifyOauth2, {
42+
name: 'testOAuthName',
43+
scope: scope,
44+
credentials: credentials,
45+
callbackUri: 'http://localhost/testOauth/callback',
46+
checkStateFunction: () => {},
47+
startRedirectPath: 2,
48+
}))
49+
3350
declare module 'fastify' {
3451
// Developers need to define this in their code like they have to do with all decorators.
3552
interface FastifyInstance {

0 commit comments

Comments
 (0)