diff --git a/.gitignore b/.gitignore
index bc780d640..69fcafd43 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,9 +13,10 @@ assets/cacheMisses
.vscode/settings.json
build
+result
*.log
*.log.ansi
*.tmp
tmp/
-dump/
\ No newline at end of file
+dump/
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 000000000..b58b603fe
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,5 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
new file mode 100644
index 000000000..50497ca0a
--- /dev/null
+++ b/.idea/codeStyles/Project.xml
@@ -0,0 +1,148 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ GROUP_PROPERTY_FIELD_WITH_GETTER_SETTER
+ KEEP
+
+
+ TREAT_LAMBDA_INITIALIZED_FIELDS_AS_METHODS
+ KEEP
+
+
+ OVERRIDDEN_METHODS
+ BY_NAME
+
+
+
+
+
+
+
+ true
+ true
+
+
+ BY_NAME
+
+
+
+
+
+ true
+
+ BY_NAME
+
+
+
+
+
+
+
+ true
+ true
+
+
+ BY_NAME
+
+
+
+
+
+ true
+
+ BY_NAME
+
+
+
+
+
+
+ true
+ true
+
+
+ BY_NAME
+
+
+
+
+
+ true
+
+ BY_NAME
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml
new file mode 100644
index 000000000..79ee123c2
--- /dev/null
+++ b/.idea/codeStyles/codeStyleConfig.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 000000000..22cdf9bd9
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml
new file mode 100644
index 000000000..1ee68b188
--- /dev/null
+++ b/.idea/jsLibraryMappings.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jsLinters/eslint.xml b/.idea/jsLinters/eslint.xml
new file mode 100644
index 000000000..541945bb0
--- /dev/null
+++ b/.idea/jsLinters/eslint.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 000000000..28a804d89
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 000000000..fbd90b4d4
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/prettier.xml b/.idea/prettier.xml
new file mode 100644
index 000000000..b0c1c68fb
--- /dev/null
+++ b/.idea/prettier.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/server.iml b/.idea/server.iml
new file mode 100644
index 000000000..6186bc99d
--- /dev/null
+++ b/.idea/server.iml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 000000000..35eb1ddfb
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/assets/schemas.json b/assets/schemas.json
index a0ab1697c..e5e0b5230 100644
Binary files a/assets/schemas.json and b/assets/schemas.json differ
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 000000000..db9e528ff
Binary files /dev/null and b/flake.lock differ
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 000000000..f0f6389a1
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,35 @@
+{
+ description = "Spacebar server, written in Typescript.";
+
+ inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
+ inputs.flake-utils.url = "github:numtide/flake-utils";
+
+ outputs = { self, nixpkgs, flake-utils }:
+ flake-utils.lib.eachSystem flake-utils.lib.allSystems (system:
+ let
+ pkgs = import nixpkgs {
+ inherit system;
+ };
+ in rec {
+ packages.default = pkgs.buildNpmPackage {
+ pname = "spacebar-server-ts";
+ src = ./.;
+ name = "spacebar-server-ts";
+ meta.mainProgram = "start-bundle";
+
+ #nativeBuildInputs = with pkgs; [ python3 ];
+ npmDepsHash = "sha256-9yyOPogFi71Dcm7DKe4FJJz9d6uDtJsliDR+b32KKvA=";
+ #makeCacheWritable = true;
+ postPatch = ''
+ substituteInPlace package.json --replace 'npx patch-package' '${pkgs.nodePackages.patch-package}/bin/patch-package'
+ '';
+ };
+ devShell = pkgs.mkShell {
+ buildInputs = with pkgs; [
+ nodejs
+ nodePackages.typescript
+ ];
+ };
+ }
+ );
+}
diff --git a/flake.template.nix b/flake.template.nix
new file mode 100644
index 000000000..d1d30d7be
--- /dev/null
+++ b/flake.template.nix
@@ -0,0 +1,35 @@
+{
+ description = "Spacebar server, written in Typescript.";
+
+ inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
+ inputs.flake-utils.url = "github:numtide/flake-utils";
+
+ outputs = { self, nixpkgs, flake-utils }:
+ flake-utils.lib.eachSystem flake-utils.lib.allSystems (system:
+ let
+ pkgs = import nixpkgs {
+ inherit system;
+ };
+ in rec {
+ packages.default = pkgs.buildNpmPackage {
+ pname = "spacebar-server-ts";
+ src = ./.;
+ name = "spacebar-server-ts";
+ meta.mainProgram = "start-bundle";
+
+ #nativeBuildInputs = with pkgs; [ python3 ];
+ npmDepsHash = "$NPM_HASH";
+ #makeCacheWritable = true;
+ postPatch = ''
+ substituteInPlace package.json --replace 'npx patch-package' '${pkgs.nodePackages.patch-package}/bin/patch-package'
+ '';
+ };
+ devShell = pkgs.mkShell {
+ buildInputs = with pkgs; [
+ nodejs
+ nodePackages.typescript
+ ];
+ };
+ }
+ );
+}
diff --git a/nix-build-test.sh b/nix-build-test.sh
new file mode 100755
index 000000000..5c6914620
--- /dev/null
+++ b/nix-build-test.sh
@@ -0,0 +1,3 @@
+#!/usr/bin/env sh
+#nix build --update-input pnpm2nix --debugger --ignore-try
+nix build --debugger --ignore-try --print-out-paths --print-build-logs --http2 "$@"
diff --git a/nix-rebuild-flake.sh b/nix-rebuild-flake.sh
new file mode 100755
index 000000000..08f55840b
--- /dev/null
+++ b/nix-rebuild-flake.sh
@@ -0,0 +1,4 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i "bash -x" -p bash
+DEPS_HASH=`nix run nixpkgs#prefetch-npm-deps -- package-lock.json`
+sed 's/$NPM_HASH/'${DEPS_HASH/\//\\\/}'/g' flake.template.nix > flake.nix
diff --git a/package.json b/package.json
index 3994670b5..7e48f745d 100644
--- a/package.json
+++ b/package.json
@@ -35,6 +35,16 @@
"imports": {
"#*": "./dist/*/index.js"
},
+ "files": [
+ "dist",
+ "assets"
+ ],
+ "bin": {
+ "start-bundle": "dist/bundle/start.js",
+ "start-api": "dist/api/start.js",
+ "start-cdn": "dist/cdn/start.js",
+ "start-gateway": "dist/gateway/start.js"
+ },
"homepage": "https://spacebar.chat",
"devDependencies": {
"@types/amqplib": "^0.8.2",
diff --git a/tsconfig.json b/tsconfig.json
index 63b5e96cb..1e3e9d59a 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -41,9 +41,7 @@
} /* Specify a set of entries that re-map imports to additional lookup locations. */,
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
- "types": [
- "node"
- ] /* Specify type package names to be included without being referenced in a source file. */,
+ "types": ["node"] /* Specify type package names to be included without being referenced in a source file. */,
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
"resolveJsonModule": true /* Enable importing .json files. */,