diff --git a/.replit b/.replit new file mode 100644 index 0000000..1f23558 --- /dev/null +++ b/.replit @@ -0,0 +1 @@ +language = "nodejs" diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..063b78f --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: npm start diff --git a/README.md b/README.md index 276e432..428c409 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,29 @@ -# uv-app +# Ultraviolet Ultraviolet application + +[![Deploy to Heroku](https://raw.githubusercontent.com/BinBashBanana/deploy-buttons/master/buttons/remade/heroku.svg)](https://heroku.com/deploy/?template=https://github.com/titaniumnetwork-dev/uv-app) +[![Run on Replit](https://raw.githubusercontent.com/BinBashBanana/deploy-buttons/master/buttons/remade/replit.svg)](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 +}; +``` diff --git a/index.js b/index.js index 8cf527d..406f266 100644 --- a/index.js +++ b/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); \ No newline at end of file +(async() => { + await import('./index.mjs'); +})(); diff --git a/index.mjs b/index.mjs new file mode 100644 index 0000000..c11420f --- /dev/null +++ b/index.mjs @@ -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); diff --git a/package.json b/package.json index 4b7a66a..11da580 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,5 @@ "proxy" ], "author": "", - "license": "GPL-3.0-or-later", - "type": "module" + "license": "GPL-3.0-or-later" }