├── CODEOWNERS ├── internal ├── app │ └── _your_app_ │ │ └── .keep ├── pkg │ └── _your_private_lib_ │ │ └── .keep └── README.md ├── ui ├── public │ ├── __ENV.js │ ├── favicon.ico │ ├── fonts │ │ ├── Gilroy-Bold.ttf │ │ ├── Gilroy-Heavy.ttf │ │ ├── Gilroy-Light.ttf │ │ ├── Gilroy-Medium.ttf │ │ └── Gilroy-Regular.ttf │ ├── images │ │ ├── manifest │ │ │ ├── icon-192x192.png │ │ │ ├── icon-256x256.png │ │ │ ├── icon-384x384.png │ │ │ └── icon-512x512.png │ │ └── logo │ │ │ └── pocketbase-nextjs-template-logo.png │ ├── manifest.json │ └── vercel.svg ├── .env.production ├── .eslintrc.json ├── .prettierignore ├── .huskyrc ├── lib │ ├── interfaces.ts │ ├── design.ts │ ├── validate.ts │ ├── parser.ts │ └── Icons.tsx ├── postcss.config.js ├── .dockerignore ├── .lintstagedrc ├── components │ ├── Footer.tsx │ ├── general │ │ ├── modals │ │ │ └── Modal.tsx │ │ ├── typo │ │ │ ├── Heading.tsx │ │ │ └── SubHeading.tsx │ │ ├── forms │ │ │ ├── Toggle.tsx │ │ │ └── InputField.tsx │ │ └── buttons │ │ │ └── StyledButton.tsx │ ├── Layout.tsx │ ├── Loading.tsx │ ├── alerts │ │ └── Toast.tsx │ ├── dashboard │ │ └── Stats.tsx │ ├── landingpage │ │ └── Login.tsx │ ├── Navigation.tsx │ └── profile │ │ └── ProfileSettingsForm.tsx ├── .prettierrc ├── pages │ ├── plans.tsx │ ├── settings.tsx │ ├── profile.tsx │ ├── index.tsx │ ├── _app.tsx │ └── dashboard.tsx ├── .gitignore ├── tsconfig.json ├── next.config.js ├── styles │ ├── fonts.css │ └── globals.css ├── config │ └── Api.ts ├── entrypoint.sh ├── tailwind.config.js ├── Dockerfile ├── package.json └── contexts │ └── userContext.tsx ├── .github ├── FUNDING.yaml ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md └── workflows │ ├── ci.yaml │ ├── release.yaml │ └── codeql-analysis.yaml ├── githooks └── README.md ├── assets ├── README.md └── pocketbase-nextjs-template-logo.png ├── init └── README.md ├── test ├── main_test.go ├── util │ └── random_test.go └── env │ └── env_test.go ├── third_party └── README.md ├── .dockerignore ├── configs └── README.md ├── deployments └── README.md ├── api └── README.md ├── SECURITY.md ├── website └── README.md ├── docs └── README.md ├── tools └── README.md ├── examples └── README.md ├── pkg ├── util │ └── random.go ├── server │ └── pocketbase.go ├── env │ └── env.go ├── migrations │ └── collections.go └── README.md ├── docker-compose.yaml ├── .editorconfig ├── .gitignore ├── cmd ├── pocketbase-nextjs-template │ └── main.go └── README.md ├── .pre-commit-config.yaml ├── scripts ├── getting-started.sh └── bump-version.sh ├── Makefile ├── go.mod ├── README.md ├── CODE_OF_CONDUCT.md └── LICENSE /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @natrongmbh 2 | -------------------------------------------------------------------------------- /internal/app/_your_app_/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /internal/pkg/_your_private_lib_/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ui/public/__ENV.js: -------------------------------------------------------------------------------- 1 | window.__ENV = {}; 2 | -------------------------------------------------------------------------------- /.github/FUNDING.yaml: -------------------------------------------------------------------------------- 1 | github: [janlauber] 2 | -------------------------------------------------------------------------------- /githooks/README.md: -------------------------------------------------------------------------------- 1 | # `/githooks` 2 | 3 | Git hooks. 4 | -------------------------------------------------------------------------------- /ui/.env.production: -------------------------------------------------------------------------------- 1 | ENV_API_URL=APP_NEXT_ENV_API_URL 2 | -------------------------------------------------------------------------------- /ui/.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "next/core-web-vitals" 3 | } 4 | -------------------------------------------------------------------------------- /ui/.prettierignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | build 3 | dist 4 | res 5 | coverage 6 | -------------------------------------------------------------------------------- /ui/.huskyrc: -------------------------------------------------------------------------------- 1 | { 2 | "hooks": { 3 | "pre-commit": "tsc && lint-staged" 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /ui/lib/interfaces.ts: -------------------------------------------------------------------------------- 1 | export interface SampleInterface { 2 | name: string; 3 | age: number; 4 | } 5 | -------------------------------------------------------------------------------- /assets/README.md: -------------------------------------------------------------------------------- 1 | # `/assets` 2 | 3 | Other assets to go along with your repository (images, logos, etc). 4 | -------------------------------------------------------------------------------- /ui/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: ["tailwindcss", "autoprefixer", "postcss-100vh-fix"], 3 | } 4 | -------------------------------------------------------------------------------- /ui/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/natrontech/pocketbase-nextjs-template/HEAD/ui/public/favicon.ico -------------------------------------------------------------------------------- /ui/lib/design.ts: -------------------------------------------------------------------------------- 1 | export function classNames(...classes: string[]) { 2 | return classes.filter(Boolean).join(' ') 3 | } 4 | -------------------------------------------------------------------------------- /ui/.dockerignore: -------------------------------------------------------------------------------- 1 | Dockerfile 2 | .dockerignore 3 | node_modules 4 | npm-debug.log 5 | README.md 6 | .next 7 | .git 8 | .env.local 9 | -------------------------------------------------------------------------------- /init/README.md: -------------------------------------------------------------------------------- 1 | # `/init` 2 | 3 | System init (systemd, upstart, sysv) and process manager/supervisor (runit, supervisord) configs. 4 | -------------------------------------------------------------------------------- /test/main_test.go: -------------------------------------------------------------------------------- 1 | package test 2 | 3 | import "testing" 4 | 5 | func TestMain(t *testing.T) { 6 | // Write your code here 7 | } 8 | -------------------------------------------------------------------------------- /third_party/README.md: -------------------------------------------------------------------------------- 1 | # `/third_party` 2 | 3 | External helper tools, forked code and other 3rd party utilities (e.g., Swagger UI). 4 | -------------------------------------------------------------------------------- /ui/public/fonts/Gilroy-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/natrontech/pocketbase-nextjs-template/HEAD/ui/public/fonts/Gilroy-Bold.ttf -------------------------------------------------------------------------------- /ui/public/fonts/Gilroy-Heavy.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/natrontech/pocketbase-nextjs-template/HEAD/ui/public/fonts/Gilroy-Heavy.ttf -------------------------------------------------------------------------------- /ui/public/fonts/Gilroy-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/natrontech/pocketbase-nextjs-template/HEAD/ui/public/fonts/Gilroy-Light.ttf -------------------------------------------------------------------------------- /ui/public/fonts/Gilroy-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/natrontech/pocketbase-nextjs-template/HEAD/ui/public/fonts/Gilroy-Medium.ttf -------------------------------------------------------------------------------- /ui/public/fonts/Gilroy-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/natrontech/pocketbase-nextjs-template/HEAD/ui/public/fonts/Gilroy-Regular.ttf -------------------------------------------------------------------------------- /ui/.lintstagedrc: -------------------------------------------------------------------------------- 1 | { 2 | "**/*.+(js|jsx|css|less|scss|ts|tsx|md)": [ 3 | "prettier --write", 4 | "git add" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /ui/lib/validate.ts: -------------------------------------------------------------------------------- 1 | export const validateEmail = (email: string) => { 2 | const re = /\S+@\S+\.\S+/; 3 | 4 | return re.test(email); 5 | } 6 | -------------------------------------------------------------------------------- /assets/pocketbase-nextjs-template-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/natrontech/pocketbase-nextjs-template/HEAD/assets/pocketbase-nextjs-template-logo.png -------------------------------------------------------------------------------- /ui/public/images/manifest/icon-192x192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/natrontech/pocketbase-nextjs-template/HEAD/ui/public/images/manifest/icon-192x192.png -------------------------------------------------------------------------------- /ui/public/images/manifest/icon-256x256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/natrontech/pocketbase-nextjs-template/HEAD/ui/public/images/manifest/icon-256x256.png -------------------------------------------------------------------------------- /ui/public/images/manifest/icon-384x384.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/natrontech/pocketbase-nextjs-template/HEAD/ui/public/images/manifest/icon-384x384.png -------------------------------------------------------------------------------- /ui/public/images/manifest/icon-512x512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/natrontech/pocketbase-nextjs-template/HEAD/ui/public/images/manifest/icon-512x512.png -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | Dockerfile 2 | .dockerignore 3 | node_modules 4 | vendor 5 | npm-debug.log 6 | README.md 7 | .next 8 | .git 9 | .env.local 10 | ui/ 11 | -------------------------------------------------------------------------------- /configs/README.md: -------------------------------------------------------------------------------- 1 | # `/configs` 2 | 3 | Configuration file templates or default configs. 4 | 5 | Put your `confd` or `consul-template` template files here. 6 | -------------------------------------------------------------------------------- /ui/components/Footer.tsx: -------------------------------------------------------------------------------- 1 | const Footer = () => { 2 | return ( 3 |
4 | 5 |
6 | ) 7 | } 8 | 9 | export default Footer 10 | -------------------------------------------------------------------------------- /ui/components/general/modals/Modal.tsx: -------------------------------------------------------------------------------- 1 | const Modal = () => { 2 | return ( 3 |
4 | 5 |
6 | ) 7 | } 8 | 9 | export default Modal 10 | -------------------------------------------------------------------------------- /ui/public/images/logo/pocketbase-nextjs-template-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/natrontech/pocketbase-nextjs-template/HEAD/ui/public/images/logo/pocketbase-nextjs-template-logo.png -------------------------------------------------------------------------------- /deployments/README.md: -------------------------------------------------------------------------------- 1 | # `/deployments` 2 | 3 | IaaS, PaaS, system and container orchestration deployment configurations and templates (docker-compose, kubernetes/helm, mesos, terraform, bosh). 4 | -------------------------------------------------------------------------------- /api/README.md: -------------------------------------------------------------------------------- 1 | # `/api` 2 | 3 | OpenAPI/Swagger specs, JSON schema files, protocol definition files. 4 | 5 | Examples: 6 | 7 | * https://github.com/kubernetes/kubernetes/tree/master/api 8 | * https://github.com/moby/moby/tree/master/api 9 | -------------------------------------------------------------------------------- /ui/components/general/typo/Heading.tsx: -------------------------------------------------------------------------------- 1 | const Heading = ({ children }: any) => { 2 | return ( 3 |

{children}

4 | ) 5 | } 6 | 7 | export default Heading; 8 | -------------------------------------------------------------------------------- /ui/components/general/typo/SubHeading.tsx: -------------------------------------------------------------------------------- 1 | const SubHeading = ({ children }: any) => { 2 | return ( 3 |

{children}

4 | ) 5 | } 6 | 7 | export default SubHeading; 8 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | | Version | Supported | 6 | | ------- | ------------------ | 7 | | latest | :white_check_mark: | 8 | 9 | ## Reporting a Vulnerability 10 | 11 | Open up an issue :) 12 | -------------------------------------------------------------------------------- /ui/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 120, 3 | "proseWrap": "preserve", 4 | "semi": false, 5 | "singleQuote": true, 6 | "useTabs": false, 7 | "tabWidth": 2, 8 | "arrowParens": "avoid", 9 | "trailingComma": "es5" 10 | } 11 | -------------------------------------------------------------------------------- /website/README.md: -------------------------------------------------------------------------------- 1 | # `/website` 2 | 3 | This is the place to put your project's website data if you are not using GitHub pages. 4 | 5 | Examples: 6 | 7 | * https://github.com/hashicorp/vault/tree/master/website 8 | * https://github.com/perkeep/perkeep/tree/master/website 9 | -------------------------------------------------------------------------------- /ui/lib/parser.ts: -------------------------------------------------------------------------------- 1 | import Api from "../config/Api"; 2 | import { User } from 'pocketbase'; 3 | 4 | export const parseUserAvatarUrl = (userObj: User) => { 5 | return Api.getUri() + "/files/" + userObj?.profile?.["@collectionId"] + "/" + userObj?.profile?.id + "/" + userObj?.profile?.avatar; 6 | } 7 | -------------------------------------------------------------------------------- /ui/pages/plans.tsx: -------------------------------------------------------------------------------- 1 | import { NextPage } from "next"; 2 | import Heading from "../components/general/typo/Heading"; 3 | 4 | const Plans: NextPage = () => { 5 | return ( 6 |
7 | Plans 8 |
9 | ) 10 | } 11 | 12 | export default Plans; 13 | -------------------------------------------------------------------------------- /docs/README.md: -------------------------------------------------------------------------------- 1 | # `/docs` 2 | 3 | Design and user documents (in addition to your godoc generated documentation). 4 | 5 | Examples: 6 | 7 | * https://github.com/gohugoio/hugo/tree/master/docs 8 | * https://github.com/openshift/origin/tree/master/docs 9 | * https://github.com/dapr/dapr/tree/master/docs 10 | -------------------------------------------------------------------------------- /ui/pages/settings.tsx: -------------------------------------------------------------------------------- 1 | import { NextPage } from "next"; 2 | import Heading from "../components/general/typo/Heading"; 3 | 4 | const Settings: NextPage = () => { 5 | return ( 6 |
7 | Settings 8 |
9 | ) 10 | } 11 | 12 | export default Settings; 13 | -------------------------------------------------------------------------------- /tools/README.md: -------------------------------------------------------------------------------- 1 | # `/tools` 2 | 3 | Supporting tools for this project. Note that these tools can import code from the `/pkg` and `/internal` directories. 4 | 5 | Examples: 6 | 7 | * https://github.com/istio/istio/tree/master/tools 8 | * https://github.com/openshift/origin/tree/master/tools 9 | * https://github.com/dapr/dapr/tree/master/tools 10 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | # `/examples` 2 | 3 | Examples for your applications and/or public libraries. 4 | 5 | Examples: 6 | 7 | * https://github.com/nats-io/nats.go/tree/master/examples 8 | * https://github.com/docker-slim/docker-slim/tree/master/examples 9 | * https://github.com/gohugoio/hugo/tree/master/examples 10 | * https://github.com/hashicorp/packer/tree/master/examples 11 | -------------------------------------------------------------------------------- /pkg/util/random.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import "math/rand" 4 | 5 | var ( 6 | letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890$%&/()=?!#+*~") 7 | ) 8 | 9 | // RandomStringBytes returns a random string of length n 10 | func RandomStringBytes(n int) string { 11 | b := make([]rune, n) 12 | for i := range b { 13 | b[i] = letters[rand.Intn(len(letters))] 14 | } 15 | return string(b) 16 | } 17 | -------------------------------------------------------------------------------- /docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: "3.9" 2 | services: 3 | pocketbase: 4 | build: 5 | context: ./ 6 | dockerfile: ./build/package/pocketbase/Dockerfile 7 | ports: 8 | - "8090:8090" 9 | volumes: 10 | - pb_data:/pb_data 11 | 12 | # ui: 13 | # build: ./ui/ 14 | # ports: 15 | # - "3000:3000" 16 | # environment: 17 | # - ENV_API_URL=http://template.natron.io:8090 18 | 19 | 20 | volumes: 21 | pb_data: {} 22 | -------------------------------------------------------------------------------- /ui/pages/profile.tsx: -------------------------------------------------------------------------------- 1 | import { NextPage } from "next"; 2 | import Heading from "../components/general/typo/Heading"; 3 | import ProfileSettingsForm from "../components/profile/ProfileSettingsForm"; 4 | 5 | const Profile: NextPage = () => { 6 | return ( 7 |
8 | Profile 9 |
10 | 11 |
12 |
13 | ) 14 | } 15 | 16 | export default Profile; 17 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | trim_trailing_whitespace = true 8 | 9 | [{*.go,Makefile,.gitmodules,go.mod,go.sum}] 10 | indent_style = tab 11 | 12 | [*.md] 13 | indent_style = tab 14 | trim_trailing_whitespace = false 15 | 16 | [*.{yml,yaml,json}] 17 | indent_style = space 18 | indent_size = 2 19 | 20 | [*.{js,jsx,ts,tsx,css,less,sass,scss,vue,py}] 21 | indent_style = space 22 | indent_size = 4 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Mac OS X files 2 | .DS_Store 3 | 4 | # Binaries for programs and plugins 5 | *.exe 6 | *.exe~ 7 | *.dll 8 | *.so 9 | *.dylib 10 | 11 | # Test binary, build with `go test -c` 12 | *.test 13 | 14 | # Output of the go coverage tool, specifically when used with LiteIDE 15 | *.out 16 | 17 | # Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736 18 | .glide/ 19 | 20 | # Dependency directories (remove the comment below to include it) 21 | vendor/ 22 | pb_data/ 23 | temp/ 24 | -------------------------------------------------------------------------------- /cmd/pocketbase-nextjs-template/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "log" 5 | 6 | "github.com/natrongmbh/pocketbase-nextjs-template/pkg/env" 7 | "github.com/natrongmbh/pocketbase-nextjs-template/pkg/server" 8 | ) 9 | 10 | func init() { 11 | err := env.Init() 12 | if err != nil { 13 | log.Fatal(err) 14 | } 15 | } 16 | 17 | func main() { 18 | server := server.Setup() 19 | 20 | // start the pocketbase server 21 | if err := server.Start(); err != nil { 22 | log.Fatal(err) 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: https://github.com/pre-commit/pre-commit-hooks 3 | rev: v4.3.0 4 | hooks: 5 | - id: check-yaml 6 | - id: end-of-file-fixer 7 | - id: trailing-whitespace 8 | exclude: README.md 9 | - repo: https://github.com/psf/black 10 | rev: 22.8.0 11 | hooks: 12 | - id: black 13 | - repo: https://github.com/dnephin/pre-commit-golang 14 | rev: v0.5.0 15 | hooks: 16 | - id: go-fmt 17 | - id: no-go-testing 18 | - id: golangci-lint 19 | - id: go-unit-tests 20 | -------------------------------------------------------------------------------- /ui/.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 | .pnpm-debug.log* 27 | 28 | # local env files 29 | .env*.local 30 | 31 | # vercel 32 | .vercel 33 | 34 | # typescript 35 | *.tsbuildinfo 36 | next-env.d.ts 37 | 38 | env/ 39 | sw.js 40 | workbox-*.js 41 | -------------------------------------------------------------------------------- /ui/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": ["dom", "dom.iterable", "esnext"], 5 | "allowJs": true, 6 | "skipLibCheck": true, 7 | "strict": true, 8 | "forceConsistentCasingInFileNames": true, 9 | "noEmit": true, 10 | "esModuleInterop": true, 11 | "module": "esnext", 12 | "moduleResolution": "node", 13 | "resolveJsonModule": true, 14 | "isolatedModules": true, 15 | "jsx": "preserve", 16 | "incremental": true 17 | }, 18 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], 19 | "exclude": ["node_modules"] 20 | } 21 | -------------------------------------------------------------------------------- /ui/next.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('next').NextConfig} */ 2 | 3 | const withPWA = require('next-pwa')({ 4 | dest: "public", 5 | register: true, 6 | skipWaiting: true, 7 | disable: process.env.NODE_ENV === "development", 8 | }) 9 | 10 | module.exports = withPWA({ 11 | trailingSlash: true, 12 | reactStrictMode: true, 13 | publicRuntimeConfig: { 14 | ENV_API_URL: process.env.ENV_API_URL, 15 | }, 16 | images: { 17 | loader: "custom", 18 | domains: ['lh3.googleusercontent.com', 'avatars.githubusercontent.com', 'images.unsplash.com'], 19 | }, 20 | env: { 21 | storePicturesInWEBP: true, 22 | } 23 | }) 24 | -------------------------------------------------------------------------------- /ui/pages/index.tsx: -------------------------------------------------------------------------------- 1 | import type { NextPage } from 'next' 2 | import Link from 'next/link' 3 | import { useRouter } from 'next/router'; 4 | import Login from '../components/landingpage/Login'; 5 | import { useUserContext } from '../contexts/userContext'; 6 | 7 | const Home: NextPage = () => { 8 | 9 | const {user, loading}: any = useUserContext(); 10 | const router = useRouter(); 11 | 12 | if (user) { 13 | router.push('/dashboard'); 14 | } 15 | 16 | return ( 17 |
18 | { 19 | !user && !loading && ( 20 | 21 | ) 22 | } 23 |
24 | ) 25 | } 26 | 27 | export default Home 28 | -------------------------------------------------------------------------------- /pkg/server/pocketbase.go: -------------------------------------------------------------------------------- 1 | package server 2 | 3 | import ( 4 | "github.com/natrongmbh/pocketbase-nextjs-template/pkg/env" 5 | "github.com/natrongmbh/pocketbase-nextjs-template/pkg/migrations" 6 | "github.com/pocketbase/pocketbase" 7 | ) 8 | 9 | // Setup initializes the pocketbase server 10 | func Setup() *pocketbase.PocketBase { 11 | 12 | // initialize pocketbase collections 13 | migrations.InitCollections() 14 | 15 | // initialize pocketbase server 16 | app := pocketbase.NewWithConfig(pocketbase.Config{ 17 | DefaultDataDir: env.POCKETBASE_DATA_DIR, 18 | DefaultEncryptionEnv: env.POCKETBASE_ENCRYPTION_KEY, 19 | }) 20 | 21 | return app 22 | } 23 | -------------------------------------------------------------------------------- /ui/styles/fonts.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: "Gilroy-Regular"; 3 | src: url("/fonts/Gilroy-Regular.ttf") format("truetype"); 4 | } 5 | 6 | @font-face { 7 | font-family: "Gilroy-Medium"; 8 | src: url("/fonts/Gilroy-Medium.ttf") format("truetype"); 9 | } 10 | 11 | @font-face { 12 | font-family: "Gilroy-Light"; 13 | src: url("/fonts/Gilroy-Light.ttf") format("truetype"); 14 | } 15 | 16 | @font-face { 17 | font-family: "Gilroy-Bold"; 18 | src: url("/fonts/Gilroy-Bold.ttf") format("truetype"); 19 | } 20 | 21 | @font-face { 22 | font-family: "Gilroy-Heavy"; 23 | src: url("/fonts/Gilroy-Heavy.ttf") format("truetype"); 24 | } 25 | -------------------------------------------------------------------------------- /pkg/env/env.go: -------------------------------------------------------------------------------- 1 | package env 2 | 3 | import ( 4 | "os" 5 | ) 6 | 7 | var ( 8 | // POCKETBASE_DATA_DIR is the default data directory 9 | POCKETBASE_DATA_DIR string 10 | // POCKETBASE_ENCRYPTION_KEY is the default encryption key 11 | POCKETBASE_ENCRYPTION_KEY string 12 | ) 13 | 14 | // Init initializes the environment variables 15 | func Init() error { 16 | if POCKETBASE_DATA_DIR = os.Getenv("POCKETBASE_DATA_DIR"); POCKETBASE_DATA_DIR == "" { 17 | POCKETBASE_DATA_DIR = "/pb_data" 18 | } 19 | 20 | if POCKETBASE_ENCRYPTION_KEY = os.Getenv("POCKETBASE_ENCRYPTION_KEY"); POCKETBASE_ENCRYPTION_KEY == "" { 21 | POCKETBASE_ENCRYPTION_KEY = "POCKETBASE_ENCRYPTION_KEY" 22 | } 23 | 24 | return nil 25 | } 26 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /ui/config/Api.ts: -------------------------------------------------------------------------------- 1 | import Axios from 'axios'; 2 | import Cookies from 'js-cookie'; 3 | import getConfig from 'next/config'; 4 | 5 | const { publicRuntimeConfig: config } = getConfig(); 6 | 7 | let urls = { 8 | test: 'http://localhost:8090/api', // test on kubernetes kind cluster locally 9 | development: 'http://localhost:8090/api', // local development 10 | production: config.ENV_API_URL, // production 11 | } 12 | 13 | let Api = Axios.create({ 14 | baseURL: urls[process.env.NODE_ENV], 15 | headers: { 16 | 'Accept': 'application/json', 17 | 'Content-Type': 'application/json' 18 | } 19 | }); 20 | 21 | const token = Cookies.get('token'); 22 | if(token) { 23 | Api.defaults.headers.common['Authorization'] = `Bearer ${token}`; 24 | } 25 | 26 | export default Api; 27 | -------------------------------------------------------------------------------- /ui/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # no verbose 3 | set +x 4 | # config 5 | envFilename='.env.production' 6 | nextFolder='./.next/' 7 | function apply_path { 8 | 9 | env | grep ENV_ | while read -r line; do 10 | # split the variable into name and value 11 | configName=$(echo $line | cut -d'=' -f1) 12 | configValue=$(echo $line | cut -d'=' -f2) 13 | 14 | envValue=$(env | grep "^$configName=" | grep -oe '[^=]*$') 15 | # if config found 16 | if [ -n "$configValue" ] && [ -n "$envValue" ]; then 17 | # replace all 18 | echo "Replace: ${configValue} with: ${envValue}" 19 | find $nextFolder \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i "s#$configValue#$envValue#g" 20 | fi 21 | done <$envFilename 22 | } 23 | apply_path 24 | echo "Starting Nextjs" 25 | exec "$@" 26 | -------------------------------------------------------------------------------- /ui/styles/globals.css: -------------------------------------------------------------------------------- 1 | @import 'tailwindcss/base'; 2 | @import 'tailwindcss/components'; 3 | @import 'tailwindcss/utilities'; 4 | 5 | html { 6 | margin: 0; 7 | padding: 0; 8 | overflow: hidden; 9 | transition: all 0.2s ease-in-out; 10 | } 11 | 12 | body { 13 | position: absolute; 14 | width: 100%; 15 | height: 100%; 16 | overflow: auto; 17 | color: #1A1A1A; 18 | background-color: #FFFFFF; 19 | } 20 | 21 | * { 22 | -webkit-tap-highlight-color: rgba(0, 0, 0, 0); 23 | } 24 | 25 | .outlined-text { 26 | text-shadow: -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff, 1px 1px 0 #fff; 27 | } 28 | 29 | .inlined-text { 30 | text-shadow: none; 31 | } 32 | 33 | strong { 34 | font-family: Gilroy-Bold; 35 | } 36 | 37 | input:checked~.dot { 38 | transform: translateX(100%); 39 | } 40 | 41 | input:checked~ { 42 | background-color: green; 43 | } 44 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /ui/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "theme_color": "#FFFFFF", 3 | "background_color": "#FFFFFF", 4 | "display": "standalone", 5 | "orientation": "portrait", 6 | "scope": "", 7 | "start_url": "/", 8 | "name": "pocketbase-nextjs-template", 9 | "short_name": "pocketbase-nextjs-template", 10 | "description": "A Next.js template for Pocketbase", 11 | "icons": [ 12 | { 13 | "src": "images/manifest/icon-192x192.png", 14 | "sizes": "192x192", 15 | "type": "image/png", 16 | "purpose": "any maskable" 17 | }, 18 | { 19 | "src": "images/manifest/icon-256x256.png", 20 | "sizes": "256x256", 21 | "type": "image/png" 22 | }, 23 | { 24 | "src": "images/manifest/icon-384x384.png", 25 | "sizes": "384x384", 26 | "type": "image/png" 27 | }, 28 | { 29 | "src": "images/manifest/icon-512x512.png", 30 | "sizes": "512x512", 31 | "type": "image/png" 32 | } 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /ui/public/vercel.svg: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /scripts/getting-started.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # This script will look for any folder and file with the name "pocketbase-nextjs-template" and replace it with the name of your project 4 | 5 | # get the name of the project 6 | echo "What is the name of your project?" 7 | read -r project_name 8 | 9 | 10 | # Find every folder with the name "pocketbase-nextjs-template" and replace it with the name of your project 11 | find . -type d -name "pocketbase-nextjs-template" -exec sh -c 'mv "$1" "${1/pocketbase-nextjs-template/$2}"' _ {} $project_name \; 12 | 13 | # go throug every file content and replace "pocketbase-nextjs-template" with the name of your project 14 | grep -rl pocketbase-nextjs-template . | xargs sed -i '' "s/pocketbase-nextjs-template/$project_name/g" 15 | 16 | echo "Done!" 17 | 18 | echo "=============================" 19 | echo "Next steps:" 20 | echo "1. direct to your project root folder" 21 | echo "2. docker-compose up -d --build" 22 | echo "3. change/expand the readme.md file" 23 | echo "4. change the name in the manifest.json and _app.tsx file" 24 | echo "=============================" 25 | -------------------------------------------------------------------------------- /cmd/README.md: -------------------------------------------------------------------------------- 1 | # `/cmd` 2 | 3 | Main applications for this project. 4 | 5 | The directory name for each application should match the name of the executable you want to have (e.g., `/cmd/myapp`). 6 | 7 | Don't put a lot of code in the application directory. If you think the code can be imported and used in other projects, then it should live in the `/pkg` directory. If the code is not reusable or if you don't want others to reuse it, put that code in the `/internal` directory. You'll be surprised what others will do, so be explicit about your intentions! 8 | 9 | It's common to have a small `main` function that imports and invokes the code from the `/internal` and `/pkg` directories and nothing else. 10 | 11 | Examples: 12 | 13 | * https://github.com/heptio/ark/tree/master/cmd (just a really small `main` function with everything else in packages) 14 | * https://github.com/moby/moby/tree/master/cmd 15 | * https://github.com/prometheus/prometheus/tree/master/cmd 16 | * https://github.com/influxdata/influxdb/tree/master/cmd 17 | * https://github.com/kubernetes/kubernetes/tree/master/cmd 18 | * https://github.com/dapr/dapr/tree/master/cmd 19 | * https://github.com/ethereum/go-ethereum/tree/master/cmd 20 | -------------------------------------------------------------------------------- /test/util/random_test.go: -------------------------------------------------------------------------------- 1 | package util_test 2 | 3 | import ( 4 | "testing" 5 | 6 | "github.com/natrongmbh/pocketbase-nextjs-template/pkg/util" 7 | ) 8 | 9 | func TestRandomStringBytes(t *testing.T) { 10 | valid_tests := []struct { 11 | description string 12 | input int 13 | }{ 14 | { 15 | description: "Test with input 30", 16 | input: 30, 17 | }, 18 | { 19 | description: "Test with non integer input", 20 | input: 10, 21 | }, 22 | } 23 | 24 | var results []string 25 | 26 | for _, test := range valid_tests { 27 | t.Run(test.description, func(t *testing.T) { 28 | // check if output length is equal to input 29 | randomString := util.RandomStringBytes(test.input) 30 | if len(randomString) != test.input { 31 | t.Errorf("Expected length of random string to be %d, got %d", test.input, len(randomString)) 32 | } 33 | 34 | results = append(results, randomString) 35 | }) 36 | } 37 | 38 | // check if all results are unique 39 | for i := 0; i < len(results); i++ { 40 | for j := i + 1; j < len(results); j++ { 41 | if results[i] == results[j] { 42 | t.Errorf("Expected all results to be unique, got %s and %s", results[i], results[j]) 43 | } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ui/components/Layout.tsx: -------------------------------------------------------------------------------- 1 | import React from "react"; 2 | import { useUserContext } from "../contexts/userContext"; 3 | import { classNames } from "../lib/design"; 4 | import Footer from "./Footer"; 5 | import Loading from "./Loading"; 6 | import Navigation from "./Navigation"; 7 | 8 | export default function Layout(props: any) { 9 | 10 | const { user, loading }: any = useUserContext(); 11 | 12 | return ( 13 |
14 | { 15 | user && !loading ? ( 16 | 17 | ) : null 18 | } 19 | 20 |
27 | {React.cloneElement(props.children)} 28 |
29 | 30 | { 31 | user && !loading ? ( 32 |
40 | ) 41 | } 42 | -------------------------------------------------------------------------------- /ui/components/general/forms/Toggle.tsx: -------------------------------------------------------------------------------- 1 | import { classNames } from "../../../lib/design"; 2 | 3 | export interface ToggleProps { 4 | name: string; 5 | label: string; 6 | onChange: (value: boolean) => void; 7 | value: boolean; 8 | } 9 | 10 | const Toggle = (props: ToggleProps) => { 11 | 12 | return ( 13 |
14 | 15 | 31 |
32 | ) 33 | 34 | } 35 | 36 | export default Toggle; 37 | -------------------------------------------------------------------------------- /internal/README.md: -------------------------------------------------------------------------------- 1 | # `/internal` 2 | 3 | Private application and library code. This is the code you don't want others importing in their applications or libraries. Note that this layout pattern is enforced by the Go compiler itself. See the Go 1.4 [`release notes`](https://golang.org/doc/go1.4#internalpackages) for more details. Note that you are not limited to the top level `internal` directory. You can have more than one `internal` directory at any level of your project tree. 4 | 5 | You can optionally add a bit of extra structure to your internal packages to separate your shared and non-shared internal code. It's not required (especially for smaller projects), but it's nice to have visual clues showing the intended package use. Your actual application code can go in the `/internal/app` directory (e.g., `/internal/app/myapp`) and the code shared by those apps in the `/internal/pkg` directory (e.g., `/internal/pkg/myprivlib`). 6 | 7 | Examples: 8 | 9 | * https://github.com/hashicorp/terraform/tree/master/internal 10 | * https://github.com/influxdata/influxdb/tree/master/internal 11 | * https://github.com/perkeep/perkeep/tree/master/internal 12 | * https://github.com/jaegertracing/jaeger/tree/master/internal 13 | * https://github.com/moby/moby/tree/master/internal 14 | * https://github.com/satellity/satellity/tree/master/internal 15 | 16 | ## `/internal/pkg` 17 | 18 | Examples: 19 | 20 | * https://github.com/hashicorp/waypoint/tree/main/internal/pkg 21 | -------------------------------------------------------------------------------- /ui/lib/Icons.tsx: -------------------------------------------------------------------------------- 1 | export function GithubIcon(props: React.ComponentProps<'svg'>): JSX.Element { 2 | return ( 3 | 4 | 5 | 6 | ) 7 | } 8 | 9 | export function GoogleIcon(props: React.ComponentProps<'svg'>): JSX.Element { 10 | return ( 11 | 12 | 13 | 14 | ) 15 | } 16 | -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: 3 | push: 4 | branches: [ main ] 5 | pull_request: 6 | # The branches below must be a subset of the branches above 7 | branches: [ main ] 8 | 9 | jobs: 10 | 11 | go-build: 12 | name: Backend Build 13 | runs-on: ubuntu-latest 14 | strategy: 15 | matrix: 16 | goVer: [1.19] 17 | 18 | steps: 19 | - name: Set up Go ${{ matrix.goVer }} 20 | uses: actions/setup-go@v1 21 | with: 22 | go-version: ${{ matrix.goVer }} 23 | id: go 24 | 25 | - name: Check out code into the Go module directory 26 | uses: actions/checkout@v2 27 | 28 | - name: Get dependencies 29 | run: | 30 | go get -v -t -d ./... 31 | go get gopkg.in/check.v1 32 | 33 | - name: Test 34 | run: go test -v ./... 35 | 36 | - name: Build 37 | run: | 38 | go build -v ./cmd/pocketbase-nextjs-template 39 | 40 | ui-build: 41 | name: Frontend Build 42 | runs-on: ubuntu-latest 43 | steps: 44 | - uses: actions/setup-node@v1 45 | with: 46 | node-version: 16 47 | - name: install yarn 48 | run: | 49 | npm install -g yarn 50 | - uses: actions/checkout@v1 51 | - name: yarn install 52 | run: | 53 | cd ./ui 54 | yarn install 55 | - name: build 56 | run: | 57 | cd ./ui 58 | echo "ENV_API_URL=${{ secrets.ENV_API_URL }}" >> .env.production 59 | yarn build 60 | -------------------------------------------------------------------------------- /test/env/env_test.go: -------------------------------------------------------------------------------- 1 | package env_test 2 | 3 | import ( 4 | "os" 5 | "testing" 6 | 7 | "github.com/natrongmbh/pocketbase-nextjs-template/pkg/env" 8 | ) 9 | 10 | func TestInit(t *testing.T) { 11 | 12 | tests := []struct { 13 | description string 14 | env map[string]string 15 | }{ 16 | { 17 | description: "Test with valid env", 18 | env: map[string]string{ 19 | "POCKETBASE_DATA_DIR": "/tmp/pb_data", 20 | "POCKETBASE_ENCRYPTION_KEY": "POCKETBASE_ENCRYPTION_KEY", 21 | }, 22 | }, 23 | { 24 | description: "Test with invalid env", 25 | env: map[string]string{ 26 | "POCKETBASE_DATA_DIR": "", 27 | "POCKETBASE_ENCRYPTION_KEY": "", 28 | }, 29 | }, 30 | } 31 | 32 | for _, test := range tests { 33 | t.Run(test.description, func(t *testing.T) { 34 | // set env 35 | for key, value := range test.env { 36 | os.Setenv(key, value) 37 | } 38 | 39 | // run test 40 | err := env.Init() 41 | if err != nil { 42 | t.Errorf("Expected no error, got %s", err) 43 | } 44 | 45 | // check if envs are set correctly 46 | if env.POCKETBASE_DATA_DIR != test.env["POCKETBASE_DATA_DIR"] && env.POCKETBASE_DATA_DIR != "/pb_data" { 47 | t.Errorf("Expected POCKETBASE_DATA_DIR to be %s, got %s", test.env["POCKETBASE_DATA_DIR"], env.POCKETBASE_DATA_DIR) 48 | } 49 | 50 | if env.POCKETBASE_ENCRYPTION_KEY != test.env["POCKETBASE_ENCRYPTION_KEY"] && env.POCKETBASE_ENCRYPTION_KEY != "POCKETBASE_ENCRYPTION_KEY" { 51 | t.Errorf("Expected POCKETBASE_ENCRYPTION_KEY to be %s, got %s", test.env["POCKETBASE_ENCRYPTION_KEY"], env.POCKETBASE_ENCRYPTION_KEY) 52 | } 53 | }) 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /ui/tailwind.config.js: -------------------------------------------------------------------------------- 1 | const { url } = require('inspector') 2 | const defaultTheme = require('tailwindcss/defaultTheme') 3 | 4 | module.exports = { 5 | content: [ 6 | "./node_modules/flowbite-react/**/*.js", 7 | "./pages/**/*.{js,ts,jsx,tsx}", 8 | "./components/**/*.{js,ts,jsx,tsx}", 9 | ], 10 | theme: { 11 | extend: { 12 | fontFamily: { 13 | 'sans': ['Gilroy-Regular', ...defaultTheme.fontFamily.sans], 14 | GilroyRegular: ['Gilroy-Regular'], 15 | GilroyMedium: ['Gilroy-Medium'], 16 | GilroyLight: ['Gilroy-Light'], 17 | GilroyHeavy: ['Gilroy-Heavy'], 18 | GilroyBold: ['Gilroy-Bold'], 19 | }, 20 | animation: { 21 | wiggle: 'wiggle 1s ease-in-out infinite', 22 | }, 23 | keyframes: { 24 | wiggle: { 25 | '0%, 100%': { transform: 'rotate(-1deg)' }, 26 | '50%': { transform: 'rotate(1deg)' }, 27 | } 28 | }, 29 | colors: { 30 | transparent: "transparent", 31 | 'black': '#1A1A1A', 32 | 'white': '#FFFFFF', 33 | 'primary': '#4285F4', 34 | 'primary-dark': '#3164B5', 35 | 'secondary': '#F59B5B', 36 | 'secondary-dark': '#B57343' 37 | }, 38 | fontSize: { 39 | '4b5': ['2.9rem', '1'], 40 | 'xxl': ['9rem', '1'], 41 | 'xxxl': ['16rem', '1.2'], 42 | }, 43 | height: { 44 | '128': '32rem', 45 | } 46 | }, 47 | }, 48 | plugins: [ 49 | require('@tailwindcss/forms'), 50 | require('tailwind-scrollbar-hide'), 51 | require("flowbite/plugin") 52 | ], 53 | corePlugins: { 54 | fontFamily: true, 55 | }, 56 | } 57 | -------------------------------------------------------------------------------- /ui/Dockerfile: -------------------------------------------------------------------------------- 1 | # Install dependencies only when needed 2 | FROM node:alpine AS deps 3 | # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. 4 | RUN apk add --no-cache libc6-compat 5 | WORKDIR /app 6 | COPY package.json ./ 7 | RUN yarn install --frozen-lockfile 8 | # Rebuild the source code only when needed 9 | FROM node:alpine AS builder 10 | WORKDIR /app 11 | COPY . . 12 | COPY --from=deps /app/node_modules ./node_modules 13 | RUN yarn build && yarn install --production --ignore-scripts --prefer-offline 14 | # Production image, copy all the files and run next 15 | FROM node:alpine AS runner 16 | WORKDIR /app 17 | ENV NODE_ENV production 18 | # RUN addgroup -g 1001 -S nodejs 19 | # RUN adduser -S nextjs -u 1001 20 | # You only need to copy next.config.js if you are NOT using the default configuration 21 | #COPY --from=builder /app/next.config.js ./ 22 | COPY --from=builder /app/public ./public 23 | COPY --from=builder /app/.next ./.next 24 | COPY --from=builder /app/node_modules ./node_modules 25 | COPY --from=builder /app/package.json ./package.json 26 | COPY entrypoint.sh . 27 | COPY .env.production . 28 | # Execute script 29 | RUN apk add --no-cache --upgrade bash 30 | RUN ["chmod", "+x", "./entrypoint.sh"] 31 | ENTRYPOINT ["./entrypoint.sh"] 32 | # USER nextjs 33 | EXPOSE 3000 34 | ENV PORT 3000 35 | # Next.js collects completely anonymous telemetry data about general usage. 36 | # Learn more here: https://nextjs.org/telemetry 37 | # Uncomment the following line in case you want to disable telemetry. 38 | ENV NEXT_TELEMETRY_DISABLED 1 39 | CMD ["node_modules/.bin/next", "start"] 40 | -------------------------------------------------------------------------------- /ui/components/general/forms/InputField.tsx: -------------------------------------------------------------------------------- 1 | import { SVGProps } from "react"; 2 | import { classNames } from "../../../lib/design"; 3 | 4 | export interface InputFieldProps { 5 | label: string; 6 | name: string; 7 | placeholder?: string; 8 | icon?: (props: SVGProps) => JSX.Element; 9 | onChange?: any; 10 | required: boolean; 11 | type: string; 12 | value?: string; 13 | disabled?: boolean; 14 | } 15 | 16 | const InputField = (props: InputFieldProps) => { 17 | return ( 18 |
22 | 32 | 33 |
34 | ) 35 | } 36 | 37 | export default InputField; 38 | -------------------------------------------------------------------------------- /ui/components/Loading.tsx: -------------------------------------------------------------------------------- 1 | const Loading = () => { 2 | 3 | 4 | return ( 5 |
6 |
7 |
8 | 12 | Loading... 13 |
14 |
15 |
16 |
17 | ) 18 | } 19 | 20 | export default Loading; 21 | -------------------------------------------------------------------------------- /scripts/bump-version.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # get arguments 4 | if [ $# -eq 0 ]; then 5 | echo "No arguments supplied" 6 | echo "Usage: bump-version.sh " 7 | exit 1 8 | fi 9 | 10 | old_version="v0.0.0" 11 | version="v0.0.0" 12 | # get the git tag in the format of v1.0.0 if it exists 13 | git_tag=$(git describe --tags --abbrev=0 2>/dev/null) 14 | 15 | replace_version() { 16 | if [ -n "$git_tag" ]; then 17 | version=$(echo $git_tag | sed 's/^v//') 18 | old_version=$version 19 | fi 20 | 21 | if [ "$1" == "major" ]; then 22 | # bump major version to vx+1.x.x 23 | version=$(echo $version | awk -F. '{$1=$1+1; $2=0; $3=0; OFS="."; printf "v%s.%s.%s", $1,$2,$3}') 24 | elif [ "$1" == "minor" ]; then 25 | # bump minor version to vx.x+1.x 26 | version=$(echo $version | awk -F. '{$2=$2+1; $3=0; OFS="."; printf "v%s.%s.%s", $1,$2,$3}') 27 | elif [ "$1" == "patch" ]; then 28 | # bump patch version to vx.x.x+1 29 | version=$(echo $version | awk -F. '{$3=$3+1; OFS="."; printf "%s.%s.%s", $1,$2,$3}') 30 | fi 31 | } 32 | 33 | # if the git tag exists then bump the version by argument (major, minor, patch) 34 | replace_version $1 35 | 36 | # color red 37 | RED='\033[0;31m' 38 | echo "${RED}Bumping version from $old_version to $version" 39 | WHITE='\033[0m' 40 | echo "${WHITE}" 41 | echo "=============================" 42 | echo "Accept the changes? (y/n)" 43 | read -r answer 44 | 45 | if [ "$accept" == "y" ]; then 46 | # replace VERSION?=0.0.0 in ../Makefile 47 | sed -i '' "s/VERSION?=$old_version/VERSION?=$version/g" ../Makefile 48 | 49 | 50 | # replace version in package.json 51 | sed -i '' "s/\"version\": \"$old_version\"/\"version\": \"$version\"/g" ../web/app/package.json 52 | 53 | # replace in go.mod 54 | sed -i '' "s/version $old_version/version $version/g" ../go.mod 55 | 56 | else 57 | echo "Aborted" 58 | exit 1 59 | fi 60 | 61 | # function to replace the version in the file with the new version 62 | -------------------------------------------------------------------------------- /ui/components/alerts/Toast.tsx: -------------------------------------------------------------------------------- 1 | import { toast } from "react-toastify"; 2 | import 'react-toastify/dist/ReactToastify.css'; 3 | 4 | export enum ToastType { 5 | success = "success", 6 | error = "error", 7 | info = "info", 8 | warning = "warning" 9 | } 10 | 11 | export const Toast = (message: string, type: ToastType) => { 12 | switch (type) { 13 | case ToastType.success: 14 | toast.success(message, { 15 | position: "top-right", 16 | autoClose: 2000, 17 | hideProgressBar: false, 18 | closeOnClick: true, 19 | pauseOnHover: true, 20 | draggable: true, 21 | progress: undefined, 22 | theme: "colored" 23 | }); 24 | break; 25 | 26 | case ToastType.error: 27 | toast.error(message, { 28 | position: "top-right", 29 | autoClose: 2000, 30 | hideProgressBar: false, 31 | closeOnClick: true, 32 | pauseOnHover: true, 33 | draggable: true, 34 | progress: undefined, 35 | theme: "colored" 36 | }); 37 | break; 38 | 39 | case ToastType.info: 40 | toast.info(message, { 41 | position: "top-right", 42 | autoClose: 2000, 43 | hideProgressBar: false, 44 | closeOnClick: true, 45 | pauseOnHover: true, 46 | draggable: true, 47 | progress: undefined, 48 | theme: "colored" 49 | }); 50 | break; 51 | 52 | case ToastType.warning: 53 | toast.warning(message, { 54 | position: "top-right", 55 | autoClose: 2000, 56 | hideProgressBar: false, 57 | closeOnClick: true, 58 | pauseOnHover: true, 59 | draggable: true, 60 | progress: undefined, 61 | theme: "colored" 62 | }); 63 | break; 64 | 65 | default: 66 | toast(message, { 67 | position: "top-right", 68 | autoClose: 2000, 69 | hideProgressBar: false, 70 | closeOnClick: true, 71 | pauseOnHover: true, 72 | draggable: true, 73 | progress: undefined, 74 | theme: "colored" 75 | }); 76 | break; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /ui/pages/_app.tsx: -------------------------------------------------------------------------------- 1 | import '../styles/globals.css' 2 | import '../styles/fonts.css' 3 | import '@tremor/react/dist/esm/tremor.css'; 4 | import type { AppProps } from 'next/app' 5 | import Layout from '../components/Layout' 6 | import { UserContextProvider } from '../contexts/userContext' 7 | import Head from 'next/head' 8 | import { useEffect } from 'react' 9 | import { ToastContainer } from 'react-toastify'; 10 | 11 | function MyApp({ Component, pageProps }: AppProps) { 12 | 13 | if (typeof window !== 'undefined') { 14 | window.addEventListener('touchend', _ => { 15 | window.scrollTo(0, 0) 16 | }); 17 | } 18 | 19 | useEffect(() => { 20 | if ("serviceWorker" in navigator && typeof window !== 'undefined') { 21 | window.addEventListener("load", function () { 22 | navigator.serviceWorker.register("/sw.js").then( 23 | function (registration) { 24 | console.log("Service Worker registration successful with scope: ", registration.scope); 25 | }, 26 | function (err) { 27 | console.log("Service Worker registration failed: ", err); 28 | } 29 | ); 30 | }); 31 | } 32 | }, []) 33 | 34 | return ( 35 |
36 | 37 | Pocketbase Next.js Template 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 |
53 | ) 54 | } 55 | 56 | export default MyApp 57 | -------------------------------------------------------------------------------- /ui/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "app", 3 | "version": "v0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "dev": "react-env -- next", 7 | "build": "next build && next export", 8 | "start": "react-env -- next start", 9 | "lint": "eslint './**/*.{ts,tsx}'", 10 | "image": "next-image-export-optimizer" 11 | }, 12 | "husky": { 13 | "pre-commit": "lint-staged" 14 | }, 15 | "lint-staged": { 16 | "./**/*.{js,jsx,ts,tsx,json,css,scss,md}": [ 17 | "prettier --write", 18 | "yarn lint", 19 | "git add" 20 | ] 21 | }, 22 | "dependencies": { 23 | "@beam-australia/react-env": "^3.1.1", 24 | "@headlessui/react": "^1.7.2", 25 | "@heroicons/react": "^2.0.11", 26 | "@tailwindcss/forms": "^0.5.2", 27 | "@tremor/react": "^1.1.1", 28 | "axios": "^1.6.0", 29 | "chart.js": "^3.9.1", 30 | "cross-fetch": "^3.1.5", 31 | "flowbite": "^1.5.3", 32 | "flowbite-react": "^0.1.11", 33 | "hamburger-react": "^2.5.0", 34 | "js-cookie": "^3.0.1", 35 | "next": "12.3.0", 36 | "next-pwa": "^5.6.0", 37 | "pocketbase": "^0.7.1", 38 | "react": "18.2.0", 39 | "react-chartjs-2": "^4.3.1", 40 | "react-dom": "18.2.0", 41 | "react-loading-skeleton": "3.1.0", 42 | "react-parallax-tilt": "^1.7.43", 43 | "react-spinners": "^0.13.4", 44 | "react-toastify": "^9.0.8", 45 | "rehype-stringify": "^9.0.3", 46 | "remark": "^14.0.2", 47 | "remark-html": "^15.0.1", 48 | "remark-parse": "^10.0.1", 49 | "remark-preset-lint-markdown-style-guide": "^5.1.2", 50 | "remark-react": "^9.0.1", 51 | "remark-rehype": "^10.1.0", 52 | "remixicon-react": "^1.0.0", 53 | "sweetalert2": "^11.4.23", 54 | "tailwind-scrollbar-hide": "^1.1.7", 55 | "unified": "^10.1.2", 56 | "vfile-reporter": "^7.0.4" 57 | }, 58 | "devDependencies": { 59 | "@faker-js/faker": "^7.5.0", 60 | "@types/js-cookie": "^3.0.2", 61 | "@types/node": "18.0.0", 62 | "@types/react": "18.0.14", 63 | "@types/react-anchor-link-smooth-scroll": "^1.0.2", 64 | "@types/react-dom": "18.0.5", 65 | "autoprefixer": "^10.4.7", 66 | "eslint": "8.17.0", 67 | "eslint-config-next": "12.1.6", 68 | "husky": "^8.0.1", 69 | "lint-staged": "^13.0.3", 70 | "postcss": "^8.4.14", 71 | "postcss-100vh-fix": "^1.0.2", 72 | "prettier": "^2.7.1", 73 | "tailwindcss": "^3.1.6", 74 | "typescript": "4.7.3" 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /ui/components/general/buttons/StyledButton.tsx: -------------------------------------------------------------------------------- 1 | import { SVGProps } from "react"; 2 | import { classNames } from "../../../lib/design"; 3 | 4 | export interface StyledButtonProps { 5 | name: string; 6 | icon?: (props: SVGProps) => JSX.Element; 7 | iconAnimation?: boolean; 8 | type?: StyledButtonType; 9 | onClick: () => void; 10 | className?: string; 11 | small?: boolean | undefined; 12 | } 13 | 14 | export enum StyledButtonType { 15 | Primary = 'primary', 16 | Secondary = 'secondary', 17 | Danger = 'danger' 18 | } 19 | 20 | const StyledButton = (props: StyledButtonProps) => { 21 | 22 | const hoverAnimationClasses = classNames( 23 | props.type === StyledButtonType.Primary ? "active:hover:bg-gray-800 sm:hover:bg-gray-800" : "", 24 | props.type === StyledButtonType.Secondary ? "active:hover:bg-gray-100 sm:hover:bg-gray-100" : "", 25 | props.type === StyledButtonType.Danger ? "active:hover:bg-red-700 sm:hover:bg-red-700" : "", 26 | "transition-all duration-150 ease-in-out" 27 | ) 28 | const defaultStyleClasses = classNames( 29 | props.type === StyledButtonType.Primary ? "bg-black text-white" : "", 30 | props.type === StyledButtonType.Secondary ? "border-2 border-black text-gray-700" : "", 31 | props.type === StyledButtonType.Danger ? "bg-red-600 text-white" : "", 32 | props.small ? "h-9 text-xs py-2" : "h-14 py-4 text-sm px-11", 33 | "rounded-sm w-full overflow-hidden group font-GilroyMedium my-2", 34 | ) 35 | 36 | return ( 37 | 57 | ) 58 | 59 | } 60 | 61 | export default StyledButton 62 | -------------------------------------------------------------------------------- /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | # This workflow uses actions that are not certified by GitHub. 2 | # They are provided by a third-party and are governed by 3 | # separate terms of service, privacy policy, and support 4 | # documentation. 5 | 6 | name: Docker Image Build & Push 7 | 8 | on: 9 | release: 10 | types: [created] 11 | 12 | env: 13 | REGISTRY: ghcr.io 14 | IMAGE_NAME: ${{ github.repository }} 15 | 16 | jobs: 17 | 18 | ui: 19 | runs-on: ubuntu-latest 20 | permissions: 21 | contents: read 22 | packages: write 23 | 24 | steps: 25 | - name: Checkout repository 26 | uses: actions/checkout@v2 27 | 28 | - name: Log in to the Container registry 29 | uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 30 | with: 31 | registry: ${{ env.REGISTRY }} 32 | username: ${{ github.actor }} 33 | password: ${{ secrets.GITHUB_TOKEN }} 34 | 35 | - name: Extract metadata (tags, labels) for Docker 36 | id: meta 37 | uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 38 | with: 39 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-ui 40 | 41 | - name: Build and push Docker image 42 | uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc 43 | with: 44 | context: ./ui 45 | file: ./ui/Dockerfile 46 | push: true 47 | tags: ${{ steps.meta.outputs.tags }} 48 | labels: ${{ steps.meta.outputs.labels }} 49 | 50 | pocketbase: 51 | runs-on: ubuntu-latest 52 | permissions: 53 | contents: read 54 | packages: write 55 | 56 | steps: 57 | - name: Checkout repository 58 | uses: actions/checkout@v2 59 | 60 | - name: Log in to the Container registry 61 | uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 62 | with: 63 | registry: ${{ env.REGISTRY }} 64 | username: ${{ github.actor }} 65 | password: ${{ secrets.GITHUB_TOKEN }} 66 | 67 | - name: Extract metadata (tags, labels) for Docker 68 | id: meta 69 | uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 70 | with: 71 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-pocketbase 72 | 73 | - name: Build and push Docker image 74 | uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc 75 | with: 76 | context: ./ 77 | file: ./build/package/pocketbase/Dockerfile 78 | push: true 79 | tags: ${{ steps.meta.outputs.tags }} 80 | labels: ${{ steps.meta.outputs.labels }} 81 | -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yaml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ "main" ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ "main" ] 20 | schedule: 21 | - cron: '38 21 * * 0' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: [ 'go', 'typescript' ] 36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] 37 | # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support 38 | 39 | steps: 40 | - name: Checkout repository 41 | uses: actions/checkout@v3 42 | 43 | # Initializes the CodeQL tools for scanning. 44 | - name: Initialize CodeQL 45 | uses: github/codeql-action/init@v2 46 | with: 47 | languages: ${{ matrix.language }} 48 | # If you wish to specify custom queries, you can do so here or in a config file. 49 | # By default, queries listed here will override any specified in a config file. 50 | # Prefix the list here with "+" to use these queries and those in the config file. 51 | 52 | # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs 53 | # queries: security-extended,security-and-quality 54 | 55 | 56 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 57 | # If this step fails, then you should remove it and run the build manually (see below) 58 | - name: Autobuild 59 | uses: github/codeql-action/autobuild@v2 60 | 61 | # ℹ️ Command-line programs to run using the OS shell. 62 | # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun 63 | 64 | # If the Autobuild fails above, remove it and uncomment the following three lines. 65 | # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. 66 | 67 | # - run: | 68 | # echo "Run, Build Application using script" 69 | # ./location_of_script_within_repo/buildscript.sh 70 | 71 | - name: Perform CodeQL Analysis 72 | uses: github/codeql-action/analyze@v2 73 | -------------------------------------------------------------------------------- /pkg/migrations/collections.go: -------------------------------------------------------------------------------- 1 | package migrations 2 | 3 | import ( 4 | "encoding/json" 5 | 6 | "github.com/pocketbase/dbx" 7 | "github.com/pocketbase/pocketbase/daos" 8 | m "github.com/pocketbase/pocketbase/migrations" 9 | "github.com/pocketbase/pocketbase/models" 10 | ) 11 | 12 | // Auto generated migration with the most recent collections configuration. 13 | func InitCollections() { 14 | m.Register(func(db dbx.Builder) error { 15 | jsonData := `[ 16 | { 17 | "id": "systemprofiles0", 18 | "name": "profiles", 19 | "system": true, 20 | "listRule": "userId = @request.user.id", 21 | "viewRule": "userId = @request.user.id", 22 | "createRule": "userId = @request.user.id", 23 | "updateRule": "userId = @request.user.id", 24 | "deleteRule": null, 25 | "schema": [ 26 | { 27 | "id": "pbfielduser", 28 | "name": "userId", 29 | "type": "user", 30 | "system": true, 31 | "required": true, 32 | "unique": true, 33 | "options": { 34 | "maxSelect": 1, 35 | "cascadeDelete": true 36 | } 37 | }, 38 | { 39 | "id": "pbfieldname", 40 | "name": "name", 41 | "type": "text", 42 | "system": false, 43 | "required": false, 44 | "unique": false, 45 | "options": { 46 | "min": null, 47 | "max": null, 48 | "pattern": "" 49 | } 50 | }, 51 | { 52 | "id": "pbfieldavatar", 53 | "name": "avatar", 54 | "type": "file", 55 | "system": false, 56 | "required": false, 57 | "unique": false, 58 | "options": { 59 | "maxSelect": 1, 60 | "maxSize": 5242880, 61 | "mimeTypes": [ 62 | "image/jpg", 63 | "image/jpeg", 64 | "image/png", 65 | "image/svg+xml", 66 | "image/gif" 67 | ], 68 | "thumbs": null 69 | } 70 | } 71 | ] 72 | }, 73 | { 74 | "id": "74o5ynevh4a1vml", 75 | "name": "tests", 76 | "system": false, 77 | "listRule": null, 78 | "viewRule": null, 79 | "createRule": null, 80 | "updateRule": null, 81 | "deleteRule": null, 82 | "schema": [ 83 | { 84 | "id": "9ddpluzl", 85 | "name": "name", 86 | "type": "text", 87 | "system": false, 88 | "required": true, 89 | "unique": false, 90 | "options": { 91 | "min": null, 92 | "max": null, 93 | "pattern": "" 94 | } 95 | }, 96 | { 97 | "id": "qhg888db", 98 | "name": "version", 99 | "type": "number", 100 | "system": false, 101 | "required": true, 102 | "unique": false, 103 | "options": { 104 | "min": null, 105 | "max": null 106 | } 107 | } 108 | ] 109 | } 110 | ]` 111 | 112 | collections := []*models.Collection{} 113 | if err := json.Unmarshal([]byte(jsonData), &collections); err != nil { 114 | return err 115 | } 116 | 117 | return daos.New(db).ImportCollections(collections, true, nil) 118 | }, func(db dbx.Builder) error { 119 | // no revert since the configuration on the environment, on which 120 | // the migration was executed, could have changed via the UI/API 121 | return nil 122 | }) 123 | } 124 | -------------------------------------------------------------------------------- /ui/contexts/userContext.tsx: -------------------------------------------------------------------------------- 1 | import { createContext, ReactNode, useContext, useEffect, useState } from "react"; 2 | import { useRouter } from "next/router"; 3 | import Swal from "sweetalert2"; 4 | import PocketBase, { User } from 'pocketbase'; 5 | import Cookies from 'js-cookie'; 6 | import Api from "../config/Api"; 7 | import { Toast, ToastType } from "../components/alerts/Toast"; 8 | import getConfig from "next/config"; 9 | 10 | const { publicRuntimeConfig: config } = getConfig(); 11 | 12 | export const UserContext = createContext({}); 13 | 14 | export const useUserContext = () => { 15 | return useContext(UserContext); 16 | }; 17 | 18 | type Props = { 19 | children: ReactNode; 20 | }; 21 | 22 | export const UserContextProvider = ({ children }: Props) => { 23 | const [user, setUser] = useState(null); 24 | const [loading, setLoading] = useState(true); 25 | const [componentLoading, setComponentLoading] = useState(false); 26 | const [error, setError] = useState(null); 27 | const [reload, setReload] = useState(false); 28 | const router = useRouter(); 29 | const client = new PocketBase(config.ENV_API_URL || "http://127.0.0.1:8090"); 30 | 31 | useEffect(() => { 32 | async function checkAuth() { 33 | await client.users.refresh() 34 | .then((newAuthData) => { 35 | setUser(newAuthData.user); 36 | }) 37 | .catch((error) => { 38 | throw error; 39 | }) 40 | } 41 | checkAuth() 42 | .catch((error) => { 43 | logout(true) 44 | console.log(error); 45 | }) 46 | .finally(() => { 47 | setLoading(false); 48 | setReload(!reload); 49 | }) 50 | // eslint-disable-next-line react-hooks/exhaustive-deps 51 | }, []); 52 | 53 | const signInWithEmail = async (username: string, password: string) => { 54 | setLoading(true); 55 | 56 | await client.users.authViaEmail(username, password) 57 | .then((data) => { 58 | if (data) { 59 | setUser(data.user); 60 | Toast("Logged In", ToastType.success); 61 | } 62 | }) 63 | .catch((error) => { 64 | console.log(error); 65 | setError(error); 66 | Toast("Login Failed", ToastType.error); 67 | }) 68 | .finally(() => { 69 | setLoading(false); 70 | }) 71 | } 72 | 73 | const logout = (noalert: boolean | null) => { 74 | client.authStore.clear(); 75 | setUser(null); 76 | if (!noalert || noalert === null) { 77 | Toast("Logged out", ToastType.success); 78 | } 79 | router.push("/"); 80 | } 81 | 82 | const contextValue = { 83 | user, 84 | loading, 85 | componentLoading, 86 | error, 87 | reload, 88 | client, 89 | setLoading, 90 | setComponentLoading, 91 | setReload, 92 | signInWithEmail, 93 | logout 94 | }; 95 | 96 | return ( 97 | 98 | {children} 99 | 100 | ) 101 | } 102 | -------------------------------------------------------------------------------- /ui/components/dashboard/Stats.tsx: -------------------------------------------------------------------------------- 1 | /* This example requires Tailwind CSS v2.0+ */ 2 | import { ArrowDownIcon, ArrowUpIcon } from '@heroicons/react/20/solid' 3 | import { CursorArrowRaysIcon, EnvelopeOpenIcon, UsersIcon } from '@heroicons/react/24/outline' 4 | import { classNames } from '../../lib/design' 5 | 6 | const stats = [ 7 | { id: 1, name: 'Total Subscribers', stat: '71,897', icon: UsersIcon, change: '122', changeType: 'increase' }, 8 | { id: 2, name: 'Avg. Open Rate', stat: '58.16%', icon: EnvelopeOpenIcon, change: '5.4%', changeType: 'increase' }, 9 | { id: 3, name: 'Avg. Click Rate', stat: '24.57%', icon: CursorArrowRaysIcon, change: '3.2%', changeType: 'decrease' }, 10 | ] 11 | 12 | const Stats = () => { 13 | return ( 14 |
15 |

Last 30 days

16 | 17 |
18 | {stats.map((item) => ( 19 |
23 |
24 |
25 |
27 |

{item.name}

28 |
29 |
30 |

{item.stat}

31 |

37 | {item.changeType === 'increase' ? ( 38 |

46 | 54 |
55 |
56 | ))} 57 |
58 |
59 | ) 60 | } 61 | 62 | export default Stats; 63 | -------------------------------------------------------------------------------- /ui/pages/dashboard.tsx: -------------------------------------------------------------------------------- 1 | import { NextPage } from "next"; 2 | import { Card, Title, AreaChart, DonutChart, Flex, Text, Bold, BarList } from "@tremor/react"; 3 | import Heading from "../components/general/typo/Heading"; 4 | import Stats from "../components/dashboard/Stats"; 5 | import GithubFillIcon from 'remixicon-react/GithubFillIcon'; 6 | import YoutubeFillIcon from 'remixicon-react/YoutubeFillIcon'; 7 | import GoogleFillIcon from 'remixicon-react/GoogleFillIcon'; 8 | import RedditFillIcon from 'remixicon-react/RedditFillIcon'; 9 | import TwitterFillIcon from 'remixicon-react/TwitterFillIcon'; 10 | 11 | const chartdata = [ 12 | { 13 | date: "Jan 22", 14 | SemiAnalysis: 2890, 15 | "The Pragmatic Engineer": 2338, 16 | }, 17 | { 18 | date: "Feb 22", 19 | SemiAnalysis: 2756, 20 | "The Pragmatic Engineer": 2103, 21 | }, 22 | { 23 | date: "Mar 22", 24 | SemiAnalysis: 3322, 25 | "The Pragmatic Engineer": 2194, 26 | }, 27 | { 28 | date: "Apr 22", 29 | SemiAnalysis: 3470, 30 | "The Pragmatic Engineer": 2108, 31 | }, 32 | { 33 | date: "May 22", 34 | SemiAnalysis: 3475, 35 | "The Pragmatic Engineer": 1812, 36 | }, 37 | { 38 | date: "Jun 22", 39 | SemiAnalysis: 3129, 40 | "The Pragmatic Engineer": 1726, 41 | }, 42 | ]; 43 | 44 | const cities = [ 45 | { 46 | name: 'New York', 47 | sales: 9800, 48 | }, 49 | { 50 | name: 'London', 51 | sales: 4567, 52 | }, 53 | { 54 | name: 'Hong Kong', 55 | sales: 3908, 56 | }, 57 | { 58 | name: 'San Francisco', 59 | sales: 2400, 60 | }, 61 | { 62 | name: 'Singapore', 63 | sales: 1908, 64 | }, 65 | { 66 | name: 'Zurich', 67 | sales: 1398, 68 | }, 69 | ]; 70 | 71 | const data = [ 72 | { name: 'Twitter', value: 456, icon: TwitterFillIcon }, 73 | { name: 'Google', value: 351, icon: GoogleFillIcon}, 74 | { name: 'GitHub', value: 271, icon: GithubFillIcon }, 75 | { name: 'Reddit', value: 191, icon: RedditFillIcon }, 76 | { name: 'Youtube', value: 91, icon: YoutubeFillIcon }, 77 | ]; 78 | 79 | const dataFormatter = (number: number) => { 80 | return "$ " + Intl.NumberFormat("us").format(number).toString(); 81 | }; 82 | 83 | const valueFormatter = (number: number) => ( 84 | `$ ${Intl.NumberFormat('us').format(number).toString()}` 85 | ); 86 | 87 | const Dashboard: NextPage = () => { 88 | return ( 89 |
92 | 93 | Dashboard 94 | 95 | 96 | 99 | Newsletter revenue over time (USD) 100 | 109 | 110 | 111 | Sales by City 112 | 120 | Website Analytics 121 | 122 | Source 123 | Visits 124 | 125 | 126 | 127 |
128 | ) 129 | } 130 | 131 | export default Dashboard; 132 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | GOCMD=go 2 | GOTEST=$(GOCMD) test 3 | GOVET=$(GOCMD) vet 4 | BINARY_NAME=pocketbase-nextjs-template 5 | VERSION?=v1.0.0 6 | SERVICE_PORT?=3000 7 | DOCKER_REGISTRY?=ghcr.io/natrontechgmbh/ #if set it should finished by / 8 | EXPORT_RESULT?=false # for CI please set EXPORT_RESULT to true 9 | 10 | GREEN := $(shell tput -Txterm setaf 2) 11 | YELLOW := $(shell tput -Txterm setaf 3) 12 | WHITE := $(shell tput -Txterm setaf 7) 13 | CYAN := $(shell tput -Txterm setaf 6) 14 | RESET := $(shell tput -Txterm sgr0) 15 | 16 | .PHONY: all test build vendor 17 | 18 | all: help 19 | 20 | ## Build: 21 | build: ## Build your project and put the output binary in out/bin/ 22 | mkdir -p out/bin 23 | GO111MODULE=on $(GOCMD) build -mod vendor -o out/bin/$(BINARY_NAME) . 24 | 25 | clean: ## Remove build related file 26 | rm -fr ./bin 27 | rm -fr ./out 28 | rm -f ./junit-report.xml checkstyle-report.xml ./coverage.xml ./profile.cov yamllint-checkstyle.xml 29 | 30 | vendor: ## Copy of all packages needed to support builds and tests in the vendor directory 31 | $(GOCMD) mod vendor 32 | 33 | watch: ## Run the code with cosmtrek/air to have automatic reload on changes 34 | $(eval PACKAGE_NAME=$(shell head -n 1 go.mod | cut -d ' ' -f2)) 35 | docker run -it --rm -w /go/src/$(PACKAGE_NAME) -v $(shell pwd):/go/src/$(PACKAGE_NAME) -p $(SERVICE_PORT):$(SERVICE_PORT) cosmtrek/air 36 | 37 | ## Test: 38 | test: ## Run the tests of the project 39 | ifeq ($(EXPORT_RESULT), true) 40 | GO111MODULE=off go get -u github.com/jstemmer/go-junit-report 41 | $(eval OUTPUT_OPTIONS = | tee /dev/tty | go-junit-report -set-exit-code > junit-report.xml) 42 | endif 43 | $(GOTEST) -v -race ./... $(OUTPUT_OPTIONS) 44 | 45 | coverage: ## Run the tests of the project and export the coverage 46 | $(GOTEST) -cover -covermode=count -coverprofile=profile.cov ./... 47 | $(GOCMD) tool cover -func profile.cov 48 | ifeq ($(EXPORT_RESULT), true) 49 | GO111MODULE=off go get -u github.com/AlekSi/gocov-xml 50 | GO111MODULE=off go get -u github.com/axw/gocov/gocov 51 | gocov convert profile.cov | gocov-xml > coverage.xml 52 | endif 53 | 54 | ## Lint: 55 | lint: lint-go lint-dockerfile lint-yaml ## Run all available linters 56 | 57 | lint-dockerfile: ## Lint your Dockerfile 58 | # If dockerfile is present we lint it. 59 | ifeq ($(shell test -e ./Dockerfile && echo -n yes),yes) 60 | $(eval CONFIG_OPTION = $(shell [ -e $(shell pwd)/.hadolint.yaml ] && echo "-v $(shell pwd)/.hadolint.yaml:/root/.config/hadolint.yaml" || echo "" )) 61 | $(eval OUTPUT_OPTIONS = $(shell [ "${EXPORT_RESULT}" == "true" ] && echo "--format checkstyle" || echo "" )) 62 | $(eval OUTPUT_FILE = $(shell [ "${EXPORT_RESULT}" == "true" ] && echo "| tee /dev/tty > checkstyle-report.xml" || echo "" )) 63 | docker run --rm -i $(CONFIG_OPTION) hadolint/hadolint hadolint $(OUTPUT_OPTIONS) - < ./Dockerfile $(OUTPUT_FILE) 64 | endif 65 | 66 | lint-go: ## Use golintci-lint on your project 67 | $(eval OUTPUT_OPTIONS = $(shell [ "${EXPORT_RESULT}" == "true" ] && echo "--out-format checkstyle ./... | tee /dev/tty > checkstyle-report.xml" || echo "" )) 68 | docker run --rm -v $(shell pwd):/app -w /app golangci/golangci-lint:latest-alpine golangci-lint run --deadline=65s $(OUTPUT_OPTIONS) 69 | 70 | lint-yaml: ## Use yamllint on the yaml file of your projects 71 | ifeq ($(EXPORT_RESULT), true) 72 | GO111MODULE=off go get -u github.com/thomaspoignant/yamllint-checkstyle 73 | $(eval OUTPUT_OPTIONS = | tee /dev/tty | yamllint-checkstyle > yamllint-checkstyle.xml) 74 | endif 75 | docker run --rm -it -v $(shell pwd):/data cytopia/yamllint -f parsable $(shell git ls-files '*.yml' '*.yaml') $(OUTPUT_OPTIONS) 76 | 77 | ## Docker: 78 | docker-build: ## Use the dockerfile to build the container 79 | docker build -f ./build/package/Dockerfile --rm --tag $(BINARY_NAME) . 80 | 81 | docker-release: ## Release the container with tag latest and version 82 | docker tag $(BINARY_NAME) $(DOCKER_REGISTRY)$(BINARY_NAME):latest 83 | docker tag $(BINARY_NAME) $(DOCKER_REGISTRY)$(BINARY_NAME):$(VERSION) 84 | # Push the docker images 85 | docker push $(DOCKER_REGISTRY)$(BINARY_NAME):latest 86 | docker push $(DOCKER_REGISTRY)$(BINARY_NAME):$(VERSION) 87 | 88 | ## Help: 89 | help: ## Show this help. 90 | @echo '' 91 | @echo 'Usage:' 92 | @echo ' ${YELLOW}make${RESET} ${GREEN}${RESET}' 93 | @echo '' 94 | @echo 'Targets:' 95 | @awk 'BEGIN {FS = ":.*?## "} { \ 96 | if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \ 97 | else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \ 98 | }' $(MAKEFILE_LIST) 99 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/natrongmbh/pocketbase-nextjs-template 2 | 3 | go 1.19 4 | 5 | require ( 6 | github.com/pocketbase/dbx v1.6.0 7 | github.com/pocketbase/pocketbase v0.7.6 8 | ) 9 | 10 | require ( 11 | github.com/AlecAivazis/survey/v2 v2.3.6 // indirect 12 | github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect 13 | github.com/aws/aws-sdk-go v1.44.102 // indirect 14 | github.com/aws/aws-sdk-go-v2 v1.16.16 // indirect 15 | github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.8 // indirect 16 | github.com/aws/aws-sdk-go-v2/config v1.17.7 // indirect 17 | github.com/aws/aws-sdk-go-v2/credentials v1.12.20 // indirect 18 | github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.17 // indirect 19 | github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.33 // indirect 20 | github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.23 // indirect 21 | github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.17 // indirect 22 | github.com/aws/aws-sdk-go-v2/internal/ini v1.3.24 // indirect 23 | github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.14 // indirect 24 | github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.9 // indirect 25 | github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.18 // indirect 26 | github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.17 // indirect 27 | github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.13.17 // indirect 28 | github.com/aws/aws-sdk-go-v2/service/s3 v1.27.11 // indirect 29 | github.com/aws/aws-sdk-go-v2/service/sso v1.11.23 // indirect 30 | github.com/aws/aws-sdk-go-v2/service/ssooidc v1.13.5 // indirect 31 | github.com/aws/aws-sdk-go-v2/service/sts v1.16.19 // indirect 32 | github.com/aws/smithy-go v1.13.3 // indirect 33 | github.com/disintegration/imaging v1.6.2 // indirect 34 | github.com/domodwyer/mailyak/v3 v3.3.4 // indirect 35 | github.com/fatih/color v1.13.0 // indirect 36 | github.com/gabriel-vasile/mimetype v1.4.1 // indirect 37 | github.com/ganigeorgiev/fexpr v0.1.1 // indirect 38 | github.com/go-ozzo/ozzo-validation/v4 v4.3.0 // indirect 39 | github.com/golang-jwt/jwt/v4 v4.4.2 // indirect 40 | github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect 41 | github.com/golang/protobuf v1.5.2 // indirect 42 | github.com/google/uuid v1.3.0 // indirect 43 | github.com/google/wire v0.5.0 // indirect 44 | github.com/googleapis/gax-go/v2 v2.5.1 // indirect 45 | github.com/inconshreveable/mousetrap v1.0.1 // indirect 46 | github.com/jmespath/go-jmespath v0.4.0 // indirect 47 | github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect 48 | github.com/labstack/echo/v5 v5.0.0-20220201181537-ed2888cfa198 // indirect 49 | github.com/mattn/go-colorable v0.1.13 // indirect 50 | github.com/mattn/go-isatty v0.0.16 // indirect 51 | github.com/mattn/go-sqlite3 v1.14.15 // indirect 52 | github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect 53 | github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0 // indirect 54 | github.com/spf13/cast v1.5.0 // indirect 55 | github.com/spf13/cobra v1.5.0 // indirect 56 | github.com/spf13/pflag v1.0.5 // indirect 57 | github.com/valyala/bytebufferpool v1.0.0 // indirect 58 | github.com/valyala/fasttemplate v1.2.1 // indirect 59 | go.opencensus.io v0.23.0 // indirect 60 | gocloud.dev v0.26.0 // indirect 61 | golang.org/x/crypto v0.17.0 // indirect 62 | golang.org/x/image v0.5.0 // indirect 63 | golang.org/x/mod v0.8.0 // indirect 64 | golang.org/x/net v0.10.0 // indirect 65 | golang.org/x/oauth2 v0.4.0 // indirect 66 | golang.org/x/sys v0.15.0 // indirect 67 | golang.org/x/term v0.15.0 // indirect 68 | golang.org/x/text v0.14.0 // indirect 69 | golang.org/x/time v0.0.0-20220920022843-2ce7c2934d45 // indirect 70 | golang.org/x/tools v0.6.0 // indirect 71 | golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect 72 | google.golang.org/api v0.96.0 // indirect 73 | google.golang.org/appengine v1.6.7 // indirect 74 | google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f // indirect 75 | google.golang.org/grpc v1.53.0 // indirect 76 | google.golang.org/protobuf v1.28.1 // indirect 77 | lukechampine.com/uint128 v1.2.0 // indirect 78 | modernc.org/cc/v3 v3.39.0 // indirect 79 | modernc.org/ccgo/v3 v3.16.9 // indirect 80 | modernc.org/libc v1.19.0 // indirect 81 | modernc.org/mathutil v1.5.0 // indirect 82 | modernc.org/memory v1.4.0 // indirect 83 | modernc.org/opt v0.1.3 // indirect 84 | modernc.org/sqlite v1.19.1 // indirect 85 | modernc.org/strutil v1.1.3 // indirect 86 | modernc.org/token v1.0.1 // indirect 87 | ) 88 | -------------------------------------------------------------------------------- /pkg/README.md: -------------------------------------------------------------------------------- 1 | # `/pkg` 2 | 3 | Library code that's ok to use by external applications (e.g., `/pkg/mypubliclib`). Other projects will import these libraries expecting them to work, so think twice before you put something here :-) Note that the `internal` directory is a better way to ensure your private packages are not importable because it's enforced by Go. The `/pkg` directory is still a good way to explicitly communicate that the code in that directory is safe for use by others. The [`I'll take pkg over internal`](https://travisjeffery.com/b/2019/11/i-ll-take-pkg-over-internal/) blog post by Travis Jeffery provides a good overview of the `pkg` and `internal` directories and when it might make sense to use them. 4 | 5 | It's also a way to group Go code in one place when your root directory contains lots of non-Go components and directories making it easier to run various Go tools (as mentioned in these talks: [`Best Practices for Industrial Programming`](https://www.youtube.com/watch?v=PTE4VJIdHPg) from GopherCon EU 2018, [GopherCon 2018: Kat Zien - How Do You Structure Your Go Apps](https://www.youtube.com/watch?v=oL6JBUk6tj0) and [GoLab 2018 - Massimiliano Pippi - Project layout patterns in Go](https://www.youtube.com/watch?v=3gQa1LWwuzk)). 6 | 7 | Note that this is not a universally accepted pattern and for every popular repo that uses it you can find 10 that don't. It's up to you to decide if you want to use this pattern or not. Regardless of whether or not it's a good pattern more people will know what you mean than not. It might a bit confusing for some of the new Go devs, but it's a pretty simple confusion to resolve and that's one of the goals for this project layout repo. 8 | 9 | Ok not to use it if your app project is really small and where an extra level of nesting doesn't add much value (unless you really want to). Think about it when it's getting big enough and your root directory gets pretty busy (especially if you have a lot of non-Go app components). 10 | 11 | The `pkg` directory origins: The old Go source code used to use `pkg` for its packages and then various Go projects in the community started copying the pattern (see [`this`](https://twitter.com/bradfitz/status/1039512487538970624) Brad Fitzpatrick's tweet for more context). 12 | 13 | 14 | Examples: 15 | 16 | * https://github.com/jaegertracing/jaeger/tree/master/pkg 17 | * https://github.com/istio/istio/tree/master/pkg 18 | * https://github.com/GoogleContainerTools/kaniko/tree/master/pkg 19 | * https://github.com/google/gvisor/tree/master/pkg 20 | * https://github.com/google/syzkaller/tree/master/pkg 21 | * https://github.com/perkeep/perkeep/tree/master/pkg 22 | * https://github.com/minio/minio/tree/master/pkg 23 | * https://github.com/heptio/ark/tree/master/pkg 24 | * https://github.com/argoproj/argo/tree/master/pkg 25 | * https://github.com/heptio/sonobuoy/tree/master/pkg 26 | * https://github.com/helm/helm/tree/master/pkg 27 | * https://github.com/kubernetes/kubernetes/tree/master/pkg 28 | * https://github.com/kubernetes/kops/tree/master/pkg 29 | * https://github.com/moby/moby/tree/master/pkg 30 | * https://github.com/grafana/grafana/tree/master/pkg 31 | * https://github.com/influxdata/influxdb/tree/master/pkg 32 | * https://github.com/cockroachdb/cockroach/tree/master/pkg 33 | * https://github.com/derekparker/delve/tree/master/pkg 34 | * https://github.com/etcd-io/etcd/tree/master/pkg 35 | * https://github.com/oklog/oklog/tree/master/pkg 36 | * https://github.com/flynn/flynn/tree/master/pkg 37 | * https://github.com/jesseduffield/lazygit/tree/master/pkg 38 | * https://github.com/gopasspw/gopass/tree/master/pkg 39 | * https://github.com/sosedoff/pgweb/tree/master/pkg 40 | * https://github.com/GoogleContainerTools/skaffold/tree/master/pkg 41 | * https://github.com/knative/serving/tree/master/pkg 42 | * https://github.com/grafana/loki/tree/master/pkg 43 | * https://github.com/bloomberg/goldpinger/tree/master/pkg 44 | * https://github.com/Ne0nd0g/merlin/tree/master/pkg 45 | * https://github.com/jenkins-x/jx/tree/master/pkg 46 | * https://github.com/DataDog/datadog-agent/tree/master/pkg 47 | * https://github.com/dapr/dapr/tree/master/pkg 48 | * https://github.com/cortexproject/cortex/tree/master/pkg 49 | * https://github.com/dexidp/dex/tree/master/pkg 50 | * https://github.com/pusher/oauth2_proxy/tree/master/pkg 51 | * https://github.com/pdfcpu/pdfcpu/tree/master/pkg 52 | * https://github.com/weaveworks/kured/tree/master/pkg 53 | * https://github.com/weaveworks/footloose/tree/master/pkg 54 | * https://github.com/weaveworks/ignite/tree/master/pkg 55 | * https://github.com/tmrts/boilr/tree/master/pkg 56 | * https://github.com/kata-containers/runtime/tree/master/pkg 57 | * https://github.com/okteto/okteto/tree/master/pkg 58 | * https://github.com/solo-io/squash/tree/master/pkg 59 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | 4 | 5 |

6 | PocketBase Next.js Template 7 |

8 |

9 | 10 | 11 | 12 | 13 | 14 | 15 |

16 |

17 | 18 |

19 | 20 | A
21 | Template Repository 22 |
23 | for Next.js apps with a PocketBase backend 24 |
25 |

26 | 27 |

28 | Build 32 | Sponsors 36 | License 40 | CodeFactor 44 |

45 | 46 |

47 | pocketbase-nextjs-template allowes you to create a Next.js app with a PocketBase backend in seconds. :rocket: 48 |

49 | 50 |

51 | 52 | Check out the company behind pocketbase-nextjs-template – 53 | https://natron.io 56 | 57 |

58 | 59 |

60 |

 

61 | 62 | ## Everything you would expect 63 | 64 | ### Getting started 65 | 66 | Search through all files/folders and replace all instances of `pocketbase-nextjs-template` with your project name. 67 | There is a bash script that does this for you: 68 | - [./scripts/getting-started.sh](./scripts/getting-started.sh) 69 | 70 | Just run it and follow the instructions. 71 | To deploy your app, you can containerize it with the included Dockerfile(s) under [./build/package/pocketbase](./build/package/pocketbase) and [./ui](./ui/). 72 | Or simply execute the docker-compose file [docker-compose.yaml](docker-compose.yaml) to run the app locally. 73 | 74 | ### Open Source 75 | 76 | Trust me, I'm open source. 77 | You can find the source code on [Github](https://github.com/natrongmbh/pocketbase-nextjs-template). 78 | The frontend is written in Next.js and the backend in GoLang (Pocketbase). 79 | License: GPL 3 80 | 81 | ### Frontend 82 | 83 | The frontend is written in TypeScript and uses Next.js. 84 | It uses [Tailwind CSS](https://tailwindcss.com/) for styling with [Flowbite React](https://flowbite-react.com) as a design system. 85 | There are also some self-written components in the `components` folder. 86 | These are mostly inspired by the ui of [Pocketbase](https://pocketbase.io). 87 | Just use them as you like. They are similar to the Pocketbase UI Components. 88 | 89 |

90 |

 

91 | 92 | ## Setup 93 | 94 | You can deploy pocketbase-nextjs-template in your Kubernetes cluster, but you have to set all the env variables. 95 | 96 | - [kubernetes-example](/deployments/kubernetes) 97 | 98 | ### Environment Variables 99 | 100 | You need to set the following Environment 101 | 102 | #### Pocketbase 103 | 104 | - `POCKETBASE_DATA_DIR` - The directory where the Pocketbase data is stored. Default: `/pb_data` 105 | - `POCKETBASE_ENCRYPTION_KEY` - The encryption key for the Pocketbase database. Must be 32 characters long. 106 | 107 | #### UI 108 | 109 | - `ENV_API_URL` - The URL of the API, e.g. `https://template.natron.io` (without trailing slash, but /api at the end, must be accessible from the webclient) 110 | 111 | ### Docker 112 | 113 | You can also build and run pocketbase-nextjs-template with Docker. 114 | 115 | ```yaml 116 | version: "3.9" 117 | services: 118 | pocketbase: 119 | build: 120 | context: ./ 121 | dockerfile: ./build/package/pocketbase/Dockerfile 122 | ports: 123 | - "8090:8090" 124 | volumes: 125 | - data:/data 126 | 127 | ui: 128 | build: ./ui 129 | ports: 130 | - "3000:3000" 131 | environment: 132 | - ENV_API_URL=http://template.natron.io:8090 133 | 134 | 135 | volumes: 136 | data: {} 137 | 138 | ``` 139 | 140 | ### Production 141 | 142 | You can deploy pocketbase-nextjs-template in your Kubernetes cluster, but you have to set all the env variables. 143 | For backing up the database, you can consider using [Litestream](https://litestream.io). 144 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | We as members, contributors, and leaders pledge to make participation in our 6 | community a harassment-free experience for everyone, regardless of age, body 7 | size, visible or invisible disability, ethnicity, sex characteristics, gender 8 | identity and expression, level of experience, education, socio-economic status, 9 | nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | We pledge to act and interact in ways that contribute to an open, welcoming, 13 | diverse, inclusive, and healthy community. 14 | 15 | ## Our Standards 16 | 17 | Examples of behavior that contributes to a positive environment for our 18 | community include: 19 | 20 | * Demonstrating empathy and kindness toward other people 21 | * Being respectful of differing opinions, viewpoints, and experiences 22 | * Giving and gracefully accepting constructive feedback 23 | * Accepting responsibility and apologizing to those affected by our mistakes, 24 | and learning from the experience 25 | * Focusing on what is best not just for us as individuals, but for the 26 | overall community 27 | 28 | Examples of unacceptable behavior include: 29 | 30 | * The use of sexualized language or imagery, and sexual attention or 31 | advances of any kind 32 | * Trolling, insulting or derogatory comments, and personal or political attacks 33 | * Public or private harassment 34 | * Publishing others' private information, such as a physical or email 35 | address, without their explicit permission 36 | * Other conduct which could reasonably be considered inappropriate in a 37 | professional setting 38 | 39 | ## Enforcement Responsibilities 40 | 41 | Community leaders are responsible for clarifying and enforcing our standards of 42 | acceptable behavior and will take appropriate and fair corrective action in 43 | response to any behavior that they deem inappropriate, threatening, offensive, 44 | or harmful. 45 | 46 | Community leaders have the right and responsibility to remove, edit, or reject 47 | comments, commits, code, wiki edits, issues, and other contributions that are 48 | not aligned to this Code of Conduct, and will communicate reasons for moderation 49 | decisions when appropriate. 50 | 51 | ## Scope 52 | 53 | This Code of Conduct applies within all community spaces, and also applies when 54 | an individual is officially representing the community in public spaces. 55 | Examples of representing our community include using an official e-mail address, 56 | posting via an official social media account, or acting as an appointed 57 | representative at an online or offline event. 58 | 59 | ## Enforcement 60 | 61 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 62 | reported to the community leaders responsible for enforcement at 63 | info@natron.io. 64 | All complaints will be reviewed and investigated promptly and fairly. 65 | 66 | All community leaders are obligated to respect the privacy and security of the 67 | reporter of any incident. 68 | 69 | ## Enforcement Guidelines 70 | 71 | Community leaders will follow these Community Impact Guidelines in determining 72 | the consequences for any action they deem in violation of this Code of Conduct: 73 | 74 | ### 1. Correction 75 | 76 | **Community Impact**: Use of inappropriate language or other behavior deemed 77 | unprofessional or unwelcome in the community. 78 | 79 | **Consequence**: A private, written warning from community leaders, providing 80 | clarity around the nature of the violation and an explanation of why the 81 | behavior was inappropriate. A public apology may be requested. 82 | 83 | ### 2. Warning 84 | 85 | **Community Impact**: A violation through a single incident or series 86 | of actions. 87 | 88 | **Consequence**: A warning with consequences for continued behavior. No 89 | interaction with the people involved, including unsolicited interaction with 90 | those enforcing the Code of Conduct, for a specified period of time. This 91 | includes avoiding interactions in community spaces as well as external channels 92 | like social media. Violating these terms may lead to a temporary or 93 | permanent ban. 94 | 95 | ### 3. Temporary Ban 96 | 97 | **Community Impact**: A serious violation of community standards, including 98 | sustained inappropriate behavior. 99 | 100 | **Consequence**: A temporary ban from any sort of interaction or public 101 | communication with the community for a specified period of time. No public or 102 | private interaction with the people involved, including unsolicited interaction 103 | with those enforcing the Code of Conduct, is allowed during this period. 104 | Violating these terms may lead to a permanent ban. 105 | 106 | ### 4. Permanent Ban 107 | 108 | **Community Impact**: Demonstrating a pattern of violation of community 109 | standards, including sustained inappropriate behavior, harassment of an 110 | individual, or aggression toward or disparagement of classes of individuals. 111 | 112 | **Consequence**: A permanent ban from any sort of public interaction within 113 | the community. 114 | 115 | ## Attribution 116 | 117 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 118 | version 2.0, available at 119 | https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. 120 | 121 | Community Impact Guidelines were inspired by [Mozilla's code of conduct 122 | enforcement ladder](https://github.com/mozilla/diversity). 123 | 124 | [homepage]: https://www.contributor-covenant.org 125 | 126 | For answers to common questions about this code of conduct, see the FAQ at 127 | https://www.contributor-covenant.org/faq. Translations are available at 128 | https://www.contributor-covenant.org/translations. 129 | -------------------------------------------------------------------------------- /ui/components/landingpage/Login.tsx: -------------------------------------------------------------------------------- 1 | import { ArrowRightIcon, EnvelopeIcon } from "@heroicons/react/24/solid"; 2 | import { useEffect, useState } from "react"; 3 | import { useUserContext } from "../../contexts/userContext"; 4 | import { GithubIcon, GoogleIcon } from "../../lib/Icons"; 5 | import { Toast, ToastType } from "../alerts/Toast"; 6 | import StyledButton, { StyledButtonType } from "../general/buttons/StyledButton"; 7 | import InputField from "../general/forms/InputField"; 8 | import Heading from "../general/typo/Heading"; 9 | import SubHeading from "../general/typo/SubHeading"; 10 | import { classNames } from "../../lib/design"; 11 | import { EnvelopeOpenIcon, LockClosedIcon } from "@heroicons/react/24/outline"; 12 | import { ClientResponseError } from 'pocketbase'; 13 | import { validateEmail } from "../../lib/validate"; 14 | import Image from "next/image"; 15 | 16 | const Login = () => { 17 | const [provider, setProvider] = useState(); 18 | 19 | const { signInWithEmail, client }: any = useUserContext() 20 | const [showForgotPassword, setShowForgotPassword] = useState(false); 21 | 22 | const handleLogin = () => { 23 | // get values from input fields 24 | const email = document.getElementById("email") as HTMLInputElement; 25 | const password = document.getElementById("password") as HTMLInputElement; 26 | 27 | // check if values are empty 28 | if (email.value === "" || password.value === "") { 29 | Toast("Please fill in all fields", ToastType.warning); 30 | document.getElementById("email")?.focus(); 31 | return; 32 | } 33 | 34 | if (!validateEmail(email.value)) { 35 | Toast("Please enter a valid email address", ToastType.warning); 36 | return; 37 | } 38 | 39 | // login 40 | signInWithEmail(email.value, password.value, false); 41 | } 42 | 43 | const handleForgotPassword = async () => { 44 | // get values from input fields 45 | const email = document.getElementById("recoverEmail") as HTMLInputElement; 46 | 47 | // check if values are empty 48 | if (email.value === "") { 49 | Toast("Please fill in all fields", ToastType.warning); 50 | document.getElementById("recoverEmail")?.focus(); 51 | return; 52 | } 53 | 54 | if (!validateEmail(email.value)) { 55 | Toast("Please enter a valid email address", ToastType.warning); 56 | return; 57 | } 58 | 59 | // Request password reset 60 | await client.users.requestPasswordReset('test@example.com') 61 | .then(() => { 62 | Toast("Email sent", ToastType.success); 63 | // value to "" 64 | email.value = ""; 65 | setShowForgotPassword(false); 66 | }) 67 | .catch((error: ClientResponseError) => { 68 | Toast(error.message, ToastType.error); 69 | }) 70 | } 71 | 72 | useEffect(() => { 73 | const getAuthProviders = async () => { 74 | const result = await client.users.listAuthMethods(); 75 | setProvider(result); 76 | } 77 | 78 | getAuthProviders() 79 | .catch((error: ClientResponseError) => { 80 | console.log(error); 81 | }) 82 | }, [client.users]) 83 | 84 | // if enter is pressed, login 85 | const handleKeyDown = (event: any) => { 86 | if (event.key === 'Enter') { 87 | handleLogin(); 88 | } 89 | } 90 | 91 | useEffect(() => { 92 | document.addEventListener("keydown", handleKeyDown, false); 93 | 94 | return () => { 95 | document.removeEventListener("keydown", handleKeyDown, false); 96 | }; 97 | 98 | // eslint-disable-next-line react-hooks/exhaustive-deps 99 | }, []); 100 | 101 | const providerNames = provider?.authProviders?.map((provider: any) => provider.name); 102 | 103 | return ( 104 |
105 |
106 |
109 | Logo src} 116 | /> 117 |
118 | 119 | Pocketbase Next.js Template 120 | 121 |
124 |
130 | 131 | App Sign In 132 | 133 | 140 | 147 | 148 | { 151 | setShowForgotPassword(!showForgotPassword); 152 | }} 153 | > 154 | Forgotten Password? 155 | 156 | 157 | 164 | { 165 | providerNames?.includes("google") && 166 | signInWithEmail()} 172 | /> 173 | } 174 | { 175 | providerNames?.includes("github") && 176 | signInWithEmail()} 182 | /> 183 | } 184 |
185 |
191 | 192 | Recover you Password 193 | 194 | 201 | 202 | 209 | 210 | { 214 | setShowForgotPassword(!showForgotPassword); 215 | }} 216 | /> 217 |
218 |
219 |
220 |
221 | ) 222 | } 223 | 224 | export default Login 225 | -------------------------------------------------------------------------------- /ui/components/Navigation.tsx: -------------------------------------------------------------------------------- 1 | import { Navbar, Dropdown, Avatar, Tooltip } from "flowbite-react"; 2 | import { Bars3Icon, BellIcon, BuildingStorefrontIcon, CalendarDaysIcon, ChartPieIcon, TableCellsIcon, WrenchScrewdriverIcon, XMarkIcon } from '@heroicons/react/24/outline'; 3 | import { useRouter } from "next/router"; 4 | import { useUserContext } from "../contexts/userContext"; 5 | import { User } from 'pocketbase'; 6 | import Api from "../config/Api"; 7 | import { parseUserAvatarUrl } from "../lib/parser"; 8 | import { classNames } from "../lib/design"; 9 | import { Disclosure, Menu, Transition } from '@headlessui/react' 10 | import { Fragment } from "react"; 11 | import Link from "next/link"; 12 | import Image from "next/image"; 13 | 14 | const Navigation = () => { 15 | 16 | const router = useRouter(); 17 | 18 | const { logout }: any = useUserContext() 19 | const { user }: any = useUserContext() 20 | 21 | // convert user to User type 22 | const userObj: User = user; 23 | 24 | const navigation = [ 25 | { 26 | name: 'Dashboard', 27 | href: '/dashboard', 28 | current: router.pathname === '/dashboard', 29 | icon: ChartPieIcon, 30 | }, 31 | { 32 | name: 'Plans', 33 | href: '/plans', 34 | current: router.pathname === '/plans', 35 | icon: TableCellsIcon, 36 | }, 37 | { 38 | name: 'Settings', 39 | href: '/settings', 40 | current: router.pathname === '/settings', 41 | icon: WrenchScrewdriverIcon, 42 | }, 43 | ] 44 | 45 | return ( 46 | 251 | ) 252 | } 253 | 254 | export default Navigation 255 | -------------------------------------------------------------------------------- /ui/components/profile/ProfileSettingsForm.tsx: -------------------------------------------------------------------------------- 1 | import { AtSymbolIcon, CheckBadgeIcon, ExclamationTriangleIcon, FingerPrintIcon, IdentificationIcon, KeyIcon, TrashIcon, UserCircleIcon, XCircleIcon } from "@heroicons/react/24/outline"; 2 | import { useUserContext } from "../../contexts/userContext"; 3 | import InputField from "../general/forms/InputField"; 4 | import SubHeading from "../general/typo/SubHeading"; 5 | import { User, ClientResponseError } from 'pocketbase'; 6 | import { parseUserAvatarUrl } from "../../lib/parser"; 7 | import StyledButton, { StyledButtonType } from "../general/buttons/StyledButton"; 8 | import Toggle from "../general/forms/Toggle"; 9 | import { Fragment, useEffect, useRef, useState } from "react"; 10 | import { classNames } from "../../lib/design"; 11 | import { Toast, ToastType } from "../alerts/Toast"; 12 | import { useRouter } from "next/router"; 13 | import Image from "next/image"; 14 | import { Dialog, Transition } from '@headlessui/react' 15 | 16 | const ProfileSettingsForm = () => { 17 | const [open, setOpen] = useState(false) 18 | 19 | const cancelButtonRef = useRef(null) 20 | 21 | const { user, client, logout }: any = useUserContext(); 22 | const userObj: User = user; 23 | const router = useRouter(); 24 | 25 | const handleSave = () => { 26 | // get values from input fields 27 | const displayName = document.getElementById("displayName") as HTMLInputElement; 28 | 29 | // check if values are empty 30 | if (displayName.value === "") { 31 | Toast("Please fill in all fields", ToastType.warning); 32 | return; 33 | } 34 | } 35 | 36 | const handleVerifyEmail = async () => { 37 | await client.users.requestVerification(userObj.email) 38 | .then(() => { 39 | Toast("Email sent", ToastType.success); 40 | }) 41 | .catch((err: ClientResponseError) => { 42 | Toast(err.message, ToastType.error); 43 | }); 44 | } 45 | 46 | const handleRequestPasswordReset = async () => { 47 | await client.users.requestPasswordReset(userObj.email) 48 | .then(() => { 49 | Toast("Email sent", ToastType.success); 50 | }) 51 | .catch((err: ClientResponseError) => { 52 | Toast(err.message, ToastType.error); 53 | }); 54 | } 55 | 56 | const handleDeleteAccount = async () => { 57 | 58 | await client.users.delete(userObj.id) 59 | .then(() => { 60 | Toast("Account deleted", ToastType.success); 61 | logout(false); 62 | }) 63 | .catch((err: ClientResponseError) => { 64 | Toast(err.message, ToastType.error); 65 | }); 66 | } 67 | 68 | const handleCancel = () => { 69 | router.push("/dashboard"); 70 | } 71 | 72 | return ( 73 |
76 | 77 | Settings 78 | 79 | 80 |
83 |
84 | { 85 | userObj?.profile?.avatar && ( 86 | User avatar src} 93 | /> 94 | ) 95 | } 96 |
97 | 104 | 105 |
106 | 107 |
108 | 117 | 126 | { 127 | userObj?.profile?.name && ( 128 | 137 | ) 138 | } 139 | 140 |
143 | 152 | 153 | { 154 | !userObj?.verified ? ( 155 |
158 | 159 | 160 | Email not verified 161 | 162 |
163 | ) : ( 164 |
167 | 168 | 169 | Email verified 170 | 171 |
172 | ) 173 | } 174 | 175 | { 176 | !userObj?.verified && ( 177 |
180 |
181 | 188 |
189 | ) 190 | 191 | } 192 |
193 | 194 |
197 | 203 | 210 |
211 | 212 | 213 |
216 |
217 | setOpen(true)} 221 | className="" 222 | icon={TrashIcon} 223 | small 224 | /> 225 |
226 |
227 | 228 | 229 | 230 | 239 |
240 | 241 | 242 |
243 |
244 | 253 | 254 |
255 |
256 |
257 |
259 |
260 | 261 | Delete account 262 | 263 |
264 |

265 | Are you sure you want to delete your account? All of your data will be permanently 266 | removed. This action cannot be undone. 267 |

268 |
269 |
270 |
271 |
272 |
273 | 282 | 290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 | 298 | 299 |
300 | ) 301 | } 302 | 303 | export default ProfileSettingsForm; 304 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------