This project is a simple API built using Express.js and Prisma to manage quotes and favorites. The API allows users to fetch random quotes, view their favorite quotes, and manage them.
- Fetch 100 random quotes.
- Manage favorite quotes for users.
- View all favorite quotes.
- Add quotes to favorites.
- Remove quotes from favorites.
- Node.js - Backend runtime
- Express.js - Web framework
- Prisma - Database ORM
- PostgreSQL - Database
- Docker - Containerization
- GitHub Actions - CI/CD automation
- Raspberry Pi - Deployment environment
-
Clone the repository:
git clone https://github.com/Navong/quote-nextjs-backend.git
-
Install dependencies:
cd quote-nextjs-backend npm install
-
Create a
.env
file with the following content:DATABASE_URL=your_database_url_here PORT=4000
-
Start the server:
npm start
GET /api/quotes/random
GET /api/favorites/:userId
POST /api/favorites
Body:
{
"userId": "123",
"quoteId": 1,
"translatedText": "Optional translated quote"
}
DELETE /api/favorites/:userId
Body:
{
"quoteId": 1
}
This project uses GitHub Actions to automate the deployment process to a Raspberry Pi server.
- Trigger: On push to the
main
branch. - Build and Push Docker Image:
- Logs into Docker Hub.
- Builds and pushes the Docker image.
- Deploy to Raspberry Pi:
- Clones the repository if not already present.
- Pulls the latest Docker image.
- Runs the container using
docker-compose
.
The CI/CD workflow configuration can be found in the repository at:
.github/workflows/main.yml
This project is licensed under the MIT License.