nar webapp howto
Create a fully self-contained executable of a web application with an embedded HTTP server using nar
Install nar as global package (you must have node.js already installed in your system)
$ npm install -g nar| #!/bin/sh | |
| # | |
| # Orinally made by Lovell Fuller for sharp | |
| # https://github.com/lovell/sharp | |
| # | |
| # Usage: | |
| # curl -s https://gist.githubusercontent.com/h2non/89bb2f87c6499d0b25f1/raw/bf3d0743107f02f5db2b93c53f7f0e07a1c33112/libvips-installer.sh | sudo bash - | |
| # |
| brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-frei0r --with-libass --with-libvo-aacenc --with-libvorbis --with-libvpx --with-opencore-amr --with-openjpeg --with-opus --with-rtmpdump --with-schroedinger --with-speex --with-theora --with-tools --with-libogg |
| // Under WTFPL license ;) | |
| function ancestors(obj) { | |
| var hierarchy = []; | |
| if (['boolean', 'number', 'string', 'undefined'].indexOf(typeof obj) !== -1 || obj === null) { // primitives types | |
| obj = Object(obj); | |
| } else if (typeof obj === 'function') { | |
| hierarchy.push( | |
| obj.name || | |
| (obj.toString().match(/function (\w*)/) || | |
| obj.toString().match(/\[object (\w*)\]/))[1] || |
| root = true | |
| [*] | |
| charset = utf-8 | |
| indent_style = space | |
| indent_size = 2 | |
| end_of_line = lf | |
| trim_trailing_whitespace = true | |
| insert_final_newline = true |
| { | |
| "node": true, | |
| "browser": false, | |
| "esnext": true, | |
| "bitwise": true, | |
| "camelcase": true, | |
| "curly": true, | |
| "eqeqeq": true, | |
| "immed": true, | |
| "indent": 2, |
| (function (global) { | |
| 'use strict'; | |
| /*\ | |
| |*| | |
| |*| Base64 / binary data / UTF-8 strings utilities | |
| |*| | |
| |*| https://developer.mozilla.org/en-US/docs/Web/JavaScript/Base64_encoding_and_decoding | |
| |*| | |
| \*/ |
| function base64UTF8Decode(str) { | |
| return unescape(decodeURIComponent(window.atob(str))) | |
| } |
| add_header Access-Control-Allow-Origin *; | |
| add_header Access-Control-Allow-Headers *; | |
| add_header Access-Control-Allow-Methods GET, POST, OPTIONS; | |
| add_header Access-Control-Allow-Credentials true; |
| function uuid() { | |
| var uuid = "", i, random; | |
| for (i = 0; i < 32; i++) { | |
| random = Math.random() * 16 | 0; | |
| if (i == 8 || i == 12 || i == 16 || i == 20) uuid += "-" | |
| uuid += (i == 12 ? 4 : (i == 16 ? (random & 3 | 8) : random)).toString(16) | |
| } | |
| return uuid | |
| } |
Create a fully self-contained executable of a web application with an embedded HTTP server using nar
Install nar as global package (you must have node.js already installed in your system)
$ npm install -g nar