summary refs log tree commit diff
diff options
context:
space:
mode:
authorRory& <root@rory.gay>2025-06-03 04:16:14 +0200
committerRory& <root@rory.gay>2025-06-03 04:16:14 +0200
commit4c6e0f259864498877cba4e8b23e088954e7a979 (patch)
tree9bba5aef3128d9e62e9db93824ee735d2d80e0e5
parentUse streaming for alarm list (diff)
downloadnodejs-final-assignment-4c6e0f259864498877cba4e8b23e088954e7a979.tar.xz
Simple nixOS module
-rw-r--r--README.md2
-rw-r--r--flake.nix37
-rw-r--r--src/db/schemas/sensorHistory.js2
3 files changed, 35 insertions, 6 deletions
diff --git a/README.md b/README.md

index 1a02eee..fa2e942 100644 --- a/README.md +++ b/README.md
@@ -15,6 +15,6 @@ Environment variables: | `PORT` | `3000` | The port the server will run on. | | `LOG_REQUESTS` | `-` | Requests to log to the console by status, `-` to invert. | | `DATABASE_SECRET_PATH` | ` ` | The path to the mongodb connection string. | +| `JWT_SECRET_PATH` | ` ` | The path to the JWT secret certificate. | | `LOG_QUERIES` | `false` | Whether to enable mongoose debug logs | | `LOG_AUTH` | `false` | Whether to enable authentication debug logs | -| `JWT_SECRET_PATH` | ` ` | The path to the JWT secret certificate. | \ No newline at end of file diff --git a/flake.nix b/flake.nix
index f5082fc..bbd4476 100644 --- a/flake.nix +++ b/flake.nix
@@ -12,7 +12,7 @@ nixpkgs, flake-utils, }: - flake-utils.lib.eachSystem flake-utils.lib.allSystems ( + (flake-utils.lib.eachSystem flake-utils.lib.allSystems ( system: let pkgs = import nixpkgs { @@ -25,8 +25,8 @@ { packages = { default = pkgs.buildNpmPackage { - pname = "nodejs-ti-a-final-assignment-TheArcaneBrony"; - name = "nodejs-ti-a-final-assignment-TheArcaneBrony"; + pname = "SafeNSound"; + name = "SafeNSound"; meta = with lib; { description = "Final assignment for NodeJS"; @@ -85,5 +85,34 @@ ]; }; } - ); + )) // { + nixosModules.default = { config, lib, ...}: { + options.safensound = { + enable = lib.mkEnableOption "Enable SafeNSound service"; + package = lib.mkOption { + type = lib.types.package; + default = self.packages.${lib.system}.default; + description = "The SafeNSound service package to run."; + }; + port = lib.mkOption { + type = lib.types.port; + default = 3000; + description = "The port on which the SafeNSound service will listen."; + }; + logRequests = lib.mkEnableOption "Log requests"; + dbCredentialsPath = lib.mkOption { + type = lib.types.path; + default = "mongodb-pass"; + description = "Path to the database credentials file."; + }; + JwtSecretPath = lib.mkOption { + type = lib.types.path; + default = "."; + description = "Path to the JWT secret directory."; + }; + logQueries = lib.mkEnableOption "Log queries"; + logAuth = lib.mkEnableOption "Log authentication"; + }; + }; + }; } \ No newline at end of file diff --git a/src/db/schemas/sensorHistory.js b/src/db/schemas/sensorHistory.js
index 0cf1187..152f03a 100644 --- a/src/db/schemas/sensorHistory.js +++ b/src/db/schemas/sensorHistory.js
@@ -29,6 +29,6 @@ export const sensorHistorySchema = new Schema( } ); -export const DbSpendHistory = model('sensorHistory', sensorHistorySchema); +export const DbSensorHistory = model('sensorHistory', sensorHistorySchema); console.log('[MONGODB] sensorHistory schema initialized successfully!');