mirror of
https://github.com/YunoHost-Apps/crabfit_ynh.git
synced 2024-09-03 18:16:21 +02:00
Properly modify the upstream code using patches
(thanks to @oiseauroch <3)
This commit is contained in:
parent
a2bdb00b08
commit
0e4e6fb6b8
5 changed files with 77 additions and 5 deletions
|
@ -1,2 +1,3 @@
|
|||
FRONTEND_URL=https://__DOMAIN__/
|
||||
DATABASE_URL=postgres://__DB_USER__:__DB_PWD__@localhost:5432/__DB_NAME__
|
||||
PORT=__PORT_API__
|
||||
|
|
|
@ -15,11 +15,6 @@ function build_backend
|
|||
# The cargo version packaged with debian (currently 11) is too old and results in errors..
|
||||
# Thus the latest version is manually installed alongside the application for the moment
|
||||
pushd $install_dir/api
|
||||
# The API port is currently hard-coded instead of being in a .env
|
||||
# TODO: MR to the upstream
|
||||
# In the meantime, lets do some sed!
|
||||
sed -i "s/3000/$port_api/g" src/main.rs
|
||||
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rustup.sh
|
||||
ynh_exec_warn_less ynh_exec_as "$app" \
|
||||
RUSTUP_HOME=$install_dir/api/.rustup \
|
||||
|
|
23
sources/patches/main-backend_get_port_by_env.patch
Normal file
23
sources/patches/main-backend_get_port_by_env.patch
Normal file
|
@ -0,0 +1,23 @@
|
|||
diff --git a/api/src/main.rs b/api/src/main.rs
|
||||
index da3e2c3..3ebd00e 100644
|
||||
--- a/api/src/main.rs
|
||||
+++ b/api/src/main.rs
|
||||
@@ -60,6 +60,9 @@ async fn main() {
|
||||
.unwrap(),
|
||||
);
|
||||
|
||||
+ let port = env::var("PORT").unwrap_or("3000".to_string());
|
||||
+ let port = port.parse::<u16>().expect("Unable to parse port");
|
||||
+
|
||||
// Rate limiting configuration (using tower_governor)
|
||||
// From the docs: Allows bursts with up to 20 requests and replenishes
|
||||
// one element after 500ms, based on peer IP.
|
||||
@@ -99,7 +102,7 @@ async fn main() {
|
||||
.layer(rate_limit)
|
||||
.layer(TraceLayer::new_for_http());
|
||||
|
||||
- let addr = SocketAddr::from(([0, 0, 0, 0], 3000));
|
||||
+ let addr = SocketAddr::from(([0, 0, 0, 0], port));
|
||||
|
||||
println!(
|
||||
"🦀 Crab Fit API listening at http://{} in {} mode",
|
|
@ -0,0 +1,22 @@
|
|||
diff --git a/frontend/src/config/api.ts b/frontend/src/config/api.ts
|
||||
index 312b092..6c11328 100644
|
||||
--- a/frontend/src/config/api.ts
|
||||
+++ b/frontend/src/config/api.ts
|
||||
@@ -70,11 +70,11 @@ const post = async <S extends z.Schema>(url: string, schema: S, input: unknown,
|
||||
}
|
||||
|
||||
// Get
|
||||
-export const getStats = () => get('/stats', StatsResponse, undefined, { revalidate: 60 })
|
||||
-export const getEvent = (eventId: string) => get(`/event/${eventId}`, EventResponse)
|
||||
-export const getPeople = (eventId: string) => get(`/event/${eventId}/people`, PersonResponse.array())
|
||||
-export const getPerson = (eventId: string, personName: string, password?: string) => get(`/event/${eventId}/people/${personName}`, PersonResponse, password && btoa(password))
|
||||
+export const getStats = () => get('stats', StatsResponse, undefined, { revalidate: 60 })
|
||||
+export const getEvent = (eventId: string) => get(`event/${eventId}`, EventResponse)
|
||||
+export const getPeople = (eventId: string) => get(`event/${eventId}/people`, PersonResponse.array())
|
||||
+export const getPerson = (eventId: string, personName: string, password?: string) => get(`event/${eventId}/people/${personName}`, PersonResponse, password && btoa(password))
|
||||
|
||||
// Post
|
||||
-export const createEvent = (input: EventInput) => post('/event', EventResponse, EventInput.parse(input))
|
||||
-export const updatePerson = (eventId: string, personName: string, input: PersonInput, password?: string) => post(`/event/${eventId}/people/${personName}`, PersonResponse, PersonInput.parse(input), password && btoa(password), 'PATCH')
|
||||
+export const createEvent = (input: EventInput) => post('event', EventResponse, EventInput.parse(input))
|
||||
+export const updatePerson = (eventId: string, personName: string, input: PersonInput, password?: string) => post(`event/${eventId}/people/${personName}`, PersonResponse, PersonInput.parse(input), password && btoa(password), 'PATCH')
|
31
sources/patches/main-remove_vercel_analytics.patch
Normal file
31
sources/patches/main-remove_vercel_analytics.patch
Normal file
|
@ -0,0 +1,31 @@
|
|||
diff --git a/frontend/package.json b/frontend/package.json
|
||||
index 486af7a..4537034 100644
|
||||
--- a/frontend/package.json
|
||||
+++ b/frontend/package.json
|
||||
@@ -15,7 +15,6 @@
|
||||
"@giraugh/tools": "^1.6.0",
|
||||
"@js-temporal/polyfill": "^0.4.4",
|
||||
"@microsoft/microsoft-graph-client": "^3.0.5",
|
||||
- "@vercel/analytics": "^1.0.1",
|
||||
"accept-language": "^3.0.18",
|
||||
"chroma.ts": "^1.0.10",
|
||||
"hue-map": "^1.0.0",
|
||||
diff --git a/frontend/src/app/layout.tsx b/frontend/src/app/layout.tsx
|
||||
index d4c1466..83a99c0 100644
|
||||
--- a/frontend/src/app/layout.tsx
|
||||
+++ b/frontend/src/app/layout.tsx
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Metadata } from 'next'
|
||||
import { Karla } from 'next/font/google'
|
||||
-import { Analytics } from '@vercel/analytics/react'
|
||||
|
||||
import Egg from '/src/components/Egg/Egg'
|
||||
import Settings from '/src/components/Settings/Settings'
|
||||
@@ -44,7 +43,6 @@ const RootLayout = async ({ children }: { children: React.ReactNode }) => {
|
||||
|
||||
{children}
|
||||
|
||||
- <Analytics />
|
||||
</body>
|
||||
</html>
|
||||
}
|
Loading…
Reference in a new issue