-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 54b4163
Showing
26 changed files
with
8,095 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
indent_size = 2 | ||
indent_style = space | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
dist | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"root": true, | ||
"extends": ["@nuxt/eslint-config"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Dependencies | ||
node_modules | ||
|
||
# Logs | ||
*.log* | ||
|
||
# Temp directories | ||
.temp | ||
.tmp | ||
.cache | ||
|
||
# Yarn | ||
**/.yarn/cache | ||
**/.yarn/*state* | ||
|
||
# Generated dirs | ||
dist | ||
|
||
# Nuxt | ||
.nuxt | ||
.output | ||
.data | ||
.vercel_build_output | ||
.build-* | ||
.netlify | ||
|
||
# Env | ||
.env | ||
|
||
# Testing | ||
reports | ||
coverage | ||
*.lcov | ||
.nyc_output | ||
|
||
# VSCode | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
!.vscode/*.code-snippets | ||
|
||
# Intellij idea | ||
*.iml | ||
.idea | ||
|
||
# OSX | ||
.DS_Store | ||
.AppleDouble | ||
.LSOverride | ||
.AppleDB | ||
.AppleDesktop | ||
Network Trash Folder | ||
Temporary Items | ||
.apdisk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
shamefully-hoist=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# imports.autoImport=false | ||
typescript.includeWorkspace=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<!-- | ||
Get your module up and running quickly. | ||
Find and replace all on all files (CMD+SHIFT+F): | ||
- Name: My Module | ||
- Package name: my-module | ||
- Description: My new Nuxt module | ||
--> | ||
|
||
# My Module | ||
|
||
[![npm version][npm-version-src]][npm-version-href] | ||
[![npm downloads][npm-downloads-src]][npm-downloads-href] | ||
[![License][license-src]][license-href] | ||
[![Nuxt][nuxt-src]][nuxt-href] | ||
|
||
My new Nuxt module for doing amazing things. | ||
|
||
- [✨ Release Notes](/CHANGELOG.md) | ||
<!-- - [🏀 Online playground](https://stackblitz.com/github/your-org/my-module?file=playground%2Fapp.vue) --> | ||
<!-- - [📖 Documentation](https://example.com) --> | ||
|
||
## Features | ||
|
||
<!-- Highlight some of the features your module provide here --> | ||
- ⛰ Foo | ||
- 🚠 Bar | ||
- 🌲 Baz | ||
|
||
## Quick Setup | ||
|
||
1. Add `my-module` dependency to your project | ||
|
||
```bash | ||
# Using pnpm | ||
pnpm add -D my-module | ||
|
||
# Using yarn | ||
yarn add --dev my-module | ||
|
||
# Using npm | ||
npm install --save-dev my-module | ||
``` | ||
|
||
2. Add `my-module` to the `modules` section of `nuxt.config.ts` | ||
|
||
```js | ||
export default defineNuxtConfig({ | ||
modules: [ | ||
'my-module' | ||
] | ||
}) | ||
``` | ||
|
||
That's it! You can now use My Module in your Nuxt app ✨ | ||
|
||
## Development | ||
|
||
```bash | ||
# Install dependencies | ||
npm install | ||
|
||
# Generate type stubs | ||
npm run dev:prepare | ||
|
||
# Develop with the playground | ||
npm run dev | ||
|
||
# Build the playground | ||
npm run dev:build | ||
|
||
# Run ESLint | ||
npm run lint | ||
|
||
# Run Vitest | ||
npm run test | ||
npm run test:watch | ||
|
||
# Release new version | ||
npm run release | ||
``` | ||
|
||
<!-- Badges --> | ||
[npm-version-src]: https://img.shields.io/npm/v/my-module/latest.svg?style=flat&colorA=18181B&colorB=28CF8D | ||
[npm-version-href]: https://npmjs.com/package/my-module | ||
|
||
[npm-downloads-src]: https://img.shields.io/npm/dm/my-module.svg?style=flat&colorA=18181B&colorB=28CF8D | ||
[npm-downloads-href]: https://npmjs.com/package/my-module | ||
|
||
[license-src]: https://img.shields.io/npm/l/my-module.svg?style=flat&colorA=18181B&colorB=28CF8D | ||
[license-href]: https://npmjs.com/package/my-module | ||
|
||
[nuxt-src]: https://img.shields.io/badge/Nuxt-18181B?logo=nuxt.js | ||
[nuxt-href]: https://nuxt.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"name": "my-module", | ||
"version": "1.0.0", | ||
"description": "My new Nuxt module", | ||
"repository": "your-org/my-module", | ||
"license": "MIT", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"types": "./dist/types.d.ts", | ||
"import": "./dist/module.mjs", | ||
"require": "./dist/module.cjs" | ||
} | ||
}, | ||
"main": "./dist/module.cjs", | ||
"types": "./dist/types.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"prepack": "nuxt-module-build", | ||
"dev": "nuxi dev playground", | ||
"dev:build": "nuxi build playground", | ||
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground", | ||
"release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags", | ||
"lint": "eslint .", | ||
"test": "vitest run", | ||
"test:watch": "vitest watch" | ||
}, | ||
"dependencies": { | ||
"@kinde-oss/kinde-typescript-sdk": "^1.0.4", | ||
"@nuxt/kit": "^3.7.1" | ||
}, | ||
"devDependencies": { | ||
"@nuxt/devtools": "latest", | ||
"@nuxt/eslint-config": "^0.2.0", | ||
"@nuxt/module-builder": "^0.5.1", | ||
"@nuxt/schema": "^3.7.1", | ||
"@nuxt/test-utils": "^3.7.1", | ||
"@types/node": "^18.17.14", | ||
"changelogen": "^0.5.5", | ||
"eslint": "^8.48.0", | ||
"nuxt": "^3.7.1", | ||
"vitest": "^0.34.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<template> | ||
<div> | ||
<NuxtLink href="/api/login" external>Login</NuxtLink> | ||
</div> | ||
</template> | ||
|
||
<script setup> | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export default defineNuxtConfig({ | ||
modules: ['../src/module'], | ||
myModule: {}, | ||
devtools: { enabled: true }, | ||
runtimeConfig: { | ||
kinde: { | ||
authDomain: '', | ||
clientId: '', | ||
clientSecret: '', | ||
redirectURL: '', | ||
logoutRedirectURL: '', | ||
} | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"private": true, | ||
"name": "my-module-playground", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "nuxi dev", | ||
"build": "nuxi build", | ||
"generate": "nuxi generate" | ||
}, | ||
"devDependencies": { | ||
"nuxt": "latest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default defineEventHandler(async event => { | ||
const loginURL = await kindeClient.login(event.context.kinde.sessionManager) | ||
await sendRedirect(event, loginURL.href) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
export default defineEventHandler(async event => { | ||
const loginURL = await kindeClient.login(event.context.kinde.sessionManager) | ||
|
||
return { | ||
success: true, | ||
loginURL | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Session } from "inspector" | ||
import { H3Event } from 'h3' | ||
|
||
export default defineEventHandler(async event => { | ||
event.context.kinde = { | ||
sessionManager: await createSessionManager(event) | ||
} | ||
}) | ||
|
||
interface SessionManager { | ||
getSessionItem: (itemKey: string) => unknown | null; | ||
setSessionItem: (itemKey: string, itemValue: unknown) => void; | ||
removeSessionItem: (itemKey: string) => void; | ||
destroySession: () => void; | ||
} | ||
|
||
async function createSessionManager(event: H3Event): Promise<SessionManager> { | ||
const config = { name: 'kinde', password: 'slkdaslkdjfskldafjaslkdjfasldkfjsdf' } | ||
const session = await getSession(event, config) | ||
console.log(session.data) | ||
return { | ||
getSessionItem: (itemKey) => { | ||
return session.data[itemKey] | ||
}, | ||
setSessionItem: (itemKey, itemValue) => { | ||
return updateSession(event, config, { | ||
[itemKey]: itemValue | ||
}) | ||
}, | ||
removeSessionItem: (itemKey) => { | ||
return updateSession(event, config, { | ||
[itemKey]: undefined | ||
}) | ||
}, | ||
destroySession: () => { | ||
return clearSession(event, config) | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default defineEventHandler(async event => { | ||
await kindeClient.handleRedirectToApp(event.context.kinde.sessionManager, getRequestURL(event)) | ||
await sendRedirect(event, '/') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "../.nuxt/tsconfig.server.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { | ||
createKindeServerClient, | ||
GrantType, | ||
type ACClientOptions, | ||
type PKCEClientOptions, | ||
type CCClientOptions, | ||
type ACClient, | ||
type CCClient | ||
} from "@kinde-oss/kinde-typescript-sdk"; | ||
|
||
const config = useRuntimeConfig() | ||
|
||
const clientOptions: ACClientOptions = { | ||
authDomain: config.kinde.authDomain, | ||
clientId: config.kinde.clientId, | ||
clientSecret: config.kinde.clientSecret, | ||
logoutRedirectURL: config.kinde.logoutRedirectURL, | ||
redirectURL: config.kinde.redirectURL | ||
}; | ||
|
||
//AUTHORIZATION_CODE client | ||
// const kindeClient = createKindeServerClient<ACClient, ACClientOptions>( | ||
// GrantType.AUTHORIZATION_CODE, | ||
// clientOptions | ||
// ); | ||
|
||
//or PKCE client | ||
export const kindeClient = createKindeServerClient<ACClient, PKCEClientOptions>( | ||
GrantType.PKCE, | ||
clientOptions | ||
); | ||
|
||
//or CLIENT_CREDENTIALS client | ||
// const kindeClient = createKindeServerClient<CCClient, CCClientOptions>( | ||
// GrantType.CLIENT_CREDENTIALS, | ||
// clientOptions | ||
// ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "./.nuxt/tsconfig.json" | ||
} |
Oops, something went wrong.