12 |
13 |
{{ data?.hello || "Nuxt3 ❤️ GraphQL" }}
14 | {{ ping }}
15 |
16 |
17 |
--------------------------------------------------------------------------------
/formkit.config.ts:
--------------------------------------------------------------------------------
1 | import { DefaultConfigOptions } from "@formkit/vue";
2 | import { generateClasses } from "@formkit/tailwindcss";
3 |
4 | export default {
5 | config: {
6 | classes: generateClasses({
7 | global: {
8 | outer: "mb-3",
9 | label: "font-bold",
10 | help: "text-sm text-slate-400",
11 | messages: "mb-3 text-sm text-red-500",
12 | },
13 | submit: {
14 | input: "btn",
15 | },
16 | }),
17 | },
18 | } as DefaultConfigOptions;
19 |
--------------------------------------------------------------------------------
/prisma/schema.prisma:
--------------------------------------------------------------------------------
1 | datasource db {
2 | provider = "mysql"
3 | url = env("DATABASE_URL")
4 | }
5 |
6 | generator client {
7 | provider = "prisma-client-js"
8 | }
9 |
10 | generator nexusPrisma {
11 | provider = "nexus-prisma"
12 | }
13 |
14 | model User {
15 | id Int @id @default(autoincrement())
16 | email String @unique
17 | password String
18 | role UserRole @default(UNVERIFIED)
19 | }
20 |
21 | enum UserRole {
22 | UNVERIFIED
23 | GUEST
24 | EDITOR
25 | ADMIN
26 | }
27 |
--------------------------------------------------------------------------------
/codegen.yml:
--------------------------------------------------------------------------------
1 | schema: generated/schema.graphql
2 | documents: graphql/**/*.graphql
3 | generates:
4 | generated/schema.ts:
5 | plugins:
6 | - typescript
7 | composables/:
8 | preset: near-operation-file
9 | presetConfig:
10 | baseTypesPath: ../generated/schema.ts
11 | extension: .ts
12 | folder: ../composables
13 | config:
14 | documentMode: documentNode
15 | plugins:
16 | - typescript
17 | - typescript-operations
18 | - typescript-vue-urql
19 | hooks:
20 | afterAllFileWrite:
21 | - eslint --fix ./generated ./composables
22 |
--------------------------------------------------------------------------------
/middleware/has-user-role.ts:
--------------------------------------------------------------------------------
1 | import type { UserRole } from "@prisma/client";
2 |
3 | export default defineNuxtRouteMiddleware((to, from) => {
4 | const { isAuthenticated, hasUserRole } = useAuth();
5 | if (!isAuthenticated.value) {
6 | return navigateTo(`/login?redirect=${to.fullPath}`);
7 | } else if (!hasUserRole(to.meta.hasUserRole || "ADMIN")) {
8 | return abortNavigation("You do not have permission to visit this page.");
9 | }
10 | });
11 |
12 | declare module "nuxt3/dist/pages/runtime/composables" {
13 | interface PageMeta {
14 | hasUserRole?: UserRole;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Nuxt 3 full stack application starter
2 |
3 | This repository contains the example code for the [Exploring Nuxt3 as a full stack solution](https://dev.to/lewebsimple/nuxt3-graphql-4p5l) series.
4 |
5 | ## Setup
6 |
7 | Make sure to install the dependencies
8 |
9 | ```bash
10 | yarn install
11 | ```
12 |
13 | ## Development
14 |
15 | Start the development server on http://localhost:3000
16 |
17 | ```bash
18 | yarn dev
19 | ```
20 |
21 | ## Production
22 |
23 | Build the application for production:
24 |
25 | ```bash
26 | yarn build
27 | ```
28 |
29 | Checkout the [deployment documentation](https://v3.nuxtjs.org/docs/deployment).
--------------------------------------------------------------------------------
/tailwind.config.js:
--------------------------------------------------------------------------------
1 | /* eslint-disable @typescript-eslint/no-var-requires */
2 |
3 | module.exports = {
4 | theme: {
5 | extend: {
6 | container: {
7 | center: true,
8 | padding: "1.5rem",
9 | },
10 | typography: {
11 | DEFAULT: {
12 | css: {
13 | maxWidth: "none",
14 | },
15 | },
16 | },
17 | },
18 | },
19 | plugins: [
20 | require("@tailwindcss/forms"),
21 | require("@tailwindcss/line-clamp"),
22 | require("@tailwindcss/typography"),
23 | require("@formkit/tailwindcss").default,
24 | ],
25 | content: ["formkit.config.ts"],
26 | };
27 |
--------------------------------------------------------------------------------
/components/nav/menu.vue:
--------------------------------------------------------------------------------
1 |
4 |
5 |