InterviewSolution
| 1. |
What is Express.js Generator? |
|
Answer» With Express.js Generator or simply express-generator, we can quickly generate a daily COMPLEX skeleton of an Express.js app. Now, the app generated comes with a lot of structures and even Jade template. To generate an app with express-generator, first we need to create a folder with the NAME of the app. After that go inside the folder and then give the command npx express-generator to create the app. Now, we need to install the dependencies in the app with the npm i command. Finally, we will start the app with the npm start command.Now, we can go to http://localhost:3000/ and SEE that we have an html output. Our app starting point is app.js file, which contains all the required imports and it’s call to two routes. The route at index.js contains the title of Express and this gets PASSED to the index.jade file. Now, the templating engine of Jade, uses its own language to show the content in http://localhost:3000/ As we can see from the above example, a fairly complex app was set up with DIFFERENT routes and templates. These templates will be shown on the client browser, when they reach the endpoints. By using the templates, we don’t even need a frontend client code and the code will be generated by the backend itself. |
|