diff --git a/flake.nix b/flake.nix
index bbd4476..5b2f8fc 100644
--- a/flake.nix
+++ b/flake.nix
@@ -87,7 +87,7 @@
}
)) // {
nixosModules.default = { config, lib, ...}: {
- options.safensound = {
+ options.services.safensound = {
enable = lib.mkEnableOption "Enable SafeNSound service";
package = lib.mkOption {
type = lib.types.package;
@@ -105,7 +105,7 @@
default = "mongodb-pass";
description = "Path to the database credentials file.";
};
- JwtSecretPath = lib.mkOption {
+ jwtSecretPath = lib.mkOption {
type = lib.types.path;
default = ".";
description = "Path to the JWT secret directory.";
@@ -113,6 +113,33 @@
logQueries = lib.mkEnableOption "Log queries";
logAuth = lib.mkEnableOption "Log authentication";
};
+
+ config = lib.mkIf (config.safensound.enable) (
+ let
+ cfg = config.services.safensound;
+ in
+ {
+ systemd.services.safensound = {
+ description = "SafeNSound Service";
+ wantedBy = [ "multi-user.target" ];
+ after = [ "network.target" "mongodb.service" ];
+ requires = [ "mongodb.service" ];
+ environment = {
+ PORT = cfg.port;
+ LOG_REQUESTS = cfg.logRequests;
+ DATABASE_SECRET_PATH = cfg.dbCredentialsPath;
+ JWT_SECRET_PATH = cfg.jwtSEcretPath;
+ LOG_QUERIES = cfg.logQueries;
+ LOG_AUTH = cfg.logAuth;
+ };
+ serviceConfig = {
+ Type = "simple";
+ ExecStart = "${cfg.package}/bin/start";
+ Restart = "on-failure";
+ DynamicUser = true;
+ };
+ };
+ });
};
};
}
\ No newline at end of file
diff --git a/hashes.json b/hashes.json
index 808b747..1237c6b 100644
--- a/hashes.json
+++ b/hashes.json
@@ -1,3 +1,3 @@
{
- "npmDepsHash": "sha256-f+7P0Ubp6FEwWvBkALbkvtlAdzI4L3JCvhQspWRFKA4="
+ "npmDepsHash": "sha256-Ygy9KnqETpBaHb2E3sDl0icB36qNcBToxoPlyvat7dA="
}
diff --git a/package-lock.json b/package-lock.json
index 022dd0c..6b21021 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,6 +9,7 @@
"version": "1.0.0",
"license": "ISC",
"dependencies": {
+ "bcrypt": "^6.0.0",
"express": "^5.1.0",
"joi": "^17.13.3",
"jsonwebtoken": "^9.0.2",
@@ -19,7 +20,6 @@
"devDependencies": {
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.27.0",
- "bcrypt": "^6.0.0",
"dotenv": "^16.5.0",
"eslint": "^9.27.0",
"globals": "^16.2.0",
@@ -428,7 +428,6 @@
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-6.0.0.tgz",
"integrity": "sha512-cU8v/EGSrnH+HnxV2z0J7/blxH8gq7Xh2JFT6Aroax7UohdmiJJlxApMxtKfuI7z68NvvVcmR78k2LbT6efhRg==",
- "dev": true,
"hasInstallScript": true,
"license": "MIT",
"dependencies": {
@@ -1753,7 +1752,6 @@
"version": "8.3.1",
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.3.1.tgz",
"integrity": "sha512-lytcDEdxKjGJPTLEfW4mYMigRezMlyJY8W4wxJK8zE533Jlb8L8dRuObJFWg2P+AuOIxoCgKF+2Oq4d4Zd0OUA==",
- "dev": true,
"license": "MIT",
"engines": {
"node": "^18 || ^20 || >= 21"
@@ -1763,7 +1761,6 @@
"version": "4.8.4",
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.8.4.tgz",
"integrity": "sha512-LA4ZjwlnUblHVgq0oBF3Jl/6h/Nvs5fzBLwdEF4nuxnFdsfajde4WfxtJr3CaiH+F6ewcIB/q4jQ4UzPyid+CQ==",
- "dev": true,
"license": "MIT",
"bin": {
"node-gyp-build": "bin.js",
diff --git a/package.json b/package.json
index bbd9060..3b4b2ff 100644
--- a/package.json
+++ b/package.json
@@ -29,7 +29,6 @@
"devDependencies": {
"@eslint/eslintrc": "^3.3.1",
"@eslint/js": "^9.27.0",
- "bcrypt": "^6.0.0",
"dotenv": "^16.5.0",
"eslint": "^9.27.0",
"globals": "^16.2.0",
@@ -39,6 +38,7 @@
"prettier-quick": "^0.0.5"
},
"dependencies": {
+ "bcrypt": "^6.0.0",
"express": "^5.1.0",
"joi": "^17.13.3",
"jsonwebtoken": "^9.0.2",
diff --git a/src/db/dbAccess/user.js b/src/db/dbAccess/user.js
index 69a83e4..9804be6 100644
--- a/src/db/dbAccess/user.js
+++ b/src/db/dbAccess/user.js
@@ -1,5 +1,5 @@
import { hash, compare, genSalt } from 'bcrypt';
-import { DbUser, deviceSchema } from '#db/schemas/index.js';
+import { DbUser } from '#db/schemas/index.js';
import { AuthDto, RegisterDto } from '#dto/index.js';
import { SafeNSoundError } from '#util/error.js';
import { WhoAmIDto } from '#dto/auth/WhoAmIDto.js';
diff --git a/src/db/schemas/user.js b/src/db/schemas/user.js
index 7a4b2f4..69ebb02 100644
--- a/src/db/schemas/user.js
+++ b/src/db/schemas/user.js
@@ -1,5 +1,4 @@
import { model, Schema, ObjectId } from 'mongoose';
-import { hash, compare } from 'bcrypt';
export const UserType = Object.freeze({
USER: 'user',
|