Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init frontend #20

Merged
merged 33 commits into from
Mar 26, 2025
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
a3efba6
hook event v1
Abdelhalim-Zerara Feb 16, 2025
c967ba8
cross-origin quick fix
Abdelhalim-Zerara Feb 16, 2025
8d6db81
hook fix
Abdelhalim-Zerara Feb 16, 2025
2708eb8
ajout certificat
But2ene Feb 16, 2025
fc1e2a5
correct api link
But2ene Feb 16, 2025
bdf7b8e
reduce example to have a working example
But2ene Feb 16, 2025
37cb5bf
interf events list
Feb 24, 2025
b6c3086
header + responsive
Feb 24, 2025
cb19338
routage + debut page accueil SCR4T
Feb 24, 2025
adb2c37
page accueil (manque logo)
Feb 24, 2025
fe7d9c5
ptit trait entre les colonnes du tableaux fixed
Feb 24, 2025
938b2e9
lien logo
Feb 24, 2025
eaef705
fix header details
Feb 24, 2025
e36e118
favicon
Feb 24, 2025
c0241a8
ajout script test automatisé existence fichiers html
But2ene Mar 2, 2025
3fa2437
allow react dev
But2ene Mar 9, 2025
a3ca09a
let front handle paths
But2ene Mar 10, 2025
34cfca1
make functionnal tests again
But2ene Mar 11, 2025
c31cca5
update frontend_dev experience
But2ene Mar 11, 2025
f7cba8d
merge
Mar 11, 2025
8c9abf0
je sais plus
Mar 11, 2025
39b89e5
cors
Mar 11, 2025
760e73a
form ajout event
Mar 12, 2025
d63f319
page about
Mar 12, 2025
b3a4608
improve makefile and doc
But2ene Mar 12, 2025
0ec80b5
review unused code
But2ene Mar 12, 2025
11b1702
delete static file
But2ene Mar 16, 2025
b8655ad
static file from memory only
But2ene Mar 17, 2025
dfe1c87
Merge branch 'main' into eva
But2ene Mar 17, 2025
50915e4
delete debug code
But2ene Mar 17, 2025
ada0e99
take guigui comments into account
But2ene Mar 21, 2025
6a059ea
delete forgotten dependency
But2ene Mar 23, 2025
783d341
add bash script to deploy frontend deploy_frontend_dev
But2ene Mar 23, 2025
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
Prev Previous commit
Next Next commit
delete static file
But2ene committed Mar 16, 2025
commit 11b170269f75a042a9ecda9e2b4c1c75ac2e29a8
10 changes: 9 additions & 1 deletion HACKING.md
Original file line number Diff line number Diff line change
@@ -71,4 +71,12 @@ following command:
make promote
```

Look at curl commands in `tests/api.t/run.t` to design new tests.
Look at curl commands in `tests/api.t/run.t` to design new tests.


Hacks
-----

In vscode, install Ocaml extension to get the button to create sandboxed terminals.

Install `ocp-indent` to format files
20 changes: 13 additions & 7 deletions src/backend/main.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@

(* This file is free software, part of FTW. See file "LICENSE" for more information *)

(* Helper functions *)
(* ************************************************************************* *)

let rec loader _root path _request =
match Static.read path with
| None -> loader _root "index.html" _request
| Some asset -> Dream.respond asset

(* Main entrypoint *)
(* ************************************************************************* *)
@@ -18,8 +25,7 @@ let () =
in
(* Defaul routes to serve the clients files (pages, scripts and css) *)
let default_routes = [
Dream.get "/static/**" @@ Dream.static options.static_path;
Dream.get "**" (Dream.from_filesystem options.static_path "index.html");
Dream.get "/**" (Dream.static ~loader "")
] in
(* Setup the router with the base information for openapi *)
let router =
@@ -47,11 +53,11 @@ let () =
("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
("Access-Control-Allow-Headers", "Content-Type, Authorization");
] ~status:`No_Content ""
| _ ->
let%lwt response = handler request in
Dream.add_header response "Access-Control-Allow-Origin" "*";
Dream.add_header response "Access-Control-Allow-Headers" "Content-Type, Authorization";
Lwt.return response
| _ ->
let%lwt response = handler request in
Dream.add_header response "Access-Control-Allow-Origin" "*";
Dream.add_header response "Access-Control-Allow-Headers" "Content-Type, Authorization";
Lwt.return response
in
(* Setup the dream server and run it *)
Dream.run
11 changes: 3 additions & 8 deletions src/backend/options.ml
Original file line number Diff line number Diff line change
@@ -9,11 +9,10 @@ open Cmdliner
type t = {
db_path : string;
server_port : int;
static_path : string;
}

let mk db_path server_port static_path =
{ db_path; server_port; static_path; }
let mk db_path server_port =
{ db_path; server_port; }

(* Cmdliner term *)
(* ************************************************************************* *)
@@ -27,9 +26,5 @@ let t =
let doc = "Port to listen on" in
Arg.(value & opt int 8080 & info ["p"; "port"] ~doc)
in
let static_path =
let doc = "Static file path to serve" in
Arg.(value & opt string "src/backend/static" & info ["s"; "static"] ~doc)
in
Term.(const mk $ db_path $ port $ static_path)
Term.(const mk $ db_path $ port)

2 changes: 1 addition & 1 deletion tests/api.t/run.t
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ Initialization

Launch the FTW server in the background

$ ftw_backend --db=":memory" --static="../../src/backend/static" > /dev/null 2>&1 &
$ ftw_backend --db=":memory" > /dev/null 2>&1 &

Sleep a bit to ensure that the server had had time to initialize and is ready
to respond to requests
71 changes: 0 additions & 71 deletions tests/routes.t/run.t

This file was deleted.