From 7f06794dc2f55a8c4be5c08fa344c83b8d099c38 Mon Sep 17 00:00:00 2001
From: CronyAkatsuki <crony@cronyakatsuki.xyz>
Date: Thu, 21 Dec 2023 17:28:09 +0100
Subject: [PATCH 01/16] Update curl links

---
 README.md | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 0f6ac27..fd961b0 100644
--- a/README.md
+++ b/README.md
@@ -31,7 +31,8 @@ chmod 700 /usr/local/upfast
 su upfast
 # go to upfast's user's home and curl the upfast binary
 cd ~
-curl -O binary
+curl -O https://code.cronyakatsuki.xyz/crony/UpFast/releases/download/v1.0/upfast
+chmod +x upfast
 ```
 
 ## Updating
@@ -41,7 +42,7 @@ When new update of upfast come's out all you will need to change to upfast user
 ```bash
 su upfast
 cd ~
-curl -O binary
+curl -O https://code.cronyakatsuki.xyz/crony/UpFast/releases/download/v1.0/upfast
 ```
 
 ## Startup automaticallly on system restart

From 21dc8f1fa1df973f00bada3a0cace10642c67d1a Mon Sep 17 00:00:00 2001
From: CronyAkatsuki <crony@cronyakatsuki.xyz>
Date: Thu, 21 Dec 2023 18:31:50 +0100
Subject: [PATCH 02/16] Add domain cli option.

---
 main.go | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/main.go b/main.go
index 325ed15..009e281 100644
--- a/main.go
+++ b/main.go
@@ -22,16 +22,21 @@ var templates embed.FS
 //go:embed all:static/*
 var static embed.FS
 
+var domain string
+
 func main() {
 	t := &Template{
 		templates: template.Must(template.ParseFS(templates, "public/views/*.html")),
 	}
 
-	port := flag.Int("p", 1323, "upfast port to listen on.")
-	adress := flag.String("a", "127.0.0.1", "upfast ip to listen to")
+	p := flag.Int("p", 1323, "upfast port to listen on.")
+	a := flag.String("a", "127.0.0.1", "upfast ip to listen to")
+	d := flag.String("d", "127.0.0.1", "upfast domain")
 	flag.Parse()
 
-	host := *adress + ":" + strconv.Itoa(*port)
+	host := *a + ":" + strconv.Itoa(*p)
+
+	domain = *d
 
 	e := echo.New()
 
@@ -91,7 +96,7 @@ func (t *Template) Render(w io.Writer, name string, data interface{}, c echo.Con
 
 func Index(c echo.Context) error {
 	data := IndexData{
-		Host: c.Request().Host,
+		Host: domain,
 	}
 	return c.Render(http.StatusOK, "index", data)
 }
@@ -191,7 +196,7 @@ func Upload(c echo.Context) error {
 		return err
 	}
 
-	fileUrl := c.Request().Host + "/files/" + file.Filename + "\n"
+	fileUrl := domain + "/files/" + file.Filename + "\n"
 
 	UserAgent := c.Request().UserAgent()
 

From 82cca8084f3d6b88f23d3702a724d44aef9bdf45 Mon Sep 17 00:00:00 2001
From: CronyAkatsuki <crony@cronyakatsuki.xyz>
Date: Thu, 21 Dec 2023 18:33:53 +0100
Subject: [PATCH 03/16] Document new option.

---
 README.md | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index fd961b0..9133956 100644
--- a/README.md
+++ b/README.md
@@ -6,10 +6,12 @@ This one is gonna be a lot easier to deploy since all you need to do is download
 
 To change the port or the ip adress to listen for you can use `-p` and `-a` options respectivelly.
 
+There is alse the `-d` option that will set what domain name upfast will return when returning the file path when uploaded.
+
 > example
 
 ```bash
-./upfast -p 8080 -a 0.0.0.0
+./upfast -p 8080 -a 0.0.0.0 -d https://upfast.cronyakatsuki.xyz
 ```
 
 By default upfast listen's on 127.0.0.1 adress so if you wan't to access it outside your network you will either need to listen to 0.0.0.0 or use a reverse proxy. I recommend the usage of a reverse proxy.
@@ -60,14 +62,14 @@ Documentation=https://code.cronyakatsuki.xyz/crony/upfast
 User=upfast
 Group=upfast
 WorkingDirectory=/usr/local/upfast/
-ExecStart=/usr/local/upfast/upfast -p 8000 -a 127.0.0.1
+ExecStart=/usr/local/upfast/upfast -p 8000 -a 127.0.0.1 -d https://upfast.cronyakatsuki.xyz
 Restart=on-failure
 
 [Install]
 WantedBy=multi-user.target
 ```
 
-Remember to change the port if you need to or the listening adress.
+Remember to change the port if you need to, the listening adress and the domain name.
 
 After that run `systemctl daemon-reload` as root or with sudo.
 

From 61e20c9b06f2878f8dcb2450c8fe8a4f6b2e2cc1 Mon Sep 17 00:00:00 2001
From: CronyAkatsuki <crony@cronyakatsuki.xyz>
Date: Thu, 21 Dec 2023 18:37:16 +0100
Subject: [PATCH 04/16] Update curl links

---
 README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 9133956..4507545 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@ chmod 700 /usr/local/upfast
 su upfast
 # go to upfast's user's home and curl the upfast binary
 cd ~
-curl -O https://code.cronyakatsuki.xyz/crony/UpFast/releases/download/v1.0/upfast
+curl -O https://code.cronyakatsuki.xyz/crony/UpFast/releases/download/v1.1/upfast
 chmod +x upfast
 ```
 
@@ -44,7 +44,7 @@ When new update of upfast come's out all you will need to change to upfast user
 ```bash
 su upfast
 cd ~
-curl -O https://code.cronyakatsuki.xyz/crony/UpFast/releases/download/v1.0/upfast
+curl -O https://code.cronyakatsuki.xyz/crony/UpFast/releases/download/v1.1/upfast
 ```
 
 ## Startup automaticallly on system restart

From fc098ec7c6749c00ac5fca611985ea52043d1b32 Mon Sep 17 00:00:00 2001
From: CronyAkatsuki <crony@cronyakatsuki.xyz>
Date: Sat, 6 Jan 2024 20:29:32 +0100
Subject: [PATCH 05/16] Update the readme with a more secure installation
 guide.

---
 README.md | 52 +++++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 41 insertions(+), 11 deletions(-)

diff --git a/README.md b/README.md
index 4507545..f60c66c 100644
--- a/README.md
+++ b/README.md
@@ -22,20 +22,50 @@ You will need to rename the `upload` folder to `files`, since I changed the nami
 
 ## Installation
 
-```bash
-# Create upfast user and home directory
-useradd --shell /bin/sh --system --home-dir /usr/local/upfast upfast
-mkdir -p /usr/local/upfast # dodge copying of skeletons
-chown upfast:upfast /usr/local/upfast
-chmod 700 /usr/local/upfast
+This installation step's will also harden our installation and limit the size of how much can be uploaded at the same time so your system can't be flooded.
 
-# change to upfast user
-su upfast
-# go to upfast's user's home and curl the upfast binary
-cd ~
+### Creating user
+```bash
+# Create upfast user with no login shell, no home directory and as a system user
+useradd --shell /usr/sbin/nologin --system -M upfast
+# Resctrict login to upfast user
+usermod -L upfast
+```
+
+### Creating virtual filesystem
+
+This is done in order to limit the amount of storage the upfast installation, so people can't storage dos you.
+
+
+Creating virtual filesystem to limit amount people can upload like chad's, using dd to create an empty file of size you choose.
+
+Change the size output file to whatever you wan't and size to whatever you wan't.
+``` bash
+# make sure to first change into a directory where you wan't to save the virtual filesystem
+dd if=/dev/zero of=20gb bs=1M count=20480
+# make that file into a filesystem
+mkfs.ext4 20gb
+# create directory to mount the filesystem, I recommend /usr/local/upfast because that's where the included systemd service looks for upfast binary
+mkdir /usr/local/upfast
+# mounting the filesystem
+mount -o loop,rw /home/ivek/20gb /usr/local/upfast
+```
+Now to make it mount on system reboot we need to add this line to fstab.
+``` fstab
+/home/amir/mydatafile /usr/local/upfast ext4 loop,rw,usrquota,grpquota 0 0
+```
+### Downloading the binary
+```bash
+# go to upfast's user's home and curl the upfast binary, make sure to run the next command's as root
+cd /usr/local/upfast
 curl -O https://code.cronyakatsuki.xyz/crony/UpFast/releases/download/v1.1/upfast
 chmod +x upfast
 ```
+```bash
+# Own the directory with upfast user and group
+chown upfast:upfast -R /usr/local/upfast
+chmod 700 /usr/local/upfast
+```
 
 ## Updating
 
@@ -43,7 +73,7 @@ When new update of upfast come's out all you will need to change to upfast user
 
 ```bash
 su upfast
-cd ~
+cd /usr/local/upfast
 curl -O https://code.cronyakatsuki.xyz/crony/UpFast/releases/download/v1.1/upfast
 ```
 

From 7365240e35b90b2f0709b789ba96af8a322b2a68 Mon Sep 17 00:00:00 2001
From: CronyAkatsuki <crony@cronyakatsuki.xyz>
Date: Sat, 6 Jan 2024 20:39:02 +0100
Subject: [PATCH 06/16] Remove redirect for security reasons.

---
 main.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main.go b/main.go
index 009e281..8c0f7fb 100644
--- a/main.go
+++ b/main.go
@@ -211,7 +211,7 @@ func Upload(c echo.Context) error {
 		return c.String(http.StatusOK, fileUrl)
 	}
 
-	return c.Redirect(http.StatusMovedPermanently, "/files/"+file.Filename)
+    return c.HTML(http.StatusOK, "File uploaded at url: <strong>" + fileUrl + "</strong>")
 }
 
 func Delete(c echo.Context) error {

From f914d57a7490f30426884a58e15ad8502589ed47 Mon Sep 17 00:00:00 2001
From: CronyAkatsuki <crony@cronyakatsuki.xyz>
Date: Sat, 6 Jan 2024 20:49:11 +0100
Subject: [PATCH 07/16] Update links.

---
 README.md | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index f60c66c..d495426 100644
--- a/README.md
+++ b/README.md
@@ -58,7 +58,7 @@ Now to make it mount on system reboot we need to add this line to fstab.
 ```bash
 # go to upfast's user's home and curl the upfast binary, make sure to run the next command's as root
 cd /usr/local/upfast
-curl -O https://code.cronyakatsuki.xyz/crony/UpFast/releases/download/v1.1/upfast
+curl -O https://code.cronyakatsuki.xyz/crony/UpFast/releases/download/v1.2/upfast
 chmod +x upfast
 ```
 ```bash
@@ -74,7 +74,7 @@ When new update of upfast come's out all you will need to change to upfast user
 ```bash
 su upfast
 cd /usr/local/upfast
-curl -O https://code.cronyakatsuki.xyz/crony/UpFast/releases/download/v1.1/upfast
+curl -O https://code.cronyakatsuki.xyz/crony/UpFast/releases/download/v1.2/upfast
 ```
 
 ## Startup automaticallly on system restart

From b87a56623b6a70a8f26d056a6d38bab052595773 Mon Sep 17 00:00:00 2001
From: Crony Akatsuki <crony@cronyakatsuki.xyz>
Date: Sun, 3 Mar 2024 11:02:29 +0100
Subject: [PATCH 08/16] Wrap it in a flake with a great tool.

---
 .gitignore     |  1 +
 default.nix    | 21 +++++++++++++
 flake.lock     | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++
 flake.nix      | 29 +++++++++++++++++
 gomod2nix.toml | 39 +++++++++++++++++++++++
 shell.nix      | 24 ++++++++++++++
 6 files changed, 199 insertions(+)
 create mode 100644 default.nix
 create mode 100644 flake.lock
 create mode 100644 flake.nix
 create mode 100644 gomod2nix.toml
 create mode 100644 shell.nix

diff --git a/.gitignore b/.gitignore
index ec996f1..6c731b7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,4 @@ upload
 env
 .env
 files
+/gomod2nix-template
diff --git a/default.nix b/default.nix
new file mode 100644
index 0000000..3e255e3
--- /dev/null
+++ b/default.nix
@@ -0,0 +1,21 @@
+{ pkgs ? (
+    let
+      inherit (builtins) fetchTree fromJSON readFile;
+      inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix;
+    in
+    import (fetchTree nixpkgs.locked) {
+      overlays = [
+        (import "${fetchTree gomod2nix.locked}/overlay.nix")
+      ];
+    }
+  )
+, buildGoApplication ? pkgs.buildGoApplication
+}:
+
+buildGoApplication {
+  pname = "upfast";
+  version = "0.1";
+  pwd = ./.;
+  src = ./.;
+  modules = ./gomod2nix.toml;
+}
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..f5b7a74
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,85 @@
+{
+  "nodes": {
+    "flake-utils": {
+      "inputs": {
+        "systems": "systems"
+      },
+      "locked": {
+        "lastModified": 1709126324,
+        "narHash": "sha256-q6EQdSeUZOG26WelxqkmR7kArjgWCdw5sfJVHPH/7j8=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "d465f4819400de7c8d874d50b982301f28a84605",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    },
+    "gomod2nix": {
+      "inputs": {
+        "flake-utils": [
+          "flake-utils"
+        ],
+        "nixpkgs": [
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1705314449,
+        "narHash": "sha256-yfQQ67dLejP0FLK76LKHbkzcQqNIrux6MFe32MMFGNQ=",
+        "owner": "nix-community",
+        "repo": "gomod2nix",
+        "rev": "30e3c3a9ec4ac8453282ca7f67fca9e1da12c3e6",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-community",
+        "repo": "gomod2nix",
+        "type": "github"
+      }
+    },
+    "nixpkgs": {
+      "locked": {
+        "lastModified": 1709237383,
+        "narHash": "sha256-cy6ArO4k5qTx+l5o+0mL9f5fa86tYUX3ozE1S+Txlds=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "1536926ef5621b09bba54035ae2bb6d806d72ac8",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "nixos-unstable",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "root": {
+      "inputs": {
+        "flake-utils": "flake-utils",
+        "gomod2nix": "gomod2nix",
+        "nixpkgs": "nixpkgs"
+      }
+    },
+    "systems": {
+      "locked": {
+        "lastModified": 1681028828,
+        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+        "owner": "nix-systems",
+        "repo": "default",
+        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-systems",
+        "repo": "default",
+        "type": "github"
+      }
+    }
+  },
+  "root": "root",
+  "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..1d8de62
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,29 @@
+{
+  description = "A basic gomod2nix flake";
+
+  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
+  inputs.flake-utils.url = "github:numtide/flake-utils";
+  inputs.gomod2nix.url = "github:nix-community/gomod2nix";
+  inputs.gomod2nix.inputs.nixpkgs.follows = "nixpkgs";
+  inputs.gomod2nix.inputs.flake-utils.follows = "flake-utils";
+
+  outputs = { self, nixpkgs, flake-utils, gomod2nix }:
+    (flake-utils.lib.eachDefaultSystem
+      (system:
+        let
+          pkgs = nixpkgs.legacyPackages.${system};
+
+          # The current default sdk for macOS fails to compile go projects, so we use a newer one for now.
+          # This has no effect on other platforms.
+          callPackage = pkgs.darwin.apple_sdk_11_0.callPackage or pkgs.callPackage;
+        in
+        {
+          packages.default = callPackage ./. {
+            inherit (gomod2nix.legacyPackages.${system}) buildGoApplication;
+          };
+          devShells.default = callPackage ./shell.nix {
+            inherit (gomod2nix.legacyPackages.${system}) mkGoEnv gomod2nix;
+          };
+        })
+    );
+}
diff --git a/gomod2nix.toml b/gomod2nix.toml
new file mode 100644
index 0000000..08676c7
--- /dev/null
+++ b/gomod2nix.toml
@@ -0,0 +1,39 @@
+schema = 3
+
+[mod]
+  [mod."github.com/golang-jwt/jwt"]
+    version = "v3.2.2+incompatible"
+    hash = "sha256-LOkpuXhWrFayvVf1GOaOmZI5YKEsgqVSb22aF8LnCEM="
+  [mod."github.com/labstack/echo/v4"]
+    version = "v4.11.3"
+    hash = "sha256-rdqH4HQB/vZyEsoymrEsQ8izjf0m7jhrIxbF6r5ZmBo="
+  [mod."github.com/labstack/gommon"]
+    version = "v0.4.0"
+    hash = "sha256-xISAIJEu2xh0hoWsORbgjnz3rDK3ft3hrvmxt0wfHVw="
+  [mod."github.com/mattn/go-colorable"]
+    version = "v0.1.13"
+    hash = "sha256-qb3Qbo0CELGRIzvw7NVM1g/aayaz4Tguppk9MD2/OI8="
+  [mod."github.com/mattn/go-isatty"]
+    version = "v0.0.19"
+    hash = "sha256-wYQqGxeqV3Elkmn26Md8mKZ/viw598R4Ych3vtt72YE="
+  [mod."github.com/valyala/bytebufferpool"]
+    version = "v1.0.0"
+    hash = "sha256-I9FPZ3kCNRB+o0dpMwBnwZ35Fj9+ThvITn8a3Jr8mAY="
+  [mod."github.com/valyala/fasttemplate"]
+    version = "v1.2.2"
+    hash = "sha256-gp+lNXE8zjO+qJDM/YbS6V43HFsYP6PKn4ux1qa5lZ0="
+  [mod."golang.org/x/crypto"]
+    version = "v0.14.0"
+    hash = "sha256-UUSt3X/i34r1K0mU+Y5IzljX5HYy07JcHh39Pm1MU+o="
+  [mod."golang.org/x/net"]
+    version = "v0.17.0"
+    hash = "sha256-qRawHWLSsJ06QNbLhUWPXGVSO1eaioeC9xZlUEWN8J8="
+  [mod."golang.org/x/sys"]
+    version = "v0.13.0"
+    hash = "sha256-/+RDZ0a0oEfJ0k304VqpJpdrl2ZXa3yFlOxy4mjW7w0="
+  [mod."golang.org/x/text"]
+    version = "v0.13.0"
+    hash = "sha256-J34dbc8UNVIdRJUZP7jPt11oxuwG8VvrOOylxE7V3oA="
+  [mod."golang.org/x/time"]
+    version = "v0.3.0"
+    hash = "sha256-/hmc9skIswMYbivxNS7R8A6vCTUF9k2/7tr/ACkcEaM="
diff --git a/shell.nix b/shell.nix
new file mode 100644
index 0000000..d4f21a8
--- /dev/null
+++ b/shell.nix
@@ -0,0 +1,24 @@
+{ pkgs ? (
+    let
+      inherit (builtins) fetchTree fromJSON readFile;
+      inherit ((fromJSON (readFile ./flake.lock)).nodes) nixpkgs gomod2nix;
+    in
+    import (fetchTree nixpkgs.locked) {
+      overlays = [
+        (import "${fetchTree gomod2nix.locked}/overlay.nix")
+      ];
+    }
+  )
+, mkGoEnv ? pkgs.mkGoEnv
+, gomod2nix ? pkgs.gomod2nix
+}:
+
+let
+  goEnv = mkGoEnv { pwd = ./.; };
+in
+pkgs.mkShell {
+  packages = [
+    goEnv
+    gomod2nix
+  ];
+}

From 821c0c91c8085ff38acfad86feb91fd5cd90376f Mon Sep 17 00:00:00 2001
From: Crony Akatsuki <crony@cronyakatsuki.xyz>
Date: Sun, 3 Mar 2024 11:18:28 +0100
Subject: [PATCH 09/16] Fix regex.

---
 main.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main.go b/main.go
index 8c0f7fb..73241ac 100644
--- a/main.go
+++ b/main.go
@@ -128,7 +128,7 @@ func Files(c echo.Context) error {
 	ImageMatch := regexp.MustCompile("^image/.*")
 	VideoMatch := regexp.MustCompile("^video/.*")
 	JsonMatch := regexp.MustCompile("application/json")
-	TextMatch := regexp.MustCompile("^text/.*|application/octet-stream")
+	TextMatch := regexp.MustCompile("^text/.*")
 
 	for _, f := range filelist {
 		filePath := "files/" + f.Name()

From 9d9acbe7d345cf6d49ddb26cc9d4a3c09fa64550 Mon Sep 17 00:00:00 2001
From: Crony Akatsuki <crony@cronyakatsuki.xyz>
Date: Sun, 3 Mar 2024 11:24:30 +0100
Subject: [PATCH 10/16] Print file names when curling /files/ path.

---
 main.go | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/main.go b/main.go
index 73241ac..af75509 100644
--- a/main.go
+++ b/main.go
@@ -122,6 +122,23 @@ func Files(c echo.Context) error {
 		log.Fatal(err)
 	}
 
+	UserAgent := c.Request().UserAgent()
+
+	log.Print(UserAgent)
+
+	match, err := regexp.MatchString("^curl/.*", UserAgent)
+	if err != nil {
+		log.Fatal(err)
+	}
+
+	if match {
+        out := ""
+        for _, f := range filelist {
+            out += f.Name() + "\n"
+        }
+		return c.String(http.StatusOK, out)
+	}
+
 	var Type string
 	var Content string
 

From fc73213a6c10fc2cdb134a0eadbf259f18f42333 Mon Sep 17 00:00:00 2001
From: Crony Akatsuki <crony@cronyakatsuki.xyz>
Date: Sun, 3 Mar 2024 12:07:46 +0100
Subject: [PATCH 11/16] Update version.

---
 default.nix | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/default.nix b/default.nix
index 3e255e3..0f78549 100644
--- a/default.nix
+++ b/default.nix
@@ -14,7 +14,7 @@
 
 buildGoApplication {
   pname = "upfast";
-  version = "0.1";
+  version = "1.3";
   pwd = ./.;
   src = ./.;
   modules = ./gomod2nix.toml;

From f5b1e6b77dfa58946e935d13d61aa4a7d68f11bd Mon Sep 17 00:00:00 2001
From: Crony Akatsuki <crony@cronyakatsuki.xyz>
Date: Thu, 7 Mar 2024 18:40:34 +0100
Subject: [PATCH 12/16] Add direnv files to .gitignore

---
 .gitignore | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.gitignore b/.gitignore
index 6c731b7..62ed374 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,5 @@ env
 .env
 files
 /gomod2nix-template
+.direnv
+.envrc

From a54ca0623a268712727965662bb8674999bae603 Mon Sep 17 00:00:00 2001
From: Crony Akatsuki <crony@cronyakatsuki.xyz>
Date: Thu, 7 Mar 2024 18:42:20 +0100
Subject: [PATCH 13/16] Remove .envrc from .gitignore

---
 .envrc     | 1 +
 .gitignore | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)
 create mode 100644 .envrc

diff --git a/.envrc b/.envrc
new file mode 100644
index 0000000..1d953f4
--- /dev/null
+++ b/.envrc
@@ -0,0 +1 @@
+use nix
diff --git a/.gitignore b/.gitignore
index 62ed374..369bee7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,3 @@ env
 files
 /gomod2nix-template
 .direnv
-.envrc

From 0b97c205c53e10ac83d8aed91ae2bdaaaaaff21b Mon Sep 17 00:00:00 2001
From: Crony Akatsuki <crony@cronyakatsuki.xyz>
Date: Thu, 7 Mar 2024 19:50:22 +0100
Subject: [PATCH 14/16] Use nix-direnv flake support.

---
 .envrc | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/.envrc b/.envrc
index 1d953f4..5d16c7a 100644
--- a/.envrc
+++ b/.envrc
@@ -1 +1,2 @@
-use nix
+watch_file default.nix shell.nix
+use flake

From 34270dfea0d561a5bf82fa9b8381587650ed20b1 Mon Sep 17 00:00:00 2001
From: Crony Akatsuki <crony@cronyakatsuki.xyz>
Date: Sat, 16 Mar 2024 18:34:49 +0100
Subject: [PATCH 15/16] Update formatting.

---
 main.go | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/main.go b/main.go
index af75509..f506920 100644
--- a/main.go
+++ b/main.go
@@ -132,10 +132,10 @@ func Files(c echo.Context) error {
 	}
 
 	if match {
-        out := ""
-        for _, f := range filelist {
-            out += f.Name() + "\n"
-        }
+		out := ""
+		for _, f := range filelist {
+			out += f.Name() + "\n"
+		}
 		return c.String(http.StatusOK, out)
 	}
 
@@ -228,7 +228,7 @@ func Upload(c echo.Context) error {
 		return c.String(http.StatusOK, fileUrl)
 	}
 
-    return c.HTML(http.StatusOK, "File uploaded at url: <strong>" + fileUrl + "</strong>")
+	return c.HTML(http.StatusOK, "File uploaded at url: <strong>"+fileUrl+"</strong>")
 }
 
 func Delete(c echo.Context) error {

From 37f1c553b419cfb2d69e12ffd66f501b34805170 Mon Sep 17 00:00:00 2001
From: Crony Akatsuki <crony@cronyakatsuki.xyz>
Date: Sun, 17 Mar 2024 15:06:04 +0100
Subject: [PATCH 16/16] Add pre-commit gofmt hook.

---
 .gitignore |   1 +
 flake.lock | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 flake.nix  |   4 +-
 shell.nix  |   8 ++++
 4 files changed, 138 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index 369bee7..3122962 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@ env
 files
 /gomod2nix-template
 .direnv
+.pre-commit-config.yaml
diff --git a/flake.lock b/flake.lock
index f5b7a74..539a3b7 100644
--- a/flake.lock
+++ b/flake.lock
@@ -1,5 +1,21 @@
 {
   "nodes": {
+    "flake-compat": {
+      "flake": false,
+      "locked": {
+        "lastModified": 1696426674,
+        "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
+        "owner": "edolstra",
+        "repo": "flake-compat",
+        "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
+        "type": "github"
+      },
+      "original": {
+        "owner": "edolstra",
+        "repo": "flake-compat",
+        "type": "github"
+      }
+    },
     "flake-utils": {
       "inputs": {
         "systems": "systems"
@@ -18,6 +34,45 @@
         "type": "github"
       }
     },
+    "flake-utils_2": {
+      "inputs": {
+        "systems": "systems_2"
+      },
+      "locked": {
+        "lastModified": 1701680307,
+        "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
+        "type": "github"
+      },
+      "original": {
+        "owner": "numtide",
+        "repo": "flake-utils",
+        "type": "github"
+      }
+    },
+    "gitignore": {
+      "inputs": {
+        "nixpkgs": [
+          "pre-commit-hooks",
+          "nixpkgs"
+        ]
+      },
+      "locked": {
+        "lastModified": 1703887061,
+        "narHash": "sha256-gGPa9qWNc6eCXT/+Z5/zMkyYOuRZqeFZBDbopNZQkuY=",
+        "owner": "hercules-ci",
+        "repo": "gitignore.nix",
+        "rev": "43e1aa1308018f37118e34d3a9cb4f5e75dc11d5",
+        "type": "github"
+      },
+      "original": {
+        "owner": "hercules-ci",
+        "repo": "gitignore.nix",
+        "type": "github"
+      }
+    },
     "gomod2nix": {
       "inputs": {
         "flake-utils": [
@@ -57,11 +112,66 @@
         "type": "github"
       }
     },
+    "nixpkgs-stable": {
+      "locked": {
+        "lastModified": 1704874635,
+        "narHash": "sha256-YWuCrtsty5vVZvu+7BchAxmcYzTMfolSPP5io8+WYCg=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "3dc440faeee9e889fe2d1b4d25ad0f430d449356",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "nixos-23.11",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "nixpkgs_2": {
+      "locked": {
+        "lastModified": 1704842529,
+        "narHash": "sha256-OTeQA+F8d/Evad33JMfuXC89VMetQbsU4qcaePchGr4=",
+        "owner": "NixOS",
+        "repo": "nixpkgs",
+        "rev": "eabe8d3eface69f5bb16c18f8662a702f50c20d5",
+        "type": "github"
+      },
+      "original": {
+        "owner": "NixOS",
+        "ref": "nixpkgs-unstable",
+        "repo": "nixpkgs",
+        "type": "github"
+      }
+    },
+    "pre-commit-hooks": {
+      "inputs": {
+        "flake-compat": "flake-compat",
+        "flake-utils": "flake-utils_2",
+        "gitignore": "gitignore",
+        "nixpkgs": "nixpkgs_2",
+        "nixpkgs-stable": "nixpkgs-stable"
+      },
+      "locked": {
+        "lastModified": 1708018599,
+        "narHash": "sha256-M+Ng6+SePmA8g06CmUZWi1AjG2tFBX9WCXElBHEKnyM=",
+        "owner": "cachix",
+        "repo": "pre-commit-hooks.nix",
+        "rev": "5df5a70ad7575f6601d91f0efec95dd9bc619431",
+        "type": "github"
+      },
+      "original": {
+        "owner": "cachix",
+        "repo": "pre-commit-hooks.nix",
+        "type": "github"
+      }
+    },
     "root": {
       "inputs": {
         "flake-utils": "flake-utils",
         "gomod2nix": "gomod2nix",
-        "nixpkgs": "nixpkgs"
+        "nixpkgs": "nixpkgs",
+        "pre-commit-hooks": "pre-commit-hooks"
       }
     },
     "systems": {
@@ -78,6 +188,21 @@
         "repo": "default",
         "type": "github"
       }
+    },
+    "systems_2": {
+      "locked": {
+        "lastModified": 1681028828,
+        "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+        "owner": "nix-systems",
+        "repo": "default",
+        "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+        "type": "github"
+      },
+      "original": {
+        "owner": "nix-systems",
+        "repo": "default",
+        "type": "github"
+      }
     }
   },
   "root": "root",
diff --git a/flake.nix b/flake.nix
index 1d8de62..fe57114 100644
--- a/flake.nix
+++ b/flake.nix
@@ -6,8 +6,9 @@
   inputs.gomod2nix.url = "github:nix-community/gomod2nix";
   inputs.gomod2nix.inputs.nixpkgs.follows = "nixpkgs";
   inputs.gomod2nix.inputs.flake-utils.follows = "flake-utils";
+  inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
 
-  outputs = { self, nixpkgs, flake-utils, gomod2nix }:
+  outputs = { self, nixpkgs, flake-utils, gomod2nix, pre-commit-hooks }:
     (flake-utils.lib.eachDefaultSystem
       (system:
         let
@@ -23,6 +24,7 @@
           };
           devShells.default = callPackage ./shell.nix {
             inherit (gomod2nix.legacyPackages.${system}) mkGoEnv gomod2nix;
+            inherit pre-commit-hooks;
           };
         })
     );
diff --git a/shell.nix b/shell.nix
index d4f21a8..5cde177 100644
--- a/shell.nix
+++ b/shell.nix
@@ -11,12 +11,20 @@
   )
 , mkGoEnv ? pkgs.mkGoEnv
 , gomod2nix ? pkgs.gomod2nix
+, pre-commit-hooks
 }:
 
 let
   goEnv = mkGoEnv { pwd = ./.; };
+  pre-commit-check = pre-commit-hooks.lib.${pkgs.system}.run {
+      src = ./.;
+      hooks = {
+          gofmt.enable = true;
+      };
+  };
 in
 pkgs.mkShell {
+  inherit (pre-commit-check) shellHook;
   packages = [
     goEnv
     gomod2nix