Skip to content

Commit

Permalink
chore(story): apply changes back to base layer (#27)
Browse files Browse the repository at this point in the history
## What?

This PR does these things:

- create `space-plugin-nuxt-base` project that contains all the auth logic
- create `space-plugin-nuxt-starter` project, which is sort of a demo to show how to use the `-base` layer, with a simple example of listing stories
- updates the Story Starter to use `space-plugin-nuxt-base` layer.

## Why?

JIRA: EXT-2179

<!--
  Explain the **motivation** for making this change.
  What existing problem does the pull request solve?
  Are there any linked issues?
-->

## How to test? (optional)

<!--
  Demonstrate the code is solid.
  Example: The exact commands you ran and their output,
  screenshots / videos if the pull request changes UI.
-->
  • Loading branch information
eunjae-lee authored Jan 31, 2024
1 parent acf9b57 commit 54abb31
Show file tree
Hide file tree
Showing 49 changed files with 14,966 additions and 112 deletions.
3 changes: 3 additions & 0 deletions space-plugin-nuxt-base/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CLIENT_ID=
CLIENT_SECRET=
BASE_URL=
10 changes: 10 additions & 0 deletions space-plugin-nuxt-base/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
root: true,
extends: ['@nuxt/eslint-config', 'plugin:vuejs-accessibility/recommended'],
rules: {
'vue/html-indent': 'off',
'vue/max-attributes-per-line': 'off',
'vue/multi-word-component-names': 'off',
'vue/html-self-closing': 'off',
},
};
24 changes: 24 additions & 0 deletions space-plugin-nuxt-base/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Nuxt dev/build outputs
.output
.data
.nuxt
.nitro
.cache
dist

# Node dependencies
node_modules

# Logs
logs
*.log

# Misc
.DS_Store
.fleet
.idea

# Local env files
.env
.env.*
!.env.example
1 change: 1 addition & 0 deletions space-plugin-nuxt-base/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
shamefully-hoist=true
23 changes: 23 additions & 0 deletions space-plugin-nuxt-base/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# `space-plugin-nuxt-base` layer

This Nuxt layer adds basic authentication flow to your existing Storyblok's Space Plugin app.

## Configuration

In your `nuxt.config.ts`,

```js
export default defineNuxtConfig({
extends: ['github:storyblok/space-tool-plugins/space-plugin-nuxt-base'],
});
```

and make sure you have the `.env` file.

```
CLIENT_ID=
CLIENT_SECRET=
BASE_URL=
```

To learn more about the configuration, read the [space-plugin-nuxt-starter's README](https://github.com/storyblok/space-tool-plugins/blob/main/space-plugin-nuxt-starter/README.md#configuration).
19 changes: 19 additions & 0 deletions space-plugin-nuxt-base/app.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export default defineAppConfig({
auth: {
endpointPrefix: '/api/connect',
initOauthFlowUrl: `/api/connect/storyblok`,
successCallback: '/',
errorCallback: '/401',
},
});

declare module '@nuxt/schema' {
interface AppConfigInput {
auth: {
endpointPrefix: string;
initOauthFlowUrl: string;
successCallback: string;
errorCallback: string;
};
}
}
9 changes: 9 additions & 0 deletions space-plugin-nuxt-base/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { AppSession } from '@storyblok/app-extension-auth';

declare module 'h3' {
interface H3EventContext {
appSession: AppSession;
}
}

export default {};
4 changes: 4 additions & 0 deletions space-plugin-nuxt-base/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
devtools: { enabled: true },
});
24 changes: 24 additions & 0 deletions space-plugin-nuxt-base/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"version": "0.0.1",
"name": "@storyblok/space-plugin-nuxt-base",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"dependencies": {
"@storyblok/app-extension-auth": "1.0.0-alpha.1"
},
"devDependencies": {
"@nuxt/devtools": "latest",
"h3": "^1.8.2",
"nuxt": "^3.8.0",
"vue": "^3.3.4",
"vue-router": "^4.2.5",
"typescript": "^5.1.3"
}
}
13 changes: 13 additions & 0 deletions space-plugin-nuxt-base/pages/index.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<template>
<div class="container">This is `@storyblok/space-plugin-nuxt-base`.</div>
</template>

<style scoped>
.container {
display: flex;
justify-content: center;
align-items: center;
widows: 100%;
height: 100vh;
}
</style>
Loading

0 comments on commit 54abb31

Please sign in to comment.