Procházet zdrojové kódy

Update to current production version supporting excalidraw.com (loaded on Heroku)

master
idlewinn před 5 roky
rodič
revize
290c0a1e3a
9 změnil soubory, kde provedl 4528 přidání a 1646 odebrání
  1. 0
    5
      .gcloudignore
  2. 107
    3
      .gitignore
  3. 2
    32
      README.md
  4. 0
    2
      app.yaml
  5. 4337
    0
      package-lock.json
  6. 61
    33
      package.json
  7. 6
    15
      src/index.ts
  8. 15
    7
      tsconfig.json
  9. 0
    1549
      yarn.lock

+ 0
- 5
.gcloudignore Zobrazit soubor

@@ -1,5 +0,0 @@
1
-# Exclude compiled .js files
2
-*.js
3
-
4
-# Exclude dependencies
5
-node_modules/

+ 107
- 3
.gitignore Zobrazit soubor

@@ -1,3 +1,107 @@
1
-*.js
2
-node_modules
3
-yarn-error.log
1
+# Logs
2
+logs
3
+*.log
4
+npm-debug.log*
5
+yarn-debug.log*
6
+yarn-error.log*
7
+lerna-debug.log*
8
+
9
+# Diagnostic reports (https://nodejs.org/api/report.html)
10
+report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11
+
12
+# Runtime data
13
+pids
14
+*.pid
15
+*.seed
16
+*.pid.lock
17
+
18
+# Directory for instrumented libs generated by jscoverage/JSCover
19
+lib-cov
20
+
21
+# Coverage directory used by tools like istanbul
22
+coverage
23
+*.lcov
24
+
25
+# nyc test coverage
26
+.nyc_output
27
+
28
+# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29
+.grunt
30
+
31
+# Bower dependency directory (https://bower.io/)
32
+bower_components
33
+
34
+# node-waf configuration
35
+.lock-wscript
36
+
37
+# Compiled binary addons (https://nodejs.org/api/addons.html)
38
+build/Release
39
+
40
+# Dependency directories
41
+node_modules/
42
+jspm_packages/
43
+
44
+# TypeScript v1 declaration files
45
+typings/
46
+
47
+# TypeScript cache
48
+*.tsbuildinfo
49
+
50
+# Optional npm cache directory
51
+.npm
52
+
53
+# Optional eslint cache
54
+.eslintcache
55
+
56
+# Microbundle cache
57
+.rpt2_cache/
58
+.rts2_cache_cjs/
59
+.rts2_cache_es/
60
+.rts2_cache_umd/
61
+
62
+# Optional REPL history
63
+.node_repl_history
64
+
65
+# Output of 'npm pack'
66
+*.tgz
67
+
68
+# Yarn Integrity file
69
+.yarn-integrity
70
+
71
+# dotenv environment variables file
72
+.env
73
+.env.test
74
+
75
+# parcel-bundler cache (https://parceljs.org/)
76
+.cache
77
+
78
+# Next.js build output
79
+.next
80
+
81
+# Nuxt.js build / generate output
82
+.nuxt
83
+dist
84
+
85
+# Gatsby files
86
+.cache/
87
+# Comment in the public line in if your project uses Gatsby and *not* Next.js
88
+# https://nextjs.org/blog/next-9-1#public-directory-support
89
+# public
90
+
91
+# vuepress build output
92
+.vuepress/dist
93
+
94
+# Serverless directories
95
+.serverless/
96
+
97
+# FuseBox cache
98
+.fusebox/
99
+
100
+# DynamoDB Local files
101
+.dynamodb/
102
+
103
+# TernJS port file
104
+.tern-port
105
+
106
+.DS_Store
107
+dist

+ 2
- 32
README.md Zobrazit soubor

@@ -1,32 +1,2 @@
1
-# excalidraw-room
2
-
3
-## Requirements
4
-
5
-- [Node.js](https://nodejs.org/en/)
6
-- [Google Cloud SDK](https://cloud.google.com/sdk/?hl=en_US)
7
-
8
-## Install
9
-
10
-```
11
-yarn
12
-```
13
-
14
-## Build
15
-
16
-```
17
-yarn build
18
-```
19
-
20
-## Run
21
-
22
-```
23
-yarn start
24
-```
25
-
26
-## Deploy
27
-
28
-Make sure you have access to the [`excalidraw-room`](https://console.cloud.google.com/home/dashboard?project=excalidraw-room) project.
29
-
30
-```
31
-yarn deploy
32
-```
1
+# collab-server
2
+Excalidraw collaboration server

+ 0
- 2
app.yaml Zobrazit soubor

@@ -1,2 +0,0 @@
1
-runtime: nodejs
2
-env: flex

+ 4337
- 0
package-lock.json
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


+ 61
- 33
package.json Zobrazit soubor

@@ -1,40 +1,68 @@
1 1
 {
2
-  "dependencies": {
3
-    "@types/express": "4.17.3",
4
-    "@types/node": "13.9.0",
5
-    "@types/socket.io": "2.1.4",
6
-    "express": "4.17.1",
7
-    "socket.io": "2.3.0",
8
-    "typescript": "3.8.3"
9
-  },
10
-  "devDependencies": {
11
-    "husky": "4.2.3",
12
-    "lint-staged": "10.0.8",
13
-    "prettier": "1.19.1"
2
+  "name": "collab-server",
3
+  "version": "1.0.0",
4
+  "description": "Excalidraw collaboration server",
5
+  "main": "index.js",
6
+  "scripts": {
7
+    "build": "tsc",
8
+    "postinstall": "npm run build",
9
+    "start": "node dist/index.js",
10
+    "test": "echo \"Error: no test specified\" && exit 1"
14 11
   },
15
-  "husky": {
16
-    "hooks": {
17
-      "pre-commit": "lint-staged"
18
-    }
12
+  "repository": {
13
+    "type": "git",
14
+    "url": "git+https://github.com/idlewinn/collab-server.git"
19 15
   },
16
+  "keywords": [],
17
+  "author": "",
20 18
   "license": "MIT",
21
-  "lint-staged": {
22
-    "*.{ts,md,json,yaml,yml}": [
23
-      "prettier --write"
24
-    ]
19
+  "bugs": {
20
+    "url": "https://github.com/idlewinn/collab-server/issues"
25 21
   },
26
-  "main": "index.js",
27
-  "name": "excalidraw-room",
28
-  "scripts": {
29
-    "build": "yarn gcp-build",
30
-    "deploy": "gcloud app deploy --project=excalidraw-room",
31
-    "fix": "yarn prettier --write",
32
-    "gcp-build": "tsc -p .",
33
-    "prepare": "yarn gcp-build",
34
-    "pretest": "yarn gcp-build",
35
-    "prettier": "prettier \"**/*.{ts,md,json,yaml,yml}\"",
36
-    "start": "node ./index.js",
37
-    "test": "yarn prettier --list-different"
22
+  "homepage": "https://github.com/idlewinn/collab-server#readme",
23
+  "dependencies": {
24
+    "@types/socket.io": "^2.1.4",
25
+    "eslint": "6.8.0",
26
+    "eslint-config-prettier": "6.10.0",
27
+    "eslint-plugin-prettier": "3.1.2",
28
+    "express": "^4.17.1",
29
+    "prettier": "1.19.1",
30
+    "socket.io": "^2.3.0"
38 31
   },
39
-  "version": "1.0.0"
32
+  "devDependencies": {
33
+    "@types/express": "^4.17.3",
34
+    "@types/node": "^13.9.0",
35
+    "typescript": "^3.8.3"
36
+  },
37
+  "eslintConfig": {
38
+    "extends": [
39
+      "prettier"
40
+    ],
41
+    "plugins": [
42
+      "prettier"
43
+    ],
44
+    "rules": {
45
+      "curly": "warn",
46
+      "no-console": [
47
+        "warn",
48
+        {
49
+          "allow": [
50
+            "warn",
51
+            "error",
52
+            "info"
53
+          ]
54
+        }
55
+      ],
56
+      "no-else-return": "warn",
57
+      "no-useless-return": "warn",
58
+      "prefer-const": [
59
+        "warn",
60
+        {
61
+          "destructuring": "all"
62
+        }
63
+      ],
64
+      "prefer-template": "warn",
65
+      "prettier/prettier": "warn"
66
+    }
67
+  }
40 68
 }

index.ts → src/index.ts Zobrazit soubor

@@ -1,15 +1,9 @@
1
-// source: https://github.com/idlewinn/collab-server/blob/master/src/index.ts
2
-
3 1
 import express from "express";
4
-import http from "http";
2
+import http, { ServerResponse } from "http";
5 3
 import socketIO from "socket.io";
6 4
 
7 5
 const app = express();
8
-const port = process.env.PORT || 8080;
9
-
10
-app.get("/", (req, res) => {
11
-  res.send("Hi, excalidraw-room!");
12
-});
6
+const port = process.env.PORT || 80; // default port to listen
13 7
 
14 8
 const server = http.createServer(app);
15 9
 
@@ -46,13 +40,10 @@ io.on("connection", socket => {
46 40
     );
47 41
   });
48 42
 
49
-  socket.on(
50
-    "server-broadcast",
51
-    (roomID: string, encryptedData: ArrayBuffer, iv: Uint8Array) => {
52
-      console.log(`${socket.id} sends update to ${roomID}`);
53
-      socket.broadcast.to(roomID).emit("client-broadcast", encryptedData, iv);
54
-    }
55
-  );
43
+  socket.on("server-broadcast", (roomID: string, encryptedData: ArrayBuffer, iv: Uint8Array) => {
44
+    console.log(`${socket.id} sends update to ${roomID}`);
45
+    socket.broadcast.to(roomID).emit("client-broadcast", encryptedData, iv);
46
+  });
56 47
 
57 48
   socket.on("disconnecting", () => {
58 49
     const rooms = io.sockets.adapter.rooms;

+ 15
- 7
tsconfig.json Zobrazit soubor

@@ -1,8 +1,16 @@
1 1
 {
2
-  "compilerOptions": {
3
-    "target": "es5",
4
-    "esModuleInterop": true,
5
-    "module": "CommonJS"
6
-  },
7
-  "include": ["*.ts"]
8
-}
2
+    "compilerOptions": {
3
+      "target": "es5",
4
+      "lib": ["dom", "dom.iterable", "esnext"],
5
+      "allowJs": true,
6
+      "skipLibCheck": true,
7
+      "esModuleInterop": true,
8
+      "allowSyntheticDefaultImports": true,
9
+      "strict": true,
10
+      "forceConsistentCasingInFileNames": true,
11
+      "moduleResolution": "node",
12
+      "resolveJsonModule": true,
13
+      "isolatedModules": true,
14
+      "outDir": "dist"
15
+    }
16
+  }

+ 0
- 1549
yarn.lock
Diff nebyl zobrazen, protože je příliš veliký
Zobrazit soubor


Načítá se…
Zrušit
Uložit