Blockchain Nanodegree Notes 20181111

Lesson 2 Web Services with Node.js

Introduction

RESTful Frameworks: gives you access to guidelines and tools that help you develop applications more efficiently.

REST (Representational State Transfer): Set of rules that defines guidelines based on the HTTP protocol.

Framework: Set of tools and guidelines designed to support the development of web applications.

Why use a framework

  • Build rapidly
  • Access code that’s been built and tested
  • Help extend functionality

13 Node.js frameworks

https://nordicapis.com/13-node-js-frameworks-to-build-web-apis/

Framework Homepages

Expressjs.com

Sailsjs.com

Hapijs.com

Express.js

Tools we’ll use

  • Expressjs.com for documentation
  • Your Local Desktop
  • A Terminal Window
  • Code Editor (I’m using VS Code)
  • Another Browser window (to view your application)

Preparation

npm init

touch index.js

npm install express --save

Express.js: Get Started

https://expressjs.com/en/starter/hello-world.html

Express.js Hello World Code

const express = require('express')
const app = express()

app.get('/', (req, res) => res.send('Hello World!'))

app.listen(3000, () => console.log('Example app listening on port 3000!'))

node index.js

open localhost:3000 in the browser

Express.js Conclusion

List of books and blogs on their site here.

Each of the modules along with their documentation are listed here.

Practice Express.js

Step 1Clone the project repository in this Github repository
Step 2Open the terminal and install the packages: npm install
Step 3Open the file app.js and blockcontroller.js and start coding - See additional info below
Step 4Run your application node app.js
Step 5Use Curl or Postman to test the endpoints

Additional Info for Step 3

Review the boilerplate code

After you’ve cloned your repository and installed the node packages using npm install, you will need to install the following packages:

  • “body-parser”: “^1.18.3”,
  • “crypto-js”: “^3.1.9-1”,
  • “express”: “^4.16.3”

The package body-parser allows you to parse incoming request bodies in a middleware before your handlers, available under the req.body property. For more documentation visit this link.

The package crypto-js you are being using it a lot during this course so far however if you need extra support feel free to read about it in the following link.

The package expressis the most important package because it allows you to use the Express Framework features to create your RESTful API. Check the documentation so you’ll be familiarized with the core concepts of this framework in this link.

Hapi.js

Getting started

https://hapijs.com/tutorials

Practice hapi.js

Step 1Clone the project repository in this Github repository
Step 2Open the terminal and install the packages: npm install
Step 3Open the file app.js and blockcontroller.js and start coding - See additional info below
Step 4Run your application node app.js
Step 5Use Curl or Postman to test the endpoints

Additional Info for Step 3

Review the boilerplate code

After you’ve cloned your repository and installed the node packages using npm install, you’ll need to install the following packages:

  • “crypto-js”: “^3.1.9-1”,
  • “hapi”: “^17.6.0”

The package crypto-js you are being using it a lot during this course so far; however, if you need extra support feel free to read about it in the following link.

The package hapiis the most important package because it allows you to use the Hapi Framework features to create your RESTful API. Check the documentation so you’ll be familiarized with the core concepts of this framework in this link

Sails.js

Getting Started

https://sailsjs.com

https://sailsjs.com/get-started

Sails.js Environment Resources

If you are unable to install the environment locally, you can find the default structure of a sails.js application here.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值