├── .eslintrc.json ├── .gitignore ├── .vscode └── settings.json ├── README.md ├── jsconfig.json ├── next.config.js ├── package-lock.json ├── package.json ├── postcss.config.js ├── public ├── next.svg └── vercel.svg ├── src └── app │ ├── actions │ └── create.js │ ├── create │ └── page.jsx │ ├── favicon.ico │ ├── globals.css │ ├── layout.jsx │ └── page.jsx └── tailwind.config.js /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "next/core-web-vitals" 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # next.js 12 | /.next/ 13 | /out/ 14 | 15 | # production 16 | /build 17 | 18 | # misc 19 | .DS_Store 20 | *.pem 21 | 22 | # debug 23 | npm-debug.log* 24 | yarn-debug.log* 25 | yarn-error.log* 26 | 27 | # local env files 28 | .env*.local 29 | 30 | # vercel 31 | .vercel 32 | 33 | # typescript 34 | *.tsbuildinfo 35 | next-env.d.ts 36 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.fontFamily": "Consolas, 'Courier New', monospace" 3 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). 2 | 3 | ## Getting Started 4 | 5 | First, run the development server: 6 | 7 | ```bash 8 | npm run dev 9 | # or 10 | yarn dev 11 | # or 12 | pnpm dev 13 | ``` 14 | 15 | Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. 16 | 17 | You can start editing the page by modifying `app/page.js`. The page auto-updates as you edit the file. 18 | 19 | This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. 20 | 21 | ## Learn More 22 | 23 | To learn more about Next.js, take a look at the following resources: 24 | 25 | - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. 26 | - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. 27 | 28 | You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! 29 | 30 | ## Deploy on Vercel 31 | 32 | The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. 33 | 34 | Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. 35 | -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "paths": { 4 | "@/*": ["./src/*"] 5 | } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /next.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | const nextConfig = { 3 | experimental: { 4 | serverActions: true, 5 | } 6 | } 7 | 8 | module.exports = nextConfig 9 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "redis-books", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "dev": "next dev", 7 | "build": "next build", 8 | "start": "next start", 9 | "lint": "next lint" 10 | }, 11 | "dependencies": { 12 | "autoprefixer": "10.4.15", 13 | "eslint": "8.48.0", 14 | "eslint-config-next": "13.4.19", 15 | "next": "13.4.19", 16 | "postcss": "8.4.28", 17 | "react": "18.2.0", 18 | "react-dom": "18.2.0", 19 | "tailwindcss": "3.3.3" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | 'tailwindcss/nesting': {}, 4 | tailwindcss: {}, 5 | autoprefixer: {}, 6 | }, 7 | } 8 | -------------------------------------------------------------------------------- /public/next.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/vercel.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/app/actions/create.js: -------------------------------------------------------------------------------- 1 | 'use server' 2 | 3 | // import { client } from "@/lib/db" 4 | import { redirect } from 'next/navigation' 5 | 6 | export async function createBook(formData) { 7 | const {title, rating, author, blurb} = Object.fromEntries(formData) 8 | 9 | 10 | } -------------------------------------------------------------------------------- /src/app/create/page.jsx: -------------------------------------------------------------------------------- 1 | 'use client' 2 | 3 | import { createBook } from '@/app/actions/create' 4 | import { useState } from "react" 5 | 6 | export default function Create() { 7 | const [error, setError] = useState('') 8 | 9 | async function handleSubmit(formData) { 10 | const result = await createBook(formData) 11 | 12 | if (result?.error) { 13 | setError(result.error) 14 | } 15 | } 16 | 17 | return ( 18 |
19 |
20 |

Add a New Book

21 | 22 | 23 | 24 | 25 | 26 | {error &&
{error}
} 27 |
28 |
29 | ) 30 | } -------------------------------------------------------------------------------- /src/app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/iamshaunjp/redis-for-beginners/d631549216c6ebe1749b94869d129de3d2c048eb/src/app/favicon.ico -------------------------------------------------------------------------------- /src/app/globals.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | body { 6 | background: #c0e1f4; 7 | padding: 40px 20px; 8 | } 9 | main { 10 | max-width: 760px; 11 | margin: 0 auto; 12 | } 13 | .card { 14 | @apply bg-white p-5 rounded-md shadow-sm my-5; 15 | 16 | & h2 { 17 | @apply mb-0 font-bold; 18 | 19 | & + p { 20 | @apply lowercase text-xs font-bold text-gray-500; 21 | font-variant: small-caps; 22 | } 23 | } 24 | & p { 25 | @apply mb-2 text-sm text-gray-500; 26 | } 27 | } 28 | .btn { 29 | @apply bg-rose-500 text-white p-2 rounded-sm text-xs; 30 | } 31 | form { 32 | @apply max-w-sm mx-auto text-center; 33 | 34 | & input, & textarea { 35 | @apply block w-full p-2 rounded-sm my-4; 36 | } 37 | .error { 38 | @apply 39 | my-4 p-2 text-sm rounded-md border-2 40 | border-red-500 bg-red-200 text-red-500; 41 | } 42 | } -------------------------------------------------------------------------------- /src/app/layout.jsx: -------------------------------------------------------------------------------- 1 | import './globals.css' 2 | import { Inter } from 'next/font/google' 3 | 4 | const inter = Inter({ subsets: ['latin'] }) 5 | 6 | export const metadata = { 7 | title: 'Create Next App', 8 | description: 'Generated by create next app', 9 | } 10 | 11 | export default function RootLayout({ children }) { 12 | return ( 13 | 14 | {children} 15 | 16 | ) 17 | } 18 | -------------------------------------------------------------------------------- /src/app/page.jsx: -------------------------------------------------------------------------------- 1 | import Link from 'next/link' 2 | 3 | const getBooks = async () => { 4 | 5 | } 6 | 7 | export default async function Home() { 8 | 9 | return ( 10 |
11 | 15 | 16 |

List of books here.

17 |
18 | ) 19 | } 20 | -------------------------------------------------------------------------------- /tailwind.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | module.exports = { 3 | content: [ 4 | './src/pages/**/*.{js,ts,jsx,tsx,mdx}', 5 | './src/components/**/*.{js,ts,jsx,tsx,mdx}', 6 | './src/app/**/*.{js,ts,jsx,tsx,mdx}', 7 | ], 8 | theme: { 9 | extend: { 10 | backgroundImage: { 11 | 'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))', 12 | 'gradient-conic': 13 | 'conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))', 14 | }, 15 | }, 16 | }, 17 | plugins: [], 18 | } 19 | --------------------------------------------------------------------------------