Skip to content

Commit

Permalink
refactor: fix typing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
thetutlage committed Oct 19, 2023
1 parent c1e0bc1 commit a73d9ec
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 32 deletions.
38 changes: 15 additions & 23 deletions examples/config/ally.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,44 @@
import { defineConfig } from '../../src/define_config.js'
import { defineConfig, services } from '../../index.js'

const allyConfig = defineConfig({
discord: {
driver: 'discord',
discord: services.discord({
clientId: process.env.DISCORD_CLIENT_ID!,
clientSecret: process.env.DISCORD_CLIENT_SECRET!,
callbackUrl: `http://localhost:${process.env.PORT}/discord/callback`,
},
google: {
driver: 'google',
}),
google: services.google({
clientId: process.env.GOOGLE_CLIENT_ID!,
clientSecret: process.env.GOOGLE_CLIENT_SECRET!,
callbackUrl: `http://localhost:${process.env.PORT}/google/callback`,
},
github: {
driver: 'github',
}),
github: services.github({
clientId: process.env.GITHUB_CLIENT_ID!,
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
callbackUrl: `http://localhost:${process.env.PORT}/github/callback`,
},
linkedin: {
driver: 'linkedin',
}),
linkedin: services.linkedin({
clientId: process.env.LINKEDIN_CLIENT_ID!,
clientSecret: process.env.LINKEDIN_CLIENT_SECRET!,
callbackUrl: `http://localhost:${process.env.PORT}/linkedin/callback`,
},
twitter: {
driver: 'twitter',
}),
twitter: services.twitter({
clientId: process.env.TWITTER_API_KEY!,
clientSecret: process.env.TWITTER_APP_SECRET!,
callbackUrl: `http://localhost:${process.env.PORT}/twitter/callback`,
},
facebook: {
driver: 'facebook',
}),
facebook: services.facebook({
clientId: process.env.FACEBOOK_CLIENT_ID!,
clientSecret: process.env.FACEBOOK_CLIENT_SECRET!,
callbackUrl: `http://localhost:${process.env.PORT}/facebook/callback`,
},
spotify: {
driver: 'spotify',
}),
spotify: services.spotify({
clientId: process.env.SPOTIFY_CLIENT_ID!,
clientSecret: process.env.SPOTIFY_CLIENT_SECRET!,
callbackUrl: `http://localhost:${process.env.PORT}/spotify/callback`,
},
}),
})

declare module '@adonisjs/ally/types' {
interface SocialProviders extends InferSocialProviders<typeof allyConfig> {}
}

export default allyConfig
2 changes: 1 addition & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export * as errors from './src/errors.js'
export { configure } from './configure.js'
export { stubsRoot } from './stubs/main.js'
export { AllyManager } from './src/ally_manager.js'
export { defineConfig } from './src/define_config.js'
export { defineConfig, services } from './src/define_config.js'

export { RedirectRequest } from './src/redirect_request.js'
export { Oauth1Driver } from './src/abstract_drivers/oauth1.js'
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"license": "MIT",
"devDependencies": {
"@adonisjs/assembler": "^6.1.3-25",
"@adonisjs/core": "^6.1.5-28",
"@adonisjs/core": "^6.1.5-29",
"@adonisjs/eslint-config": "^1.1.8",
"@adonisjs/prettier-config": "^1.1.8",
"@adonisjs/tsconfig": "^1.1.8",
Expand Down Expand Up @@ -78,7 +78,7 @@
"@poppinss/utils": "^6.5.0"
},
"peerDependencies": {
"@adonisjs/core": "^6.1.5-28"
"@adonisjs/core": "^6.1.5-29"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/define_config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import type {
LinkedInDriverConfig,
FacebookDriverConfig,
AllyManagerDriverFactory,
} from '@adonisjs/ally/types'
} from './types.js'

/**
* Shape of config after it has been resolved from
Expand Down
8 changes: 4 additions & 4 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
* file that was distributed with this source code.
*/

import { HttpContext } from '@adonisjs/core/http'
import { ConfigProvider } from '@adonisjs/core/types'
import {
import type { HttpContext } from '@adonisjs/core/http'
import type { ConfigProvider } from '@adonisjs/core/types'
import type {
Oauth2AccessToken,
Oauth1RequestToken,
Oauth1AccessToken,
Expand All @@ -18,7 +18,7 @@ import {
ApiRequestContract,
RedirectRequestContract as ClientRequestContract,
} from '@poppinss/oauth-client/types'
import { AllyManager } from './ally_manager.js'
import type { AllyManager } from './ally_manager.js'

export type { Oauth2AccessToken }
export type { Oauth1AccessToken }
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"rootDir": "./",
"outDir": "./build"
}
}
}

0 comments on commit a73d9ec

Please sign in to comment.