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