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

feat: home page & category api #46

Merged
merged 24 commits into from
Dec 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
ddc9fdf
feat: init homepage
dribble-njr Dec 15, 2024
a3f8c9f
fix: safe area surface content height
dribble-njr Dec 16, 2024
00025e8
feat: home greeting
dribble-njr Dec 16, 2024
805cb40
feat(db): dish model
dribble-njr Dec 16, 2024
cb53a57
chore: clean up
dribble-njr Dec 17, 2024
ccf9d87
feat(db): add image to dish table
dribble-njr Dec 17, 2024
e49d37f
fix(server): judge user existed firstly
dribble-njr Dec 17, 2024
01ee9f2
feat(db): add referential integrity constraints with onDelete rules
dribble-njr Dec 23, 2024
e11c042
feat: init category crud
dribble-njr Dec 23, 2024
2967ef6
chore: optimize docker
dribble-njr Dec 23, 2024
f156baf
feat: prisma seed
dribble-njr Dec 23, 2024
16250aa
feat: use transaction
dribble-njr Dec 24, 2024
e9a58c9
chore: cache yarn install
dribble-njr Dec 24, 2024
3c47f43
feat: create category in kitchen
dribble-njr Dec 24, 2024
134068b
feat: category crud
dribble-njr Dec 24, 2024
39c17b8
feat(db): category seed
dribble-njr Dec 24, 2024
477e39f
refactor(category): imporve trash-related operations naming
dribble-njr Dec 25, 2024
77170f3
chore(ci): add prisma deploy
dribble-njr Dec 25, 2024
c35506e
docs: update
dribble-njr Dec 25, 2024
02371d8
fix(ci): git diff bad object
dribble-njr Dec 25, 2024
651aa22
fix(ci): use migrate diff
dribble-njr Dec 25, 2024
40b6dac
fix(ci): environment secrets error
dribble-njr Dec 25, 2024
64b73a7
feat: add index explicitly
dribble-njr Dec 25, 2024
181fbaf
chore(ci): change the timing of check prisma migration
dribble-njr Dec 25, 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
71 changes: 55 additions & 16 deletions .github/workflows/check-prisma.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,72 @@ on:
pull_request:
paths:
- 'apps/server/prisma/schema.prisma'
types: [opened, synchronize, reopened, edited]
types: [opened, synchronize, reopened]

jobs:
check-migrations:
runs-on: ubuntu-latest

environment: development

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.10.0
cache: yarn

- name: Check for Prisma migrations
- name: Install dependencies
run: |
yarn install

- name: Check for Prisma schema and migration consistency
run: |
echo "Checking changes between commits..."
git diff --name-only ${{ github.event.before }} ${{ github.sha }}

# Check if there are new changes in prisma/migrations
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q 'apps/server/prisma/migrations'; then
echo "✅ Prisma migration files detected. All good!"
# Ensure the base branch is fetched
git fetch origin ${{ github.base_ref }}

# Get the changed files between the base branch and the PR head
changed_files=$(git diff --name-only origin/${{ github.base_ref }} HEAD)
echo "Changed files: $changed_files"

# Check if schema.prisma has been modified
if echo "$changed_files" | grep -q 'apps/server/prisma/schema.prisma'; then
echo "🔍 Schema.prisma has been modified. Checking migrations..."

cd apps/server

# Run Prisma migrate diff to verify the migration consistency
npx prisma migrate diff \
--from-schema-datamodel prisma/schema.prisma \
--to-migrations prisma/migrations \
--shadow-database-url ${{ secrets.SHADOW_DB_URL }} \
--script > migration_diff.sql

# Check if there are any differences
if [ "$(cat migration_diff.sql | grep -v '^$' | tr -d '\n')" = "-- This is an empty migration." ]; then
echo "✅ Schema and migrations are consistent."
else
echo "❌ Detected differences between schema.prisma and migration files!"
echo "------------------------------------------"
echo "Generated migration diff:"
cat migration_diff.sql
echo "------------------------------------------"
echo "Please ensure all schema changes are reflected in migration files."
echo "You can use the following command to generate migrations:"
echo ""
echo " npx prisma migrate dev"
echo ""
echo "Once done, commit the migration files and push your changes."
echo "------------------------------------------"
exit 1
fi
else
echo "❌ No Prisma migration files found!"
echo "------------------------------------------"
echo "You modified the Prisma schema but did not generate migration files."
echo "Please run the following command to generate migrations:"
echo ""
echo " npx prisma migrate dev"
echo ""
echo "Once done, commit the migration files and push your changes."
echo "------------------------------------------"
exit 1
echo "✅ No changes to schema.prisma detected. All good!"
fi
2 changes: 1 addition & 1 deletion .github/workflows/pr-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
cd ../..

# Start container with dynamic port
SERVER_PORT=$PORT NODE_ENV=dev docker compose -f docker-compose.yml up -d --build
SERVER_PORT=$PORT docker compose -f docker-compose.yml up -d --build
EOF
env:
DEPLOY_DIR: ${{ secrets.DEPLOY_DIR }}
Expand Down
51 changes: 27 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
# Imperial Kitchen
# 御膳房

[![runs with Expo Go](https://img.shields.io/badge/Runs%20with%20Expo%20Go-4630EB.svg?style=flat-square&logo=EXPO&labelColor=white&logoColor=000)](https://expo.dev/client) [![NestJS](https://img.shields.io/badge/NestJS-E0234E.svg?style=flat-square&logo=NestJS&labelColor=white&logoColor=E0234E)](https://nestjs.com/) [![Prisma](https://img.shields.io/badge/Prisma-2D3748.svg?style=flat-square&logo=Prisma&labelColor=white&logoColor=2D3748)](https://www.prisma.io/) [![MySQL](https://img.shields.io/badge/MySQL-4479A1.svg?style=flat-square&logo=MySQL&labelColor=white&logoColor=4479A1)](https://www.mysql.com/) [![Redis](https://img.shields.io/badge/Redis-DC382D.svg?style=flat-square&logo=Redis&labelColor=white&logoColor=DC382D)](https://redis.io/)

[中文版](README_ZH.md)
[English Version](README_EN.md)

A food ordering app for family kitchen.
一个家庭厨房的点餐应用。

## Features
## 特性

- [x] Auth: JWT Login, register, logout.
- [x] Multi-language support, theme color, theme mode.
- [ ] Browse menus:View all kinds of food and their details, including images, descriptions and prices.
- [ ] Order food:Choose food and add it to shopping cart.
- [ ] Recipe: Generate recipes.
- [ ] Profile: View personal information, order history, virtual coins.
- [ ] AI assistant: Ask questions about the menu.
- [x] 认证:JWT 登录、注册、登出。
- [x] 多语言支持、主题色、主题模式。
- [ ] 浏览菜单:查看所有食物及其详情,包括图片、描述和价格。
- [ ] 点餐:选择食物并添加到购物车。
- [ ] 菜谱:支持生成菜谱。
- [ ] 个人中心:查看个人信息、订单历史、虚拟货币。
- [ ] AI 助手:询问菜单相关问题。

## Contributing
## 开发

To develop Expo, you should read [Tools for development](https://docs.expo.dev/develop/tools/) firstly.
开发 Expo 应用前,请先阅读 [开发工具](https://docs.expo.dev/develop/tools/)

1. Fork this repository to your GitHub account.
2. Install `yarn@1.22.22` and `node@20.10.0`.
3. Download repo and install deps.
1. Fork 本仓库;
2. 安装 `yarn@1.22.22` `node@20.10.0`
3. 下载仓库并安装依赖;
```sh
git clone <your_clone_repo>
cd imperial-kitchen
yarn install
```
4. Run mobile.
4. 启动移动端
```sh
yarn dev:mobile
```
5. Install and configure [`mysql`](https://www.mysql.com/), [`nodemailer`](https://nodemailer.com/) and [`redis`](https://redis.io/try-free/).
5. 安装并配置:[`mysql`](https://www.mysql.com/), [`nodemailer`](https://nodemailer.com/) and [`redis`](https://redis.io/try-free/)
> [!NOTE]
> If you use [`docker`](https://www.docker.com/) to start the server, you can skip the configuration of `mysql`.
6. Configure server env: rename **server/.env.example** to **server/.env**.
```shell
> 若你使用 [`docker`](https://www.docker.com/) 启动服务端,可以跳过配置 `mysql`
6. 配置服务端环境变量:将 **server/.env.example** 改名为 **server/.env**
```sh
# PORT=8000
# DB_URL="mysql://root:root@database:3306/imperial_kitchen"
# DB_URL="mysql://root:root@host.docker.internal:3306/imperial_kitchen"

# # nodemailer
# nodemailer_host=
Expand All @@ -52,11 +52,14 @@ To develop Expo, you should read [Tools for development](https://docs.expo.dev/d
# REDIS_PASSWORD=
# REDIS_URL=
```
7. Run server, and the api docs can be viewed at [api-docs](http://localhost:8000/api-docs).

> [!NOTE]
> 若使用 `docker` 启动服务端,出现 `Can't reach database server at host.docker.internal:3306` 报错,请检查 host 配置。
7. 启动服务端,并访问 [api-docs](http://localhost:8000/api-docs) 查看 API 文档。
```sh
yarn dev:server
```
or use docker to start the server:
或使用 docker 启动服务端:
```sh
yarn docker:dev
```
65 changes: 65 additions & 0 deletions README_EN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Imperial Kitchen

[![runs with Expo Go](https://img.shields.io/badge/Runs%20with%20Expo%20Go-4630EB.svg?style=flat-square&logo=EXPO&labelColor=white&logoColor=000)](https://expo.dev/client) [![NestJS](https://img.shields.io/badge/NestJS-E0234E.svg?style=flat-square&logo=NestJS&labelColor=white&logoColor=E0234E)](https://nestjs.com/) [![Prisma](https://img.shields.io/badge/Prisma-2D3748.svg?style=flat-square&logo=Prisma&labelColor=white&logoColor=2D3748)](https://www.prisma.io/) [![MySQL](https://img.shields.io/badge/MySQL-4479A1.svg?style=flat-square&logo=MySQL&labelColor=white&logoColor=4479A1)](https://www.mysql.com/) [![Redis](https://img.shields.io/badge/Redis-DC382D.svg?style=flat-square&logo=Redis&labelColor=white&logoColor=DC382D)](https://redis.io/)

[中文版](README.md)

A food ordering app for family kitchen.

## Features

- [x] Auth: JWT Login, register, logout.
- [x] Multi-language support, theme color, theme mode.
- [ ] Browse menus:View all kinds of food and their details, including images, descriptions and prices.
- [ ] Order food:Choose food and add it to shopping cart.
- [ ] Recipe: Generate recipes.
- [ ] Profile: View personal information, order history, virtual coins.
- [ ] AI assistant: Ask questions about the menu.

## Develop

To develop Expo, you should read [Tools for development](https://docs.expo.dev/develop/tools/) firstly.

1. Fork this repository to your GitHub account.
2. Install `yarn@1.22.22` and `node@20.10.0`.
3. Download repo and install deps.
```sh
git clone <your_clone_repo>
cd imperial-kitchen
yarn install
```
4. Run mobile.
```sh
yarn dev:mobile
```
5. Install and configure [`mysql`](https://www.mysql.com/), [`nodemailer`](https://nodemailer.com/) and [`redis`](https://redis.io/try-free/).
> [!NOTE]
> If you use [`docker`](https://www.docker.com/) to start the server, you can skip the configuration of `mysql`.
6. Configure server env: rename **server/.env.example** to **server/.env**.
```shell
# PORT=8000
# DB_URL="mysql://root:root@host.docker.internal:3306/imperial_kitchen"

# # nodemailer
# nodemailer_host=
# nodemailer_auth_user=
# nodemailer_auth_pass=

# # jwt
# JWT_SECRET=agshddgfsd

# # redis
# REDIS_PASSWORD=
# REDIS_URL=
```

> [!NOTE]
> If start server with `docker`, you get `Can't reach database server at host.docker.internal:3306` error, please check the host configuration.
7. Run server, and the api docs can be viewed at [api-docs](http://localhost:8000/api-docs).
```sh
yarn dev:server
```
or use docker to start the server:
```sh
yarn docker:dev
```
62 changes: 0 additions & 62 deletions README_ZH.md

This file was deleted.

6 changes: 6 additions & 0 deletions apps/mobile/app/(app)/(tabs)/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ const TAB_CONFIG: TabConfig[] = [
icon: 'flask',
activeIcon: 'flask-outline'
},
{
name: 'message',
locale: 'message',
icon: 'message-text',
activeIcon: 'message-text-outline'
},
{
name: 'profile',
locale: 'profile',
Expand Down
Loading
Loading