UNPKG

3.83 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
86## Supported Node Versions
87
88Restify currently works on Node.js v14.x and v16.x.
89
90## License
91
92The MIT License (MIT)
93
94Copyright (c) 2018 restify
95
96Permission is hereby granted, free of charge, to any person obtaining a copy of
97this software and associated documentation files (the "Software"), to deal in
98the Software without restriction, including without limitation the rights to
99use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
100the Software, and to permit persons to whom the Software is furnished to do so,
101subject to the following conditions:
102
103The above copyright notice and this permission notice shall be included in all
104copies or substantial portions of the Software.
105
106THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
107IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
108FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
109AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
110LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
111OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
112SOFTWARE.
113
114## Bugs
115
116See <https://github.com/restify/node-restify/issues>.
117
118## Other repositories
119
120- For the errors module, please go [here](https://github.com/restify/errors).
121
122
123## Mailing list
124
125See the
126[Google group](https://groups.google.com/forum/?hl=en&fromgroups#!forum/restify)
127.