HI WELCOME TO SIRIS

Express.js Scaffolding

Leave a Comment

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.
  1. 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:
  1. 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:
  1. var express = require('express');  
  2. var app = express();  
  3. app.get('/', function (req, res) {  
  4.   res.send('Welcome to JavaTpoint!');  
  5. });  
  6. app.listen(8000, function () {  
  7.   console.log('Example app listening on port 8000!');  
  8. });  
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

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.