Express.js Scaffolding

What is scaffolding

Scaffolding is a technique that is supported by some MVC frameworks.

It is mainly supported by the following frameworks:

Ruby on Rails,OutSystems Platform, Express Framework, Play framework, Django, MonoRail, Brail, Symfony, Laravel, CodeIgniter, Yii, CakePHP, Phalcon PHP, Model-Glue, PRADO, Grails, Catalyst, Seam Framework, Spring Roo, ASP.NET etc.

Scaffolding facilitates the programmers to specify how the application data may be used. This specification is used by the frameworks with predefined code templates, to generate the final code that the application can use for CRUD operations (create, read, update and delete database entries).

Express.js Scaffold

An Express.js scaffold supports candy and more web projects based on Node.js.

Install scaffold

Execute the following command to install scaffold.

snippet
npm install express-scaffold

It will take a few seconds and the screen will look like this:

ExpressJs Scaffold 1

After this step, execute the following command to install express generator:

snippet
npm install -g express-generator
ExpressJs Scaffold 2

Now, you can use express to scaffold a web-app.

Let's take an example:

First create a directory named myapp. Create a file named app.js in the myapp directory having the following code:

snippet
var express = require('express');
var app = express();
app.get('/', function (req, res) {
  res.send('Welcome to rookienerd!');
});
app.listen(8000, function () {
  console.log('Example app listening on port 8000!');
});

Open Node.js command prompt, go to myapp and run npm init command (In my case, I have created myapp folder on desktop)

ExpressJs Scaffold 3

Fill the entries and press enter.

ExpressJs Scaffold 4

It will create a package.json file in myapp folder and the data is shown in JSON format.

ExpressJs Scaffold 5

Output:

ExpressJs Scaffold 6
Related Tutorial
Follow Us
https://www.facebook.com/Rookie-Nerd-638990322793530 https://twitter.com/RookieNerdTutor https://plus.google.com/b/117136517396468545840 #
Contents +