sudo pacman -Suy rpmextractwget https://www.kraxel.org/repos/jenkins/edk2/edk2.git-ovmf-x64-XXXXXX.noarch.rpm| const requestContainer = { | |
| request: { | |
| headers: { | |
| 'Content-type': 'text/html' | |
| } | |
| }, | |
| context: { | |
| host: 'example.com' | |
| } | |
| } |
| # Ask for the user password | |
| # Script only works if sudo caches the password for a few minutes | |
| sudo true | |
| # Install kernel extra's to enable docker aufs support | |
| # sudo apt-get -y install linux-image-extra-$(uname -r) | |
| # Add Docker PPA and install latest version | |
| sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 | |
| sudo sh -c "echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list" |
| // middleware with same function signature | |
| const middleware = [ | |
| (req, res) => { | |
| return { | |
| ...res, | |
| test: req.ref1 | |
| } | |
| }, | |
| (req, res) => { | |
| return { |
Functional programming gets a bad wrap about being too hard for mere mortals to comprehend. This is nonsense. The concepts are actually quite simple to grasp.
The jargon is the hardest part. A lot of that vocabulary comes from a specialized field of mathematical study called category theory (with a liberal sprinkling of type theory and abstract algebra). This sounds a lot scarier than it is. You can do this!
All examples using ES6 syntax. wrap (foo) => bar means:
function wrap (foo) {| var WebSocket = require('ws'); | |
| var userPublicToken = 'apikey'; | |
| var username = 'username'; | |
| var ws = new WebSocket('wss://stream.tutum.co/v1/events?token='+ userPublicToken +'&user=' +username); | |
| ws.on('open', function() { | |
| console.log('Connected'); | |
| }); |
To implement API authentication in KeystoneJS, you need the following:
For key based authentication
For session based authentication
This is an example of how to scaffold API endpoints to list / get / create / update / delete Posts in a Keystone website.
It's a modification of the default project created with the yo keystone generator (see https://github.com/JedWatson/generator-keystone)
Gists don't let you specify full paths, so in the project structure the files would be:
routes-index.js --> /routes/index.js // modified to add the api endpoints
routes-api-posts.js --> /routes/api/posts.js // new file containing the Post API route controllers
| function mixin(...mixins) { | |
| class Mixed { | |
| constructor() { | |
| for (let mixin of mixins) { | |
| const props = Object.getOwnPropertyNames(mixin.prototype) | |
| for (let prop of props) { | |
| if (prop === 'constructor') { | |
| // call constructor of mixin | |
| mixin.apply(this) // fails | |
| } else { |