What is a RESTful API

One sentence summary, a very high degree of extensible design interface specification, is essentially the interface design guidance, more details refer to my another article about a REST Api blog.csdn.net/geeklevin/a…

In NodeJS, there are many JS libraries that can be used to make Restful apis, such as the traditional Express (HTTP server), or the KOA framework, which uses Restify.

Restify uses a simple and lightweight framework for creating restful apis. See restify.com/

 

Start making interfaces

Checkout the helloworld project that we created, and make changes based on that.

The steps are as follows:

  • Add restify library
  • Write your first API using Restify

Add restify library

Use the command: NPM install -g restify

In package.json devDependencies, you can see a restify JS library.

Write the first API:

Go to the project directory and run it with Node app.js.

Caption

sample code

First look at the effect:

Restify is the first example

Code parsing:

 

Ok, here we write an interface that allows users to link to http://localhost:8080/hello/levin

Click access to view the results, the code links: codechina.csdn.net/geeklevin/n… I will continue writing articles on interface development later.