Express Web Framework (Node.js/JavaScript)

2018-08-22 14:05 更新

先決條件

在啟動此模塊之前,您需要了解什么是服務(wù)器端Web編程和Web框架,最好是閱讀我們的服務(wù)器端網(wǎng)站編程第一步模塊中的主題 。 強(qiáng)烈建議您了解編程概念和 JavaScript 的一般知識,但不必了解核心概念 。

注意:此網(wǎng)站有許多有用的資源,可用于在客戶端開發(fā)環(huán)境下學(xué)習(xí)JavaScript : -CN / docs / Web / JavaScript"> JavaScript , JavaScript指南 , JavaScript基礎(chǔ), JavaScript (學(xué)習(xí))。 核心JavaScript語言和概念對于Node.js上的服務(wù)器端開發(fā)是相同的,這種材料將是相關(guān)的。 Node.js提供其他API ,用于支持 在無瀏覽器環(huán)境中有用,例如 創(chuàng)建HTTP服務(wù)器并訪問文件系統(tǒng),但不支持使用瀏覽器和DOM的JavaScript API。

本指南將提供有關(guān)使用Node.js和Express的一些信息,Internet上和書中還有許多其他優(yōu)秀的資源 - 其中一些鏈接從 / 894359"class ="external">如何開始使用Node.js (StackOverflow)和 for-learning-Node-js?" class ="external">學(xué)習(xí)Node.js最好的資源是什么?(Quora)。

指南

Express/Node introduction
In this first Express article we answer the questions "What is Node?" and "What is Express?" and give you an overview of what makes the Express web framework special. We'll outline the main features, and show you some of the main building blocks of an Express application (although at this point you won't yet have a development environment in which to test it).
Setting up a Node (Express) development environment
Now that you know what Express is for, we'll show you how to set up and test a Node/Express development environment on Windows, Linux (Ubuntu), and Mac OS X. Whatever common operating system you are using, this article should give you what you need to be able to start developing Express apps.
Express Tutorial: The Local Library website
The first article in our practical tutorial series explains what you'll learn, and provides an overview of the "local library" example website we'll be working through and evolving in subsequent articles.
Express Tutorial Part 2: Creating a skeleton website
This article shows how you can create a "skeleton" website project, which you can then go on to populate with site-specific routes, templates/views and databases.
Express Tutorial Part 3: Using a Database (with Mongoose)
This article briefly introduces databases for Node/Express. It then goes on to show how we can use Mongoose to provide database access for the LocalLibrary website. It explains how object schema and models are declared, the main field types, and basic validation. It also briefly shows a few of the main ways you can access model data.
Express Tutorial Part 4: Routes and controllers
In this tutorial we'll set up routes (URL handling code) with "dummy" handler functions for all the resource endpoints that we'll eventually need in the LocalLibrary website. On completion we'll have a modular structure for our route handling code, that we can extend with real handler functions in the following articles. We'll also have a really good understanding of how to create modular routes using Express.
Express Tutorial Part 5: Displaying library data
We're now ready to add the pages that display the LocalLibrary website books and other data. The pages will include a home page that shows how many records we have of each model type, and list and detail pages for all of our models. Along the way we'll gain practical experience in getting records from the database, and using templates.
Express Tutorial Part 6: Working with forms
In this tutorial we'll show you how to work with HTML Forms in Express, using Pug, and in particular how to write forms to create, update, and delete documents from the database.
Express Tutorial Part 7: Deploying to production
Now you've created an awesome LocalLibrary website, you're going to want to install it on a public web server so that it can be accessed by library staff and members over the Internet. This article provides an overview of how you might go about finding a host to deploy your website, and what you need to do in order to get your site ready for production.

注意:這是教程文章的結(jié)尾(目前為止)。 如果你想擴(kuò)展它,其他有趣的話題包括:

  • Using sessions
  • User authentication
  • User authorisation and permissions
  • Testing an Express web application
  • Web security for Express web applications.

當(dāng)然,有一個評估任務(wù)是非常好的!

以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號