Skip to content

Commit

Permalink
Genesis commit
Browse files Browse the repository at this point in the history
  • Loading branch information
JowaDev committed Jun 9, 2024
1 parent 8e4917d commit f467813
Show file tree
Hide file tree
Showing 46 changed files with 1,769 additions and 180 deletions.
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
DATABASE_URL=postgres://app:TxVeQ4nN82SSiYHoswqOURZvQDaL4KpNElsCEEe9bwDxMd73KckIeXzS5cU6LiC2@localhost:30003/app
17 changes: 17 additions & 0 deletions .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified bun.lockb
Binary file not shown.
17 changes: 17 additions & 0 deletions components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "default",
"rsc": true,
"tsx": true,
"tailwind": {
"config": "tailwind.config.ts",
"css": "src/app/globals.css",
"baseColor": "slate",
"cssVariables": true,
"prefix": ""
},
"aliases": {
"components": "@/components",
"utils": "@/lib/utils"
}
}
23 changes: 23 additions & 0 deletions disaster-recovery/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
24 changes: 24 additions & 0 deletions disaster-recovery/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: v2
name: disaster-recovery
description: A Helm chart for Kubernetes

# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"
9 changes: 9 additions & 0 deletions disaster-recovery/templates/database-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
type: kubernetes.io/basic-auth
kind: Secret
metadata:
name: {{ .Values.dev.database.secret.name }}
namespace: {{ .Values.dev.namespace }}
data:
password: {{ .Values.dev.database.secret.password }}
username: {{ .Values.dev.database.secret.username }}
16 changes: 16 additions & 0 deletions disaster-recovery/templates/database.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: {{ .Values.dev.database.name }}
namespace: {{ .Values.dev.namespace }}
spec:
instances: {{ .Values.dev.database.instance }}
primaryUpdateStrategy: unsupervised
monitoring:
enablePodMonitor: true
storage:
size: {{ .Values.dev.database.storage.size }}
bootstrap:
initdb:
secret:
name: {{ .Values.dev.database.secret.name }}
4 changes: 4 additions & 0 deletions disaster-recovery/templates/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: {{ .Values.dev.namespace }}
21 changes: 21 additions & 0 deletions disaster-recovery/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Global configuration
dockerRegistry:
dockerconfigjson: ""
image:
pullPolicy: Always
repository: jowadev/strapi-backend
tag: local

# Dev
dev:
fullname: db-backend
namespace: dev
database:
name: postgresql
instance: 3
storage:
size: 1Gi
secret:
name: database-secret
username: YXBw
password: VHhWZVE0bk44MlNTaVlIb3N3cU9VUlp2UURhTDRLcE5FbHNDRUVlOWJ3RHhNZDczS2NrSWVYelM1Y1U2TGlDMg==
11 changes: 11 additions & 0 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import 'dotenv/config';
import {defineConfig} from 'drizzle-kit';

export default defineConfig({
schema: './src/db/todo/schema.ts',
out: './src/db/todo/migrations',
dialect: 'postgresql',
dbCredentials: {
url: process.env.DATABASE_URL!,
},
});
39 changes: 34 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,50 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"cnpg-repo-install": "helm repo add cnpg https://cloudnative-pg.github.io/charts && helm upgrade --install cnpg --namespace cnpg-system --create-namespace cnpg/cloudnative-pg",
"monitoring-repo-install": "helm repo add prometheus-community https://prometheus-community.github.io/helm-charts && helm upgrade --install -f https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/main/docs/src/samples/monitoring/kube-stack-config.yaml prometheus-community prometheus-community/kube-prometheus-stack",
"deploy-locally": "helm upgrade --install disaster-recovery ./disaster-recovery",
"patch-cnpg-svc": "kubectl patch svc postgresql-rw -n dev -p '{\"spec\": {\"type\": \"NodePort\", \"ports\": [{\"name\": \"postgres\", \"nodePort\": 30003, \"port\": 5432, \"targetPort\": 5432, \"protocol\": \"TCP\"}]}}'",
"monitoring-svc-forward": "kubectl port-forward svc/prometheus-community-grafana 3000:80",
"deploy": "bun run cnpg-repo-install && bun run monitoring-repo-install && bun run deploy-locally && bun run patch-cnpg-svc && bun run monitoring-svc-forward",
"generate-migration": "bunx drizzle-kit generate",
"push-migration": "bunx drizzle-kit migrate"
},
"dependencies": {
"@hookform/resolvers": "^3.6.0",
"@radix-ui/react-label": "^2.0.2",
"@radix-ui/react-popover": "^1.0.7",
"@radix-ui/react-scroll-area": "^1.0.5",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-toast": "^1.1.5",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"dotenv": "^16.4.5",
"drizzle-orm": "^0.31.2",
"framer-motion": "^11.2.10",
"lucide-react": "^0.390.0",
"next": "14.2.3",
"postgres": "^3.4.4",
"react": "^18",
"react-dom": "^18",
"next": "14.2.3"
"react-hook-form": "^7.51.5",
"reveal.js": "^5.1.0",
"sharp": "^0.33.4",
"tailwind-merge": "^2.3.0",
"tailwindcss-animate": "^1.0.7",
"zod": "^3.23.8"
},
"devDependencies": {
"typescript": "^5",
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"drizzle-kit": "^0.22.6",
"eslint": "^8",
"eslint-config-next": "14.2.3",
"postcss": "^8",
"tailwindcss": "^3.4.1",
"eslint": "^8",
"eslint-config-next": "14.2.3"
"typescript": "^5",
"@types/reveal.js": "^5.0.3"
}
}
6 changes: 3 additions & 3 deletions postcss.config.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/** @type {import('postcss-load-config').Config} */
const config = {
plugins: {
tailwindcss: {},
},
plugins: {
tailwindcss: {},
},
};

export default config;
7 changes: 6 additions & 1 deletion public/next.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion public/vercel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions src/actions/createTodo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use server'

import {z} from "zod";
import {TodoFormSchema} from "@/db/todo/validator";
import {insertTodo} from "@/db/todo/service";
import {NewTodoType} from "@/db/todo/schema";
import {revalidatePath} from "next/cache";

export const createTodo = async (data: z.infer<typeof TodoFormSchema>) => {
const validatedFields = TodoFormSchema.safeParse(data);
if (!validatedFields.success) {
throw new Error(validatedFields.error.errors[0].message);
}
const insertResult: NewTodoType[] = await insertTodo(validatedFields.data)
revalidatePath('/');
return insertResult;
}
17 changes: 17 additions & 0 deletions src/actions/editTodo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use server'

import {z} from "zod";
import {TodoEditFormSchema} from "@/db/todo/validator";
import {updateTodo} from "@/db/todo/service";
import {NewTodoType} from "@/db/todo/schema";
import {revalidatePath} from "next/cache";

export const editTodo = async (data: z.infer<typeof TodoEditFormSchema>) => {
const validatedFields = TodoEditFormSchema.safeParse(data);
if (!validatedFields.success) {
throw new Error(validatedFields.error.errors[0].message);
}
const updateResult: NewTodoType[] = await updateTodo(validatedFields.data.id, validatedFields.data);
revalidatePath('/');
return updateResult;
}
16 changes: 16 additions & 0 deletions src/actions/removeTodo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use server'

import {z} from "zod";
import {TodoDeleteSchema} from "@/db/todo/validator";
import {revalidatePath} from "next/cache";
import {deleteTodo} from "@/db/todo/service";

export const removeTodo = async (data: z.infer<typeof TodoDeleteSchema>) => {
const validatedFields = TodoDeleteSchema.safeParse(data);
if (!validatedFields.success) {
throw new Error(validatedFields.error.errors[0].message);
}
const removeResult = await deleteTodo(validatedFields.data.id);
revalidatePath('/');
return removeResult;
}
Loading

0 comments on commit f467813

Please sign in to comment.