Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
98 changes: 49 additions & 49 deletions .github/workflows/deploy_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,53 +10,53 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: frontend/package-lock.json

- name: Install deps (frontend)
working-directory: frontend
run: npm ci

- name: Debug TypeScript config and paths
working-directory: frontend
run: |
npx tsc -p tsconfig.json --showConfig | sed -n '1,200p'
ls -la src/lib || true
grep -R --line-number --color=never "from '@/lib" src || true
- name: Build frontend
working-directory: frontend
run: npm run build

- name: Copy files to server
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.DEV_SERVER_HOST }}
username: ${{ secrets.DEV_SSH_USERNAME }}
key: ${{ secrets.DEV_SSH_PRIVATE_KEY }}
source: "frontend/dist/*"
target: "${{ secrets.DEV_PROJECT_PATH }}/frontend/dist/"

- name: Deploy
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.DEV_SERVER_HOST }}
username: ${{ secrets.DEV_SSH_USERNAME }}
key: ${{ secrets.DEV_SSH_PRIVATE_KEY }}
script: |
cd ${{ secrets.DEV_PROJECT_PATH }}
git pull origin develop
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
cache-dependency-path: frontend/package-lock.json

- name: Install deps (frontend)
working-directory: frontend
run: npm ci

- name: Debug TypeScript config and paths
working-directory: frontend
run: |
npx tsc -p tsconfig.json --showConfig | sed -n '1,200p'
ls -la src/lib || true
grep -R --line-number --color=never "from '@/lib" src || true

- name: Build frontend
working-directory: frontend
run: npm run build

- name: Copy files to server
uses: appleboy/scp-action@v0.1.7
with:
host: ${{ secrets.DEV_SERVER_HOST }}
username: ${{ secrets.DEV_SSH_USERNAME }}
key: ${{ secrets.DEV_SSH_PRIVATE_KEY }}
source: "frontend/dist/*"
target: "${{ secrets.DEV_PROJECT_PATH }}/frontend/dist/"

- name: Deploy
uses: appleboy/ssh-action@v1.0.0
with:
host: ${{ secrets.DEV_SERVER_HOST }}
username: ${{ secrets.DEV_SSH_USERNAME }}
key: ${{ secrets.DEV_SSH_PRIVATE_KEY }}
script: |
cd ${{ secrets.DEV_PROJECT_PATH }}
git pull origin develop

uv sync --no-dev
uv run manage.py migrate

sudo systemctl restart pythonbooks

echo "Deployment successful!"
uv sync --no-dev
uv run manage.py migrate
sudo systemctl restart pythonbooks
echo "Deployment successful!"
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ dist/
downloads/
eggs/
.eggs/
lib/
lib64/
#lib/
#lib64/
parts/
sdist/
var/
Expand Down
41 changes: 41 additions & 0 deletions frontend/src/lib/api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import axios from 'axios';
import type { Book, Publisher, Tag, PaginatedResponse } from '@/types';

const API_BASE_URL = 'http://localhost:8001/api/v1';

const api = axios.create({
baseURL: API_BASE_URL,
headers: {
'Content-Type': 'application/json',
},
});

export const booksApi = {
getBooks: async (params?: {
search?: string;
category?: string;
publisher?: string;
sort?: string;
page?: number;
}): Promise<PaginatedResponse<Book>> => {
const response = await api.get('/books/', { params });
return response.data;
},

getBook: async (id: number): Promise<Book> => {
const response = await api.get(`/books/${id}/`);
return response.data;
},

getPublishers: async (): Promise<Publisher[]> => {
const response = await api.get('/publishers/');
return response.data.results || response.data;
},

getTags: async (): Promise<Tag[]> => {
const response = await api.get('/tags/');
return response.data.results || response.data;
},
};

export default api;
6 changes: 6 additions & 0 deletions frontend/src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { type ClassValue, clsx } from "clsx"
import { twMerge } from "tailwind-merge"

export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}