Merge branch 'main' of https://github.com/titaniumnetwork-dev/ultraviolet-web-app
This commit is contained in:
commit
88e5dbc33a
6 changed files with 56 additions and 28 deletions
1
.replit
Normal file
1
.replit
Normal file
|
|
@ -0,0 +1 @@
|
|||
language = "nodejs"
|
||||
1
Procfile
Normal file
1
Procfile
Normal file
|
|
@ -0,0 +1 @@
|
|||
web: npm start
|
||||
29
README.md
29
README.md
|
|
@ -1,2 +1,29 @@
|
|||
# uv-app
|
||||
# Ultraviolet
|
||||
Ultraviolet application
|
||||
|
||||
[](https://heroku.com/deploy/?template=https://github.com/titaniumnetwork-dev/uv-app)
|
||||
[](https://replit.com/github/titaniumnetwork-dev/uv-app)
|
||||
|
||||
Deploying on machine
|
||||
|
||||
```
|
||||
git clone https://github.com/titaniumnetwork-dev/uv-app/
|
||||
cd uv-app
|
||||
npm install
|
||||
npm start
|
||||
```
|
||||
|
||||
`uv.config.js`
|
||||
|
||||
```javascript
|
||||
self.__uv$config = {
|
||||
prefix: '/sw/', // Proxy url prefix
|
||||
bare: '/bare/', // Bare server location
|
||||
encodeUrl: Ultraviolet.codec.xor.encode, // URL Encoding function
|
||||
decodeUrl: Ultraviolet.codec.xor.decode, // Decode URL function
|
||||
handler: '/uv.handler.js', // Handler script
|
||||
bundle: '/uv.bundle.js', // Bundled script
|
||||
config: '/uv.config.js', // Configuration script
|
||||
sw: '/uv.sw.js', // Service Worker Script
|
||||
};
|
||||
```
|
||||
|
|
|
|||
28
index.js
28
index.js
|
|
@ -1,25 +1,3 @@
|
|||
import { Server } from './bare/Server.mjs';
|
||||
import { readFileSync } from 'fs';
|
||||
import https from 'https';
|
||||
import nodeStatic from 'node-static';
|
||||
|
||||
|
||||
const bare = new Server('/bare/', '');
|
||||
const serve = new nodeStatic.Server('static/');
|
||||
|
||||
const server = https.createServer({
|
||||
key: readFileSync('ssl/default.key', 'utf-8'),
|
||||
cert: readFileSync('ssl/default.cert', 'utf-8')
|
||||
});
|
||||
|
||||
server.on('request', (request, response) => {
|
||||
if (bare.route_request(request, response)) return true;
|
||||
serve.serve(request, response);
|
||||
});
|
||||
|
||||
server.on('upgrade', (req, socket, head) => {
|
||||
if(bare.route_upgrade(req, socket, head))return;
|
||||
socket.end();
|
||||
});
|
||||
|
||||
server.listen(443);
|
||||
(async() => {
|
||||
await import('./index.mjs');
|
||||
})();
|
||||
|
|
|
|||
22
index.mjs
Normal file
22
index.mjs
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { Server } from './tomp/Server.mjs';
|
||||
import { readFileSync } from 'fs';
|
||||
import http from 'http';
|
||||
import nodeStatic from 'node-static';
|
||||
|
||||
|
||||
const bare = new Server('/bare/', '');
|
||||
const serve = new nodeStatic.Server('static/');
|
||||
|
||||
const server = http.createServer();
|
||||
|
||||
server.on('request', (request, response) => {
|
||||
if (bare.route_request(request, response)) return true;
|
||||
serve.serve(request, response);
|
||||
});
|
||||
|
||||
server.on('upgrade', (req, socket, head) => {
|
||||
if(bare.route_upgrade(req, socket, head))return;
|
||||
socket.end();
|
||||
});
|
||||
|
||||
server.listen(process.env.PORT || 8080);
|
||||
|
|
@ -15,6 +15,5 @@
|
|||
"proxy"
|
||||
],
|
||||
"author": "",
|
||||
"license": "GPL-3.0-or-later",
|
||||
"type": "module"
|
||||
"license": "GPL-3.0-or-later"
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue