+1
.envrc
+1
.envrc
···
1
+
use flake
+1
-1
.gitignore
+1
-1
.gitignore
+17
-3
README.org
+17
-3
README.org
···
7
7
8
8
- [[https://hurl.dev][hurl]] :: CLI tool that runs http requests, similar to curl
9
9
- [[https://docs.docker.com/desktop/][docker :: ]] Using docker to run project and mocks
10
+
- [[https://just.systems/][just]] :: CLI runner
10
11
- [[https://jqlang.org/][jq]] :: (Optional) CLI tool to query JSON data
12
+
13
+
If you're using nix, you can find a flake in the root of the project and run =nix develop= to download all the tools (or allow [[https://direnv.net/][direnv]] to auto import in your path)
11
14
12
15
*** Usage
13
16
14
-
Run the project with both providers mocked:
17
+
Run docker compose to start mocks, the mocks will use ports =8002= and =8003= and the were created using [[https://github.com/mrak/stubby4node][stubby4node]]
15
18
16
19
#+begin_src shell
17
20
docker compose up
18
21
#+end_src
19
22
20
-
The docker compose file is configured to build and run 3 dockers, 2 being the mocked providers (Stripe and Braintree), they're both were created using [[https://github.com/mrak/stubby4node][stubby4node]] and the project.
21
-
The main project will use port =8000= in your machine and the providers will use port =8001= and =8002= (this is mostly for running the main project outside docker).
23
+
In another terminal, bulid and run the project with =just=, it will start the project in port =8000=
24
+
25
+
#+begin_src shell
26
+
just run
27
+
#+end_src
22
28
23
29
In other terminal, make the request with hurl
24
30
···
31
37
#+begin_src shell
32
38
hurl request.hurl | jq .
33
39
#+end_src
40
+
41
+
** Tests
42
+
43
+
To run all tests, you can run the command that it will run all tests from the project:
44
+
45
+
#+begin_src shell
46
+
just test
47
+
#+end_src
+61
flake.lock
+61
flake.lock
···
1
+
{
2
+
"nodes": {
3
+
"flake-utils": {
4
+
"inputs": {
5
+
"systems": "systems"
6
+
},
7
+
"locked": {
8
+
"lastModified": 1731533236,
9
+
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
10
+
"owner": "numtide",
11
+
"repo": "flake-utils",
12
+
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
13
+
"type": "github"
14
+
},
15
+
"original": {
16
+
"owner": "numtide",
17
+
"repo": "flake-utils",
18
+
"type": "github"
19
+
}
20
+
},
21
+
"nixpkgs": {
22
+
"locked": {
23
+
"lastModified": 1752012998,
24
+
"narHash": "sha256-Q82Ms+FQmgOBkdoSVm+FBpuFoeUAffNerR5yVV7SgT8=",
25
+
"owner": "NixOS",
26
+
"repo": "nixpkgs",
27
+
"rev": "2a2130494ad647f953593c4e84ea4df839fbd68c",
28
+
"type": "github"
29
+
},
30
+
"original": {
31
+
"owner": "NixOS",
32
+
"ref": "nixpkgs-unstable",
33
+
"repo": "nixpkgs",
34
+
"type": "github"
35
+
}
36
+
},
37
+
"root": {
38
+
"inputs": {
39
+
"flake-utils": "flake-utils",
40
+
"nixpkgs": "nixpkgs"
41
+
}
42
+
},
43
+
"systems": {
44
+
"locked": {
45
+
"lastModified": 1681028828,
46
+
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
47
+
"owner": "nix-systems",
48
+
"repo": "default",
49
+
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
50
+
"type": "github"
51
+
},
52
+
"original": {
53
+
"owner": "nix-systems",
54
+
"repo": "default",
55
+
"type": "github"
56
+
}
57
+
}
58
+
},
59
+
"root": "root",
60
+
"version": 7
61
+
}
+28
flake.nix
+28
flake.nix
···
1
+
{
2
+
description = "A Nix-flake-based Golang development environment";
3
+
4
+
inputs = {
5
+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
6
+
7
+
flake-utils.url = "github:numtide/flake-utils";
8
+
};
9
+
10
+
outputs = { self, nixpkgs, flake-utils }:
11
+
flake-utils.lib.eachDefaultSystem (system:
12
+
let
13
+
inherit (pkgs.lib) optional optionals;
14
+
15
+
pkgs = import nixpkgs { inherit system; };
16
+
in
17
+
{
18
+
devShells.default = pkgs.mkShell {
19
+
buildInputs = with pkgs; [
20
+
go
21
+
hurl
22
+
just
23
+
jq
24
+
];
25
+
};
26
+
}
27
+
);
28
+
}