18829464 by Glitch (hello-express)

:ocean::violin: Checkpoint

./gun-ws.js:13690106/9
./README.md:13690106/1052
./package.json:13690106/364
./server.js:13690106/430
1 parent d255a941
1 # hello-express 1 # GunDB Multiserver
2 2
3 A server that serves a webpage, its resources, and some data 3 A server that serves ephemeral Gun instances through websocket paths
4 4
5 5
6 ## Your Project
7
8 On the front-end,
9
10 - Edit `views/index.html` to change the content of the webpage
11 - `public/client.js` is the javacript that runs when you load the webpage
12 - `public/style.css` is the styles for `views/index.html`
13 - Drag in `assets`, like images or music, to add them to your project
14
15 On the back-end,
16
17 - your app starts at `server.js`
18 - add frameworks and packages in `package.json`
19 - safely store app secrets in `.env` (nobody can see this but you and people you invite)
20
21 Click `Show` in the header to see your app live. Updates to your code will instantly deploy.
22
23
24 ## Made by [Glitch](https://glitch.com/)
25
26 **Glitch** is the friendly community where you'll build the app of your dreams. Glitch lets you instantly create, remix, edit, and host an app, bot or site, and you can invite collaborators or helpers to simultaneously edit code with you.
27
28 Find out more [about Glitch](https://glitch.com/about).
29
30 ( ᵔ ᴥ ᵔ )
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
15 15
16 if(opt.web){ 16 if(opt.web){
17 17
18 console.log('Initializing Gun WS socket!', ws.path); 18 console.log('Initializing Gun WS socket', ws.path);
19 19
20 ws.server = ws.server || opt.web; 20 ws.server = ws.server || opt.web;
21 ws.path = ws.path || '/gun'; 21 ws.path = ws.path || '/gun';
......
1 { 1 {
2 "//1": "describes your app and its dependencies", 2 "name": "gundb-multiserver",
3 "//2": "https://docs.npmjs.com/files/package.json",
4 "//3": "updating this file will download and update your packages",
5 "name": "hello-express",
6 "version": "0.0.1", 3 "version": "0.0.1",
7 "description": "A simple Node app built on Express, instantly up and running.", 4 "description": "Serve multiple Gun WS instances over a single HTTP socket",
8 "main": "server.js", 5 "main": "server.js",
9 "scripts": { 6 "scripts": {
10 "start": "node server.js" 7 "start": "node server.js"
...@@ -18,7 +15,7 @@ ...@@ -18,7 +15,7 @@
18 "node": "12.x" 15 "node": "12.x"
19 }, 16 },
20 "repository": { 17 "repository": {
21 "url": "https://glitch.com/edit/#!/hello-express" 18 "url": "https://glitch.com/edit/#!/gundb-multiserver"
22 }, 19 },
23 "license": "MIT", 20 "license": "MIT",
24 "keywords": [ 21 "keywords": [
......
...@@ -23,10 +23,9 @@ server.on('upgrade', async function (request, socket, head) { ...@@ -23,10 +23,9 @@ server.on('upgrade', async function (request, socket, head) {
23 } else { 23 } else {
24 // Create Node 24 // Create Node
25 console.log('Create id',pathname); 25 console.log('Create id',pathname);
26 // HOW HOW HOW ? IS it even possible to attach the WS to the Gun Object alone? 26 // NOTE: Only works with lib/ws.js shim allowing a predefined WS as ws.web parameter in Gun constructor
27 // Works only when passing "server" to the web parameter, no WS/WSS) 27 gun.server = new WebSocket.Server({ noServer: true, path: pathname});
28 gun.server = new WebSocket.Server({ noServer: true}); 28 gun.gun = new Gun({peers:[], localStorage: false, file: false, ws: { noServer: true, path: pathname, web: gun.server }, web: gun.server });
29 gun.gun = new Gun({peers:[], localStorage: false, ws: { noServer: true, path: pathname, web: gun.server }, web: gun.server });
30 lru.set(pathname,gun); 29 lru.set(pathname,gun);
31 } 30 }
32 } 31 }
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!