1.3 KiB
1.3 KiB
Lunch Picker Backend
Express API server for Lunch Picker miniapp.
Modes
- Memory mode: run without MySQL env vars (quick local demo)
- MySQL mode: set
MYSQL_HOST(orMYSQL_URL) and run with real DB
1) Install
cd backend
npm install
cp .env.example .env
2) Start
npm start
Server: http://localhost:4000
3) MySQL setup
- Create DB (example)
create database lunch_picker character set utf8mb4 collate utf8mb4_0900_ai_ci;
- Apply schema
mysql -u root -p lunch_picker < ../docs/db/schema.sql
- Set
.envvalues (MYSQL_HOST,MYSQL_USER,MYSQL_PASSWORD,MYSQL_DATABASE)
When MySQL mode starts, seed data is inserted automatically only when restaurant table is empty.
API Endpoints
GET /v1/healthGET /v1/restaurants/nearbyGET /v1/restaurants/:restaurantIdGET /v1/restaurants/:restaurantId/reviewsPOST /v1/restaurants/:restaurantId/reviewsDELETE /v1/reviews/:reviewIdPOST /v1/restaurants/:restaurantId/likeGET /v1/users/me/reviews
Auth Simulation
Set x-user-id header to simulate user identity.
Example:
curl -H "x-user-id: demo-user-1" "http://localhost:4000/v1/restaurants/nearby?lat=37.501&lng=127.037&radiusMeters=1000&sort=distance"