UNPKG

3.75 kBMarkdownView Raw
1<!-- Please don't remove this: Grab your social icons from https://github.com/carlsednaoui/gitsocial -->
2
3<!-- display the social media buttons in your README -->
4
5[![alt text][1.1]][1]
6
7
8<!-- links to social media icons -->
9<!-- no need to change these -->
10
11<!-- icons with padding -->
12
13[1.1]: http://i.imgur.com/tXSoThF.png (twitter icon with padding)
14
15<!-- icons without padding -->
16
17[1.2]: http://i.imgur.com/wWzX9uB.png (twitter icon without padding)
18
19
20<!-- links to your social media accounts -->
21<!-- update these accordingly -->
22
23[1]: http://www.twitter.com/restifyjs
24
25<!-- Please don't remove this: Grab your social icons from https://github.com/carlsednaoui/gitsocial -->
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
36REST APIs. For full details, see http://restify.com
37
38Follow restify on [![alt text][1.2]][1]
39
40# Usage
41
42## Server
43```javascript
44var restify = require('restify');
45
46const server = restify.createServer({
47 name: 'myapp',
48 version: '1.0.0'
49});
50
51server.use(restify.plugins.acceptParser(server.acceptable));
52server.use(restify.plugins.queryParser());
53server.use(restify.plugins.bodyParser());
54
55server.get('/echo/:name', function (req, res, next) {
56 res.send(req.params);
57 return next();
58});
59
60server.listen(8080, function () {
61 console.log('%s listening at %s', server.name, server.url);
62});
63```
64
65## Client
66```javascript
67var assert = require('assert');
68var clients = require('restify-clients');
69
70var client = clients.createJsonClient({
71 url: 'http://localhost:8080',
72 version: '~1.0'
73});
74
75client.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
87The MIT License (MIT)
88
89Copyright (c) 2018 restify
90
91Permission is hereby granted, free of charge, to any person obtaining a copy of
92this software and associated documentation files (the "Software"), to deal in
93the Software without restriction, including without limitation the rights to
94use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
95the Software, and to permit persons to whom the Software is furnished to do so,
96subject to the following conditions:
97
98The above copyright notice and this permission notice shall be included in all
99copies or substantial portions of the Software.
100
101THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
102IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
103FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
104AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
105LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
106OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
107SOFTWARE.
108
109## Bugs
110
111See <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
120See the
121[Google group](https://groups.google.com/forum/?hl=en&fromgroups#!forum/restify)
122.