Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V2] Multiuser support #4

Merged
merged 188 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
188 commits
Select commit Hold shift + click to select a range
6ef008e
Define new database schema
timia2109 Jan 13, 2023
0cf32e4
Drop existing migration
timia2109 Jan 13, 2023
bd57948
Add new migration
timia2109 Jan 13, 2023
79e19ad
Add next auth
timia2109 Jan 13, 2023
66efdae
Implement next auth
timia2109 Jan 13, 2023
1726689
Add authenticated requests
timia2109 Jan 13, 2023
db65853
create timerange model
timia2109 Jan 13, 2023
f581a13
Add google auth to env vars
timia2109 Jan 13, 2023
d972bba
add dal operations
timia2109 Jan 13, 2023
b5c45d6
add userCreationHandler
timia2109 Jan 13, 2023
f3ff04e
Add methods to trpc
timia2109 Jan 13, 2023
15bd905
Upgrade package-lock
timia2109 Jan 13, 2023
84ddd0b
Add helper type
timia2109 Jan 13, 2023
cf8ba23
Use prisma client of Context
timia2109 Jan 13, 2023
1c63d9b
Resolved mealPlan
timia2109 Jan 13, 2023
cf3c112
add i18nnext
timia2109 Jan 13, 2023
d45cdbc
Add i18next
timia2109 Jan 13, 2023
7eb9f3a
configure i18next
timia2109 Jan 13, 2023
aba8d0f
Add some texts
timia2109 Jan 13, 2023
99083ae
add i18nconfig to tsconfig
timia2109 Jan 13, 2023
8aa8ef8
simpler trpc router
timia2109 Jan 13, 2023
1199b6e
add mealplans router
timia2109 Jan 13, 2023
4d2ef16
rename page
timia2109 Jan 13, 2023
c4e641c
create new index page
timia2109 Jan 13, 2023
3002d2a
add _document
timia2109 Jan 13, 2023
fcefb88
integrate i18next to app
timia2109 Jan 13, 2023
f9bed0f
fix import
timia2109 Jan 13, 2023
16fcdd6
add hack to getSession
timia2109 Jan 13, 2023
191cd76
add react hook for session
timia2109 Jan 13, 2023
c6e4e02
add env setting for privacy Url
timia2109 Jan 13, 2023
fb4ca53
add area of signin buttons
timia2109 Jan 13, 2023
1976dd0
add generic card component
timia2109 Jan 13, 2023
e945aaf
add footer
timia2109 Jan 13, 2023
e6612d4
Improvements
timia2109 Oct 27, 2023
46134e6
Switch to pnpm
timia2109 Oct 27, 2023
2e62420
Upgrade next
timia2109 Oct 27, 2023
2e86c23
Fix color
timia2109 Oct 27, 2023
69b3bf7
Fix footer
timia2109 Oct 27, 2023
4cbf0e3
Run updates // switch packages
timia2109 Jul 23, 2024
bcc7918
Add DaisyUI
timia2109 Jul 23, 2024
1f54f92
Upgrade NextAuth to v5
timia2109 Jul 23, 2024
4464a07
Remove trpc support (will use Server Actions)
timia2109 Jul 23, 2024
0190728
Add new layout
timia2109 Jul 23, 2024
2d9715b
Add mock navbar
timia2109 Jul 23, 2024
c825456
chore: Update NextAuth configuration for session validity in seconds
timia2109 Jul 23, 2024
9c34d4e
Use new Auth Schema. Reset all Migrations
timia2109 Jul 23, 2024
c18b04e
Comment out old pages to make the migration easier
timia2109 Jul 23, 2024
ecc18e8
chore: Update Prisma dependency to version 5.17.0
timia2109 Jul 23, 2024
e6afb94
Apply next suggestions
timia2109 Jul 23, 2024
44d27cf
chore: Update .gitignore to replace "_pages" with "OLD_pages"
timia2109 Jul 23, 2024
d378650
chore: Add new layout and update NextAuth configuration
timia2109 Jul 23, 2024
6bb57cd
chore: Add middleware for server authentication
timia2109 Jul 23, 2024
285e4ba
Move middleware
timia2109 Jul 23, 2024
fe36aa5
Fix auth
timia2109 Jul 23, 2024
136c2fc
Add secret to env schema
timia2109 Jul 23, 2024
1672dc5
chore: Add launch.json for debugging configurations
timia2109 Jul 24, 2024
b4dd166
Add first Page
timia2109 Jul 24, 2024
af71163
Add next-intl
timia2109 Jul 24, 2024
30c296b
Prepare next-intl with next-auth
timia2109 Jul 24, 2024
34a9d5d
Switch to next-international
timia2109 Jul 24, 2024
81f78d3
Add Login Buttons
timia2109 Jul 24, 2024
863c1a8
chore: Remove SignInButtons component
timia2109 Jul 24, 2024
92715ee
Add better title
timia2109 Jul 24, 2024
5ca96d4
Fix locales
timia2109 Jul 24, 2024
48ef733
Fix prisma
timia2109 Jul 24, 2024
2ff8de2
Add Google Profile images as secure
timia2109 Jul 31, 2024
ebbd199
Optimize Authentication
timia2109 Jul 31, 2024
b6fe671
Export get current locale
timia2109 Jul 31, 2024
8f9d3e3
Add helper to get userid
timia2109 Jul 31, 2024
a13bc1d
Add helper for redirection
timia2109 Jul 31, 2024
4c046bb
Add profileImage
timia2109 Jul 31, 2024
a34865a
Redirect to Meal Plan after login
timia2109 Jul 31, 2024
1b9c3e1
Add layout for userArea
timia2109 Jul 31, 2024
2aa77fd
Add example page
timia2109 Jul 31, 2024
71fd6bb
chore: Update zod dependency to version 3.23.8 and add zod-form-data …
timia2109 Aug 2, 2024
8620126
Optimize DAL
timia2109 Aug 2, 2024
56f070b
Migrate plan to new Schema
timia2109 Aug 2, 2024
dc4e38b
Optimize onCreateUser
timia2109 Aug 2, 2024
ddc874d
chore: Update ESLint configuration to ignore non-null assertions
timia2109 Aug 2, 2024
1952875
feat: Add getLinkWithLocale function for redirecting with locale
timia2109 Aug 2, 2024
11ae8a4
feat: Add createKeyDate function for generating key dates
timia2109 Aug 2, 2024
22cb699
chore: Refactor getMonthRange function to remove unnecessary code
timia2109 Aug 2, 2024
d62f46b
chore: Refactor enumerateDates function
timia2109 Aug 2, 2024
bc9cd76
chore: Remove unused components and optimize calendar rendering
timia2109 Aug 2, 2024
901f6c4
feat: Update user avatar size in NavBar component
timia2109 Aug 2, 2024
1baad10
chore: Add updateMealEntry action for updating meal entries
timia2109 Aug 2, 2024
a7c5ec6
chore: Refactor meal plan page component
timia2109 Aug 2, 2024
1737ac8
feat: Add MoveMonthButton component for navigating between months in …
timia2109 Aug 2, 2024
c573a6f
feat: Refactor MealPlanContainer colors and add MoveMonthButton
timia2109 Aug 2, 2024
82de4cd
Shorten calendar
timia2109 Aug 2, 2024
892b76c
chore: Remove unnecessary semicolon in MealPlanPage component
timia2109 Aug 2, 2024
662e2f5
fix: Update date validation in updateMealEntry action
timia2109 Aug 2, 2024
01c2a2e
feat: optimize design
timia2109 Aug 2, 2024
d549de3
feat: Update MealEntryComponent to use form element for better access…
timia2109 Aug 2, 2024
0685b6d
feat: Update body class in layout component for better styling
timia2109 Aug 2, 2024
99e08ca
feat: use light mode as default (currently)
timia2109 Aug 2, 2024
0246ec3
feat: define Jenin Theme
timia2109 Aug 2, 2024
fc63a2e
feat: Add getMealPlanLabel function to retrieve meal plan label
timia2109 Aug 2, 2024
f5508b4
Update translation for landing page and meal plan labels
timia2109 Aug 2, 2024
ddf8fc2
feat: Use title on mealplans
timia2109 Aug 2, 2024
5a376cf
feat: Add backlink in navbar
timia2109 Aug 2, 2024
e5eb8d1
feat: Short all ID fields (sorry, new migration history)
timia2109 Aug 2, 2024
30387db
Merge pull request #2 from timia2109/feature/next-14
timia2109 Aug 2, 2024
1db7fed
Clean up ESLint
timia2109 Aug 2, 2024
653193b
chore: Upgrade typescript
timia2109 Aug 2, 2024
09a2267
chore: Reconfigure typescript
timia2109 Aug 2, 2024
0d4c766
refactor: Remove old stuff, try to get a fully build
timia2109 Aug 2, 2024
2f0a450
feat: Add docker support
timia2109 Aug 2, 2024
148a626
feat: First draft of manage page
timia2109 Aug 2, 2024
e671cbb
Remove old locales
timia2109 Aug 2, 2024
1051760
feat: Exclude MealPlanEntry component and spilt to recycle
timia2109 Aug 3, 2024
30d726a
feat: Add new profile Images components
timia2109 Aug 3, 2024
41f05de
feat: Optimize footer
timia2109 Aug 3, 2024
8ff9261
feat: Optimize footer in layout
timia2109 Aug 3, 2024
b9ad438
fix: Reduce bugs with invalid date combinations
timia2109 Aug 3, 2024
307b067
feat: sort mealplans by name
timia2109 Aug 3, 2024
b6b1a66
feat: add function to get mealplan users
timia2109 Aug 3, 2024
558f887
feat: refactor NavBar
timia2109 Aug 3, 2024
0f122b0
Add missing texts
timia2109 Aug 3, 2024
8cb9aa7
feat: Add an not found page
timia2109 Aug 3, 2024
4cdb3c1
feat: Optimize Manage page
timia2109 Aug 3, 2024
13c7358
feat: Add header for mealplan page
timia2109 Aug 3, 2024
3c8f399
refactor: restructure
timia2109 Aug 3, 2024
c0def4f
feat: set mealplan as default
timia2109 Aug 3, 2024
3e8d15c
feat: add hint, that default plan cant be deleted
timia2109 Aug 3, 2024
eb5d8fc
feat: Add new tooltip elements
timia2109 Aug 3, 2024
e0c3597
feat: use tooltip elements
timia2109 Aug 3, 2024
3d369af
feat: optimize leave meal plan
timia2109 Aug 3, 2024
9d1a71e
feat: Deleting Mealplan
timia2109 Aug 3, 2024
97c5b9f
feat: Add sceleton for invitation
timia2109 Aug 3, 2024
b12c5a8
Merge pull request #3 from timia2109/feature/mealplan-management
timia2109 Aug 3, 2024
0d5973d
Add expiration time
timia2109 Aug 3, 2024
7256749
feat: Update prisma client
timia2109 Aug 3, 2024
c2e5898
feat: fix invitation link creation
timia2109 Aug 3, 2024
6862069
Merge branch 'main' into epic/users
timia2109 Aug 3, 2024
8352a34
rename: Rename epic job
timia2109 Aug 3, 2024
7051285
Add expiration time
timia2109 Aug 3, 2024
42ac676
feat: Update prisma client
timia2109 Aug 3, 2024
736c0e4
feat: fix invitation link creation
timia2109 Aug 3, 2024
0ebe7b7
Merge branch 'feature/create-invitations' of https://github.com/timia…
timia2109 Aug 3, 2024
7cb0a80
chore: add fa brands icons
timia2109 Aug 3, 2024
06f52e8
Create sharing invitation links
timia2109 Aug 3, 2024
2d54dce
fix: build error with not found page
timia2109 Aug 4, 2024
93f08bb
fix: build with preserving locale
timia2109 Aug 4, 2024
96ca9b5
Correct relations in Schema
timia2109 Aug 4, 2024
6ece2c9
feat: Add relations migration
timia2109 Aug 4, 2024
5e04d19
feat: Build first invitation joining step
timia2109 Aug 4, 2024
a8566fc
feat: Finalize plan joining
timia2109 Aug 4, 2024
7ec6088
refactor: Remove old artifacts
timia2109 Aug 4, 2024
ea1b65b
fix: Other schema error
timia2109 Aug 4, 2024
6592511
Merge pull request #6 from timia2109/feature/create-invitations
timia2109 Aug 4, 2024
0596e17
refactor: Use clearer component names
timia2109 Aug 4, 2024
58dda87
refactor: Harmonize action names
timia2109 Aug 4, 2024
e6d633f
refactor: Rename database file
timia2109 Aug 4, 2024
74a900c
feat: add function to rename meal plan
timia2109 Aug 4, 2024
cf897d4
refactor: central route management in routes.ts
timia2109 Aug 4, 2024
08ec493
feat: better links on manage
timia2109 Aug 4, 2024
0f73780
feat: optimize MealPlanComponent layout
timia2109 Aug 4, 2024
d346f46
Add titles to profile images
timia2109 Aug 4, 2024
a01365e
Add actions for adding and renaming plans
timia2109 Aug 4, 2024
fc63732
feat: add all edit actions
timia2109 Aug 4, 2024
35d3e40
feat: harmonize all dialogs
timia2109 Aug 4, 2024
962667a
feat: Optimize NavBar & add Profile page
timia2109 Aug 4, 2024
487bc9f
feat: Response optimizations. Better invite screen
timia2109 Aug 4, 2024
edce0e5
feat: Better order on invitation
timia2109 Aug 4, 2024
6fc1155
feat: more themes, theme selector
timia2109 Aug 4, 2024
48eb013
feat: Add layout preferences
timia2109 Aug 5, 2024
19953c8
feat: Refresh jenin theme
timia2109 Aug 5, 2024
7c50607
feat: get themes from config
timia2109 Aug 5, 2024
b66b0c8
feat: drop jenin theme
timia2109 Aug 5, 2024
ea1181a
fix: build errors
timia2109 Aug 5, 2024
31bb3a3
Merge pull request #7 from timia2109/feature/meal-plan-creation
timia2109 Aug 5, 2024
f6bc0aa
refactor: footer
timia2109 Aug 5, 2024
a211dc4
feat: better documentation
timia2109 Aug 5, 2024
58360fa
chore: new example image
timia2109 Aug 5, 2024
1449536
feat: harmonize login button
timia2109 Aug 5, 2024
96d92fb
feat: drop constraint to enable user linking
timia2109 Aug 5, 2024
9d2cfbd
feat: style logo in NavBar
timia2109 Aug 7, 2024
12ad22b
feat: optimize login buttons
timia2109 Aug 7, 2024
3ca532b
feat: optimize manage layout
timia2109 Aug 7, 2024
f123eaa
fix: fixes a bug, that create multiple mealplans on different account…
timia2109 Aug 7, 2024
bc52f10
feat: add a features landing page
timia2109 Aug 7, 2024
6ceb332
refactor: update path to image in readme
timia2109 Aug 7, 2024
0e36ef1
feat: add locales
timia2109 Aug 7, 2024
8f62f2d
Merge pull request #8 from timia2109/feature/ui-improvements
timia2109 Aug 7, 2024
34dd79f
feat: add support for redirect proxy
timia2109 Aug 7, 2024
51c4cd8
feat: Update authjs
timia2109 Aug 7, 2024
1a8603d
feat: add sharp
timia2109 Aug 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Since .env is gitignored, you can use .env.example to build a new `.env` file when you clone the repo.
# Keep this file up-to-date when you add new variables to `.env`.

# This file will be committed to version control, so make sure not to have any secrets in it.
# If you are cloning this repo, create a copy of this file named `.env` and populate it with your secrets.

# When adding additional env variables, the schema in /env/schema.mjs should be updated accordingly

# Prisma
DATABASE_URL=file:./db.sqlite
DATABASE_URL=mysql://root:root@db/simple-meal-plan
INVITATION_VALIDITY=P30D
NEXTAUTH_SECRET=A_SECRET
ROOT_URL=https://example.com
NEXT_PUBLIC_PRIVACY_URL=https://example.com
14 changes: 10 additions & 4 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,15 @@
"parserOptions": {
"project": "./tsconfig.json"
},
"plugins": ["@typescript-eslint"],
"extends": ["next/core-web-vitals", "plugin:@typescript-eslint/recommended"],
"plugins": [
"@typescript-eslint"
],
"extends": [
"next/core-web-vitals",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"@typescript-eslint/consistent-type-imports": "warn"
"@typescript-eslint/consistent-type-imports": "warn",
"@typescript-eslint/no-non-null-assertion": "off"
}
}
}
35 changes: 35 additions & 0 deletions .github/workflows/publish-epic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Publish Epic
on:
push:
branches:
- epic/*
env:
REGISTRY: ghcr.io
jobs:
build-docker-image:
runs-on: ubuntu-22.04
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Docker Login
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker Metadata action
id: docker_metadata
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}
tags: |
type=ref,event=branch
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.docker_metadata.outputs.tags }}
labels: ${{ steps.docker_metadata.outputs.labels }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ yarn-error.log*

# typescript
*.tsbuildinfo
.yarn/cache
.yarn/cache
OLD_pages
28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug server-side",
"type": "node-terminal",
"request": "launch",
"command": "pnpm dev"
},
{
"name": "Debug client-side",
"type": "chrome",
"request": "launch",
"url": "http://localhost:3000"
},
{
"name": "Debug full stack",
"type": "node-terminal",
"request": "launch",
"command": "pnpm dev",
"serverReadyAction": {
"pattern": "- Local:.+(https?://.+)",
"uriFormat": "%s",
"action": "debugWithChrome"
}
}
]
}
25 changes: 18 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
# Simple Meal Plan

This is a very simple meal planner which I build in two hours.
I want to replace the Excel Sheet, my girlfriend was using.
Currently there a no authentication build in. So this should only deployed on private networks.
Work in Progress.
This is a very simple meal planner. It's main purpose is to host it as a free SaaS solution.
You can use it [here](https://example.com). Anyway you can deploy it using Docker.

I want to replace the Excel Sheet, my girlfriend was using.

## Features

![Example Screenshot](public/example.png)

- Plan Meal for any date
- (Tablet, Desktop): See a complete calendar of the month which is editable
- Share meal plans with magic links to other users to collaborate (household, etc.)
- Manage multiple meal plans per user

## Techstack

- [Next.js](https://nextjs.org)
- [Prisma](https://prisma.io)
- [Tailwind CSS](https://tailwindcss.com)
- [tRPC](https://trpc.io)
- [DaisyUI](https://daisyui.com)

## Deployment

## Screenshot
![Example Screenshot](docs/example.png)
You'll need a MySQL / MariaDB database.
Have a look at [`.env.example`](./.env.example) or at the [schema](./src/env/schema.mjs)
71 changes: 26 additions & 45 deletions dockerfile
Original file line number Diff line number Diff line change
@@ -1,64 +1,45 @@
##### DEPENDENCIES
FROM node:20 AS base

FROM node:16-alpine AS deps
RUN apk add --no-cache libc6-compat openssl1.1-compat
FROM base AS builder
WORKDIR /app

# Install Prisma Client - remove if not using Prisma

COPY prisma ./

# Install dependencies based on the preferred package manager

COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml\* ./

RUN \
if [ -f yarn.lock ]; then yarn --frozen-lockfile; \
elif [ -f package-lock.json ]; then npm ci; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && pnpm i; \
else echo "Lockfile not found." && exit 1; \
fi

##### BUILDER

FROM node:16-alpine AS builder
ARG DATABASE_URL
ARG NEXT_PUBLIC_CLIENTVAR
WORKDIR /app
COPY --from=deps /app/node_modules ./node_modules
COPY . .

# ENV NEXT_TELEMETRY_DISABLED 1
ENV NEXT_TELEMETRY_DISABLED=1 SKIP_ENV_VALIDATION=1

RUN \
if [ -f yarn.lock ]; then SKIP_ENV_VALIDATION=1 yarn build; \
elif [ -f package-lock.json ]; then SKIP_ENV_VALIDATION=1 npm run build; \
elif [ -f pnpm-lock.yaml ]; then yarn global add pnpm && SKIP_ENV_VALIDATION=1 pnpm run build; \
else echo "Lockfile not found." && exit 1; \
fi
# SET DUMMY VALUES FOR BUILD
ENV DATABASE_URL=CHANGE_ME
ENV GOOGLE_CLIENT_ID=CHANGE_ME
ENV GOOGLE_CLIENT_SECRET=CHANGE_ME
ENV NEXTAUTH_SECRET=CHANGE_ME

##### RUNNER
RUN corepack enable pnpm && pnpm i --frozen-lockfile && pnpm run build

FROM node:16-alpine AS runner
RUN apk add --no-cache libc6-compat openssl1.1-compat
# ================================#
# PROD
# ================================
FROM base AS runner
WORKDIR /app

ENV NODE_ENV production

# ENV NEXT_TELEMETRY_DISABLED 1
ENV NODE_ENV=production NEXT_TELEMETRY_DISABLED=1

RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nextjs

COPY --from=builder /app/next.config.mjs ./
COPY --from=builder /app/public ./public
COPY --from=builder /app/package.json ./package.json
COPY --from=builder --chown=nextjs:nodejs /app/public ./public
COPY --chown=nextjs:nodejs prisma ./prisma/

COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
# Set the correct permission for prerender cache
RUN mkdir .next
RUN chown nextjs:nodejs .next
RUN npm install prisma

COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --chown=nextjs:nodejs ./init.sh .

USER nextjs

EXPOSE 3000
ENV PORT 3000

CMD ["node", "server.js"]
ENV PORT=3000 HOSTNAME=0.0.0.0
ENTRYPOINT [ "/bin/sh", "./init.sh" ]
Binary file removed docs/example.png
Binary file not shown.
4 changes: 4 additions & 0 deletions init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

#!/bin/sh
npx prisma migrate deploy
node server.js
16 changes: 11 additions & 5 deletions next.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@
/** @type {import("next").NextConfig} */
const config = {
reactStrictMode: true,
swcMinify: true,
i18n: {
locales: ["en"],
defaultLocale: "en",
},
output: "standalone",
images: {
remotePatterns: [
{
hostname: "img.shields.io",
},
{
hostname: "*.googleusercontent.com",
},
],
},
};

export default config;
Loading