rand(Ø)

> beautiful code & photos

about <

Posts tagged: nodejs

Ghost: How I moved my images to Cloudinary

For the past two weeks, I have been very busy moving all my Ghost apps images over to Cloudinary. As you probably know, my Photography Portfolio is running with Ghost and even there is not a ton of content, I needed to ensure it could meet these requirements:

  1. Deliver top quality images faster than my hosting solution
  2. Support RetinaJS assets upload via Ghost

If I was pretty confident with the 1st requirement, the 2nd was a tricky one in addition to move all existing content in Cloudinary.

A new Cloudinary storage adapter for Ghost

I looked for existing

> Continue Reading

Chakram & JSON schema structuring

I know, Chakram is old (no update over a year) but I use it in one of my project because along with Mocha and Chai, it makes a pretty powerful tool for a NodeJS functional testing stack.

For the past few hours, I've been trying to reference a JSON schema from another one stored in the very same directory.

Understanding the documentation about structuring JSON schema is pretty straightforward but in real life, it gets more complicated when you don't fully understand how it really works (and I still don't, don't get me wrong).

The issue

Let's say, I have

> Continue Reading

Nunjucks: inject Express request to templates

On my free time, I recently started to think about the next version of my photography portfolio which starts to be old and especially is not designed to be effectively browsable on tablets.
And, there are also other things I'd like to fix...

Anyway, as I recently got some basic skills in NodeJS, I challenged myself to rewrite my dear portfolio with this technology. I looked for an interesting templating engine not too far from Twig which I like a lot then I chose to go with Nunjucks, which is very similar and seems not to be dead.

In my

> Continue Reading

JS: Singleton as a module

When you develop a NodeJS application, you probably get to work with services and as much as possible with service dependency injection.
As I worked quite a lot with Symfony lately, I wanted to be able to manage my NodeJS services as it should be, and in some case, like a database connection: a single instance for the whole script.

I quicky looked onto Internet to see how to build a singleton in JavaScript (pardon my weak skills in this language) and I quickly found what I was (almost) looking for.

Code examples provided in the different posts I've read

> Continue Reading

NodeJS: Quick dev server

I'm on a nice project where I need to develop a kind of proxy in NodeJS. When you work to forward data after possible filtering or transformation, it's never too easy to quickly set up an environment in order to test your on-going development.

Using NodeJS, I extended my colleague very small HTTP server that just returns a 201 HTTP code and prints the request body in the console:

// debug-server.js
var http = require('http');
var port = process.env.PORT || 8080;
var host = '127.0.0.1';

http.createServer(function (request, response) {
    // console.log(request.headers);
    request.pipe(process.stdout)
> Continue Reading