Creating the image upload server

We have finished building the services. Now let's build the image storage server. The image storage server defines the routes using which an image can be stored, deleted, or retrieved.

Open the Initial/image-storage directory. Inside the directory, you will find a package.json file and an app.js file. The app.js file is where you will write the code, and package.json lists the dependencies for the image storage server. The upload service is dependent on express, connect-multiparty, path, and fs. Run the npm install command inside Initial/image-storage to install the dependencies locally.

The following is the code to import the modules:

var express = require("express"); var app = express(); var fs = require("fs"); ...

Get JavaScript: Moving to ES2015 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.