From e7800727d55f5491ec4d935ab063ee102e7cdf73 Mon Sep 17 00:00:00 2001 From: Rory& Date: Wed, 28 May 2025 07:16:56 +0200 Subject: Bare minimum express server, fix nix package --- flake.nix | 8 +++----- hashes.json | 2 +- package.json | 3 ++- src/api/start.js | 12 ++++++++++++ 4 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 src/api/start.js diff --git a/flake.nix b/flake.nix index 4c5e915..bdcf963 100644 --- a/flake.nix +++ b/flake.nix @@ -39,6 +39,7 @@ nativeBuildInputs = with pkgs; [ python3 ]; npmDepsHash = hashesFile.npmDepsHash; makeCacheWritable = true; + dontNpmBuild = true; postPatch = '' substituteInPlace package.json --replace 'npx patch-package' '${pkgs.nodePackages.patch-package}/bin/patch-package' ''; @@ -50,8 +51,8 @@ find node_modules -maxdepth 1 -type d -empty -delete mkdir -p $out - cp -r assets dist node_modules package.json $out/ - makeWrapper ${pkgs.nodejs}/bin/node $out/bin/start --prefix NODE_PATH : $out/node_modules --add-flags $out/$i + cp -r src node_modules package.json $out/ + makeWrapper ${pkgs.nodejs}/bin/node $out/bin/start --prefix NODE_PATH : $out/node_modules --add-flags $out set +x runHook postInstall @@ -78,9 +79,6 @@ devShell = pkgs.mkShell { buildInputs = with pkgs; [ nodejs - nodePackages.typescript - nodePackages.ts-node - nodePackages.patch-package nodePackages.prettier ]; }; diff --git a/hashes.json b/hashes.json index 7bee6e9..35acf15 100644 --- a/hashes.json +++ b/hashes.json @@ -1,3 +1,3 @@ { - "npmDepsHash": "sha256-moMLyLAQ+sHfhc5zJfC/quKTM1M/M3bFziOPGKP30Ys=" + "npmDepsHash": "sha256-X4ILC6lL+THrUg04KgIw7KAatCeuIgMgsYAgrLFtHjI=" } diff --git a/package.json b/package.json index 9d2c557..d65d404 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,8 @@ "name": "nodejs-final-assignment", "version": "1.0.0", "description": "[![Review Assignment Due Date](https://classroom.github.com/assets/deadline-readme-button-22041afd0340ce965d47ae6ef1cefeee28c7c493a6346c4f15d667ab976d596c.svg)](https://classroom.github.com/a/3A9ByVp3)", - "main": "index.js", + "main": "src/api/start.js", + "type": "module", "scripts": { "prepare": "husky install" }, diff --git a/src/api/start.js b/src/api/start.js new file mode 100644 index 0000000..9d9c586 --- /dev/null +++ b/src/api/start.js @@ -0,0 +1,12 @@ +import express from "express"; + +const app = express(); +const PORT = process.env.PORT || 3000; + +app.get("/", (req, res) => { + res.send("Welcome to the API!"); +}); + +app.listen(PORT, () => { + console.log(`Server is running on http://localhost:${PORT}`); +}); -- cgit 1.5.1