Skip to content

Commit 460567f

Browse files
committed
update
1 parent 8b619c7 commit 460567f

File tree

5 files changed

+51
-10
lines changed

5 files changed

+51
-10
lines changed

.github/workflows/main.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,5 @@ jobs:
3535
username: 'deploy'
3636
host: '${{ vars.EMPTY_POINT_REMOTE_HOST }}'
3737
key: ${{ secrets.EMPTY_POINT_REMOTE_KEY }}
38-
script: |
39-
cd /home/deploy/empty-point/next-js-app
40-
npm install
41-
npx prisma generate
42-
npx prisma migrate deploy
43-
npm run build
44-
pm2 stop "empty-point"; pm2 delete "empty-point"; pm2 start npm --name "empty-point" -- start
38+
script: "sh /home/deploy/empty-point/start.sh"
4539

fast-api-app/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
@app.get("/hello")
77
async def hello():
8-
return "hello world!"
8+
return 'hello world!'
99

1010

1111
if __name__ == '__main__':

next-js-app/src/app/page.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import axios from "axios";
1+
import http from "@/lib/http";
22

33
export default function Home() {
4-
const hello = axios.get('http://localhost:3000/api/fast-api-app/hello')
4+
const hello = http.get('/api/fast-api-app/hello')
55
.then(response => JSON.stringify(response.data))
66
.catch( error => {
77
console.log(error)

next-js-app/src/lib/http.ts

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import axios from "axios";
2+
3+
const http = axios.create({
4+
baseURL: process.env.BASE_URL,
5+
timeout: 10000
6+
});
7+
8+
http.interceptors.request.use(
9+
config => {
10+
// 处理请求前的逻辑...
11+
12+
return config
13+
},
14+
error => {
15+
// 请求错误处理
16+
17+
return Promise.reject(error)
18+
}
19+
);
20+
21+
http.interceptors.response.use(
22+
response => {
23+
// 处理响应数据
24+
25+
return response
26+
},
27+
error => {
28+
// 处理响应错误
29+
30+
return Promise.reject(error)
31+
}
32+
);
33+
34+
export default http;

start.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
cd /home/deploy/empty-point/fast-api-app
2+
python -m venv ./
3+
source bin/active
4+
pip install -r requirements.txt
5+
pm2 stop "fast-api-app"; pm2 delete "fast-api-app"; pm2 start main.py --name "fast-api-app"
6+
deactive
7+
8+
cd /home/deploy/empty-point/next-js-app
9+
npm install
10+
npx prisma generate
11+
npx prisma migrate deploy
12+
npm run build
13+
pm2 stop "empty-point"; pm2 delete "empty-point"; pm2 start npm --name "empty-point" -- start

0 commit comments

Comments
 (0)