- Express:
- express-force-ssl: https://www.npmjs.com/package/express-force-ssl
- express-session: https://www.npmjs.com/package/express-session
- cors: https://www.npmjs.com/package/cors
- compression: https://www.npmjs.com/package/compression
- body-parser: https://www.npmjs.com/package/body-parser
- greenlock-express: https://www.npmjs.com/package/greenlock-express
- helmet: https://github.com/helmetjs/helmet
- hsts: https://github.com/helmetjs/hsts
- GraphQL & Relay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// do we have errors? | |
if (condition === false) { | |
return new Error('reason goes here') || Promise.reject(new Error('reason goes here')); // either | |
} | |
// are tasks needed? | |
if (condition === false) { | |
return tasks(); | |
} | |
return Promise.resolve(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// unfinished | |
let externalVariable = 1; | |
class Externa{ | |
constructor () { | |
this.map = new Map(); | |
} | |
set x (value) { | |
this.map.set('x', value); | |
} | |
get x () { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable no-undef */ | |
// http://keycode.info | |
class Keylock { | |
constructor(key) { | |
this.keyCode = key.charCodeAt(0); | |
this.isDown = false; | |
this.isUp = true; | |
this.onPress = undefined; | |
this.onRelease = undefined; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://stackoverflow.com/a/49825905 |
- Adding package on windows
- Install Windows SDK 8.1 https://developer.microsoft.com/en-us/windows/downloads/sdk-archive
- Create folder
C:\OpenSSL-Win64\
(exact) - Download
http://www.indyproject.org/Sockets/fpc/AMD64-Win64OpenSSL-0_9_8g.zip
- (or from here:
http://www.indyproject.org/Sockets/fpc/OpenSSLforWin64.en.aspx
) - Extract to folder
cd C:\OpenSSL-Win64
mkdir lib
copy libeay32.lib lib
yarn add greenlock ursa
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* eslint-disable no-console, no-undef, arrow-body-style */ | |
import sha256 from 'fast-sha256/sha256'; | |
import pako from 'pako'; | |
import msgpack5 from 'msgpack5'; | |
import nacl from 'tweetnacl'; | |
import naclutils from 'tweetnacl-util'; | |
import prettybytes from 'pretty-bytes'; | |
export const fromUTF8 = naclutils.decodeUTF8; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 'downloadFile.js', written by blending two solutions: | |
// 'js-download' https://github.com/kennethjiang/js-file-download | |
// 'Anders Paulsen' https://blog.jayway.com/2017/07/13/open-pdf-downloaded-api-javascript/ | |
export function downloadFile(data, filename, mime) { | |
// It is necessary to create a new blob object with mime-type explicitly set | |
// otherwise only Chrome works like it should | |
const blob = new Blob([data], {type: mime || 'application/octet-stream'}); | |
if (typeof window.navigator.msSaveBlob !== 'undefined') { | |
// IE doesn't allow using a blob object directly as link href. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var saveData = (function () { | |
var a = document.createElement("a"); | |
document.body.appendChild(a); | |
a.style = "display: none"; | |
return function (data, fileName) { | |
var json = JSON.stringify(data), | |
blob = new Blob([json], {type: "octet/stream"}), | |
url = window.URL.createObjectURL(blob); | |
a.href = url; | |
a.download = fileName; |