Skip to content

Commit

Permalink
feat!: move to layer
Browse files Browse the repository at this point in the history
  • Loading branch information
atinux committed Feb 27, 2024
1 parent 97820cc commit 5309e02
Show file tree
Hide file tree
Showing 35 changed files with 261 additions and 466 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ npx nypm@latest add @nuxthub/core
npx nypm@latest add -D wrangler
```

3. Add `@nuxthub/core` to the `modules` section of `nuxt.config.ts`
3. Add `@nuxthub/core` to the `extends` section of `nuxt.config.ts`

```js
export default defineNuxtConfig({
modules: [
extends: [
'@nuxthub/core'
]
})
Expand Down
9 changes: 5 additions & 4 deletions docs/components/Logo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
<path fill="#00DC82" d="M168 200h111c3.542 0 6.932-1.244 10-3 3.068-1.756 6.23-3.959 8-7 1.77-3.041 3.002-6.49 3-10.001-.002-3.511-1.227-6.959-3-9.998L222 41c-1.77-3.04-3.933-5.2448-7-7-3.067-1.7552-7.458-3-11-3s-6.933 1.2448-10 3-5.23 3.96-7 7l-19 33-38-64.00236c-1.772-3.0398-3.932-6.24273-7-7.99764-3.068-1.754913-6.458-2-10-2s-6.932.245087-10 2c-3.0677 1.75491-6.2283 4.95784-8 7.99764L2 170.001C.226979 173.04.00154312 176.488.00000191 179.999-.0015393 183.51.229648 186.959 2 190c1.77035 3.04 4.93245 5.244 8 7 3.0675 1.756 6.4578 3 10 3h70c27.737 0 47.925-12.442 62-36l34-59 18-31 55 94h-73l-18 32Zm-79-32H40l73-126 37 63-24.509 42.725C116.144 163.01 105.488 168 89 168Z" />
<path fill="#00DC82" fill-rule="evenodd" d="M1120.15 197.2c4.93 2.267 10.12 2.8 15.85 2.8 9.73 0 18.35-1.533 25.55-5.8 7.2-4.267 12.67-10.333 16.4-18.2 3.87-7.867 6.05-16.6 6.05-27 0-10.4-2.18-19.933-6.05-27.8-3.73-7.867-9.2-13.933-16.4-18.2-7.07-4.2668-15.4-6.4001-25-6.4001-6.13 0-11.6 1.1333-16.4 3.4-4.8 2.1331-9.22 5.0671-12.15 8.8001V59.3999h-20c-4.42 0-8 3.5817-8 8V200h28v-12c2.8 3.867 7.22 6.933 12.15 9.2Zm-6.4-28.2c-4.53-5.2-6.75-12-6.75-20.4 0-8.533 2.15-15.333 6.55-20.4 4.53-5.2 10.53-7.8 18-7.8 7.47 0 13.4 2.6 17.8 7.8 4.53 5.067 6.8 11.867 6.8 20.4 0 8.4-2.27 15.2-6.8 20.4-4.53 5.067-10.47 7.6-17.8 7.6s-13.27-2.533-17.8-7.6ZM937 200V59.9999h-20c-4.418 0-8 3.5817-8 8V116h-54V59.9999h-28V200h19.946c4.439 0 8.029-3.615 7.999-8.054L854.6 141H909v59h28Zm118-45.989V92.0115h-16c-.12 0-.3.0004-.5.0009-.52.0013-1.21.003-1.5-.0009l-.09-.0012c-2.92-.0397-4.97-.0674-6.91 2.0012-2.23 2.3779-3 4.5651-3 7.9995v52c0 8.059-.46 13.037-4 17-3.54 3.832-6.78 5-14 5-7.09 0-11.457-1.168-15-5-3.543-3.963-4-8.941-4-17v-52c0-3.4344-.769-4.7537-3-6.9995-2.231-2.378-5.588-3-9-3h-16v61.9995c0 14.004 5.389 25.81 13 34 7.742 8.191 19.434 11.989 34 11.989 14.57 0 25.26-3.798 33-11.989 7.74-8.19 13-19.996 13-34Z" clip-rule="evenodd" />
</svg>
<div v-else class="flex items-center gap-1" @click.right.prevent="onLogoClick">
<span>Nuxt</span>
<span class="rounded-sm bg-primary-400 dark:bg-primary-500 text-gray-900 px-0.5">hub</span>
<div v-else class="flex items-center gap-1 text-[25px] font-extrabold" @click.right.prevent="onLogoClick">
<UIcon name="i-simple-icons-nuxtdotjs" class="text-green-400 h-[36px] w-[36px] flex-shrink-0" />
<span class="relative top-1">Nuxt</span>
<span class="rounded-sm bg-primary-400 dark:bg-primary-500 text-gray-900 px-[4px] relative top-1">hub</span>
</div>
</template>

<script setup lang="ts">
const defaultLogo = useState('logo-default', () => true)
const defaultLogo = ref(true)
function onLogoClick () {
defaultLogo.value = !defaultLogo.value
Expand Down
9 changes: 5 additions & 4 deletions docs/content/docs/1.getting-started/1.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ Each storage utils is auto-imported and ready to be used in your [Nuxt's server
NuxtHub comes with a powerful proxy system to connect to your project's resources from your local environment, allowing you to work with your remote storage as if it was local.
::

## Modules
## Packages

We plan to provide a complete backend experience for Nuxt apps through various `@nuxthub` modules.

- [`@nuxthub/core`](https://github.com/nuxt-hub/core): Main module to provide storage features
- `@nuxthub/auth`: Authentication module for user management
- `@nuxthub/analytics`: Analytics module to track events within your applicaiton and API
- [`@nuxthub/core`](https://github.com/nuxt-hub/core): Main package to provide storage features
- `@nuxthub/auth`: Add authentication for user management (soon)
- `@nuxthub/email`: Send transactional emails to your users (soon)
- `@nuxthub/analytics`: Understand your traffic and track events within your application and API (soon)
- `@nuxthub/...`: You name it!

::callout
Expand Down
14 changes: 7 additions & 7 deletions docs/content/docs/1.getting-started/2.installation.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
title: Installation
description: Add NuxtHub core module to your Nuxt project.
description: Add NuxtHub to your Nuxt project.
---


## Setup

1. Install the NuxtHub module to your project:
1. Install the NuxtHub package to your project:

::code-group

Expand Down Expand Up @@ -50,18 +50,18 @@ bun add --dev @nuxthub/core

::

3. Add `@nuxthub/core` to your `modules` section in your `nuxt.config`:
3. Add `@nuxthub/core` to your `extends` section in your `nuxt.config`:

```ts [nuxt.config.ts]
export default defineNuxtConfig({
modules: ['@nuxthub/core']
extends: ['@nuxthub/core']
})
```

That's it! You can now use the NuxtHub module in your Nuxt project.
That's it! You can now use NuxtHub features in your Nuxt project.

::callout
The module will create a `.data/hub` directory in your project root, which contains the necessary configuration files and resources for the module to work. It will also add it to the `.gitignore` file to avoid committing it to your repository.
NuxtHub will create a `.data/hub` directory in your project root, which contains the necessary configuration files and resources for the features to work. It will also add it to the `.gitignore` file to avoid committing it to your repository.
::

## Options
Expand All @@ -70,7 +70,7 @@ Configure options in your `nuxt.config.ts` as such:

```ts [nuxt.config.ts]
export default defineNuxtConfig({
modules: ['@nuxthub/core'],
extends: ['@nuxthub/core'],
hub: {
remote: true
}
Expand Down
10 changes: 4 additions & 6 deletions docs/content/docs/1.getting-started/3.deploy.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export default defineNuxtConfig({
})
```

The module will use the remote storage from your deployed project **as long as you are logged in with the [NuxtHub CLI](https://github.com/nuxt-hub/cli) and the local project is linked to a NuxtHub project**.
Nuxt will use the remote storage from your deployed project **as long as you are logged in with the [NuxtHub CLI](https://github.com/nuxt-hub/cli) and the local project is linked to a NuxtHub project**.

## Self-hosted

Expand All @@ -75,22 +75,20 @@ Once the deployment is done, NuxtHub should be ready to use in your deployed pro

### Remote Storage

To enable remote storage in your self-hosted project, the module requires a secret to access it.
To enable remote storage in your self-hosted project, you need to create a secret key.

1. Set the `NUXT_HUB_PROJECT_SECRET` environment variable in your Cloudflare Pages project settings and retry the last deployment to apply the changes.
1. Set the `NUXT_HUB_PROJECT_SECRET` environment variable in your Cloudflare Pages project settings and retry the last deployment to apply the changes (you can generate a random secret on https://www.uuidgenerator.net/version4)
2. Set the same `NUXT_HUB_PROJECT_SECRET` and `NUXT_HUB_PROJECT_URL` environment variables in your local project

```bash [.env]
NUXT_HUB_PROJECT_SECRET=my-project-secret-used-in-cloudflare-env
NUXT_HUB_PROJECT_URL=https://my-nuxthub-project.pages.dev
```

When restarting your local server, the module will automatically use the remote data from your deployed project as long as the `NUXT_HUB_PROJECT_SECRET` matches the one in your Cloudflare Pages project settings.

Then, start your Nuxt project with:

```bash [Terminal]
npx nuxt dev --remote
```

Your development project will now use the remote storage from your deployed project.
NuxtHub will use the remote data from your deployed project as long as the `NUXT_HUB_PROJECT_SECRET` matches the one in your Cloudflare Pages project settings.
8 changes: 6 additions & 2 deletions docs/content/index.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
title: 'NuxtHub'
description: 'Build full-stack Nuxt apps, with zero configuration.'
title: 'NuxtHub: Build full-stack Nuxt apps, on the edge.'
description: 'Access to a Database, Key-Value, and Blob storage with zero configuration. Deploy with confidence on your Cloudflare account and access to your remote storage locally with our secured proxy.'
navigation: false
hero:
title: 'Build full-stack <span class="text-primary">Nuxt apps</span>, on the edge.'
description: 'Access to a Database, Key-Value, and Blob storage with zero configuration. Deploy with confidence on your Cloudflare account and access to your remote storage locally with our secured proxy.'
orientation: horizontal
headline:
to: https://github.com/nuxt-hub/core
label: Alpha version is out!
target: _blank
links:
- label: Get started
icon: i-heroicons-arrow-right-20-solid
Expand Down
6 changes: 4 additions & 2 deletions docs/pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
<script setup lang="ts">
import { joinURL } from 'ufo'
const { data: page } = await useAsyncData('index', () => queryContent('/').findOne())
const { url } = useSiteConfig()
useSeoMeta({
title: page.value.title,
ogTitle: page.value.title,
description: page.value.description,
ogDescription: page.value.description,
ogImage: 'https://hub.nuxt.com/social.png'
ogImage: joinURL(url, '/social.png')
})
</script>

<template>
Expand Down
28 changes: 28 additions & 0 deletions docs/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,34 @@ import defaultTheme from 'tailwindcss/defaultTheme'
export default <Partial<Config>>{
theme: {
extend: {
colors: {
slate: {
50: '#f8fafc',
100: '#f1f5f9',
200: '#e2e8f0',
300: '#cbd5e1',
400: '#94a3b8',
500: '#64748b',
600: '#475569',
700: '#334155',
800: '#1e293b',
900: '#0f172a',
950: '#020420'
},
green: {
50: '#EFFDF5',
100: '#D9FBE8',
200: '#B3F5D1',
300: '#75EDAE',
400: '#00DC82',
500: '#00C16A',
600: '#00A155',
700: '#007F45',
800: '#016538',
900: '#0A5331',
950: '#052e16'
}
},
fontFamily: {
sans: ['DM Sans', 'DM Sans fallback', ...defaultTheme.fontFamily.sans]
}
Expand Down
7 changes: 7 additions & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { createResolver } from '@nuxt/kit'

const { resolve } = createResolver(import.meta.url)

export default defineNuxtConfig({
extends: resolve('src/')
})
25 changes: 8 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,26 @@
"name": "@nuxthub/core",
"private": false,
"version": "0.1.15",
"description": "Nuxt Toolkit to create full-stack applications on the Edge.",
"description": "Build full-stack Nuxt applications on Cloudflare, with zero configuration.",
"repository": {
"type": "git",
"url": "git+https://github.com/nuxt-hub/core.git"
},
"license": "Apache-2.0",
"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",
"main": "./nuxt.config.ts",
"files": [
"dist"
"src",
"nuxt.config.ts"
],
"keywords": ["nuxt", "fullstack", "cloudflare", "database", "kv", "blob"],
"scripts": {
"prepack": "nuxt-module-build build",
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
"dev:prepare": "nuxi prepare playground",
"dev": "nuxi dev playground",
"dev:build": "nuxi build playground",
"docs": "nuxi dev docs",
"docs:build": "nuxi generate docs",
"release": "npm run lint && npm run test && npm run prepack && changelogen --release && npm publish && git push --follow-tags",
"release": "npm run lint && npm run test && changelogen --release && npm publish && git push --follow-tags",
"lint": "eslint .",
"test": "vitest run",
"test:watch": "vitest watch"
Expand All @@ -55,7 +48,6 @@
},
"devDependencies": {
"@nuxt/eslint-config": "^0.2.0",
"@nuxt/module-builder": "^0.5.5",
"@nuxt/schema": "^3.10.3",
"@nuxt/test-utils": "^3.11.0",
"@types/node": "^20.11.20",
Expand All @@ -64,7 +56,6 @@
"nuxt": "^3.10.3",
"typescript": "^5.3.3",
"vitest": "^1.3.1",
"vue-tsc": "^1.8.27",
"wrangler": "^3.29.0"
}
}
}
7 changes: 3 additions & 4 deletions playground/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
export default defineNuxtConfig({
devtools: { enabled: true },
extends: [
'../'
],
modules: [
'../src/module',
'@nuxt/ui',
'@kgierke/nuxt-basic-auth'
],
ui: {
icons: ['heroicons', 'simple-icons']
},
// hub: {
// remote: true
// },
basicAuth: {
enabled: process.env.NODE_ENV === 'production',
allowedRoutes: ['/api/_hub/'],
Expand Down
1 change: 1 addition & 0 deletions playground/server/api/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default eventHandler(async () => {
await kv.set('react:next', { version: 2016 })
await kv.set('react:gatsby', { version: 2015 })


return kv.keys()
// const db = hubDatabase()
// return useProjectKV(projectUrl).getKeys()
Expand Down
Loading

0 comments on commit 5309e02

Please sign in to comment.