1 |
|
2 |
|
3 |
|
4 |
|
5 | [![alt text][1.1]][1]
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | [1.1]: http://i.imgur.com/tXSoThF.png (twitter icon with padding)
|
14 |
|
15 |
|
16 |
|
17 | [1.2]: http://i.imgur.com/wWzX9uB.png (twitter icon without padding)
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | [1]: http://www.twitter.com/restifyjs
|
24 |
|
25 |
|
26 |
|
27 | ![restify](/../gh-images/logo/png/restify_logo_black_transp_288x288.png?raw=true "restify")
|
28 |
|
29 | [![Build Status](https://travis-ci.org/restify/node-restify.svg?branch=master)](https://travis-ci.org/restify/node-restify)
|
30 | [![Dependency Status](https://david-dm.org/restify/node-restify.svg)](https://david-dm.org/restify/node-restify)
|
31 | [![devDependency Status](https://david-dm.org/restify/node-restify/dev-status.svg)](https://david-dm.org/restify/node-restify#info=devDependencies)
|
32 | [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
|
33 |
|
34 | [restify](http://restify.com) is a framework, utilizing
|
35 | [connect](https://github.com/senchalabs/connect) style middleware for building
|
36 | REST APIs. For full details, see http://restify.com
|
37 |
|
38 | Follow restify on [![alt text][1.2]][1]
|
39 |
|
40 | # Usage
|
41 |
|
42 | ## Server
|
43 | ```javascript
|
44 | var restify = require('restify');
|
45 |
|
46 | const server = restify.createServer({
|
47 | name: 'myapp',
|
48 | version: '1.0.0'
|
49 | });
|
50 |
|
51 | server.use(restify.plugins.acceptParser(server.acceptable));
|
52 | server.use(restify.plugins.queryParser());
|
53 | server.use(restify.plugins.bodyParser());
|
54 |
|
55 | server.get('/echo/:name', function (req, res, next) {
|
56 | res.send(req.params);
|
57 | return next();
|
58 | });
|
59 |
|
60 | server.listen(8080, function () {
|
61 | console.log('%s listening at %s', server.name, server.url);
|
62 | });
|
63 | ```
|
64 |
|
65 | ## Client
|
66 | ```javascript
|
67 | var assert = require('assert');
|
68 | var clients = require('restify-clients');
|
69 |
|
70 | var client = clients.createJsonClient({
|
71 | url: 'http://localhost:8080',
|
72 | version: '~1.0'
|
73 | });
|
74 |
|
75 | client.get('/echo/mark', function (err, req, res, obj) {
|
76 | assert.ifError(err);
|
77 | console.log('Server returned: %j', obj);
|
78 | });
|
79 | ```
|
80 |
|
81 | # Installation
|
82 | ```bash
|
83 | $ npm install restify
|
84 | ```
|
85 | ## License
|
86 |
|
87 | The MIT License (MIT)
|
88 |
|
89 | Copyright (c) 2018 restify
|
90 |
|
91 | Permission is hereby granted, free of charge, to any person obtaining a copy of
|
92 | this software and associated documentation files (the "Software"), to deal in
|
93 | the Software without restriction, including without limitation the rights to
|
94 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
95 | the Software, and to permit persons to whom the Software is furnished to do so,
|
96 | subject to the following conditions:
|
97 |
|
98 | The above copyright notice and this permission notice shall be included in all
|
99 | copies or substantial portions of the Software.
|
100 |
|
101 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
102 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
103 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
104 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
105 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
106 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
107 | SOFTWARE.
|
108 |
|
109 | ## Bugs
|
110 |
|
111 | See <https://github.com/restify/node-restify/issues>.
|
112 |
|
113 | ## Other repositories
|
114 |
|
115 | - For the errors module, please go [here](https://github.com/restify/errors).
|
116 |
|
117 |
|
118 | ## Mailing list
|
119 |
|
120 | See the
|
121 | [Google group](https://groups.google.com/forum/?hl=en&fromgroups#!forum/restify)
|
122 | .
|