1 |
3a515b92
|
cagy
|
[](http://expressjs.com/)
|
2 |
|
|
|
3 |
|
|
Fast, unopinionated, minimalist web framework for [node](http://nodejs.org).
|
4 |
|
|
|
5 |
|
|
[![NPM Version][npm-image]][npm-url]
|
6 |
|
|
[![NPM Downloads][downloads-image]][downloads-url]
|
7 |
|
|
[![Linux Build][travis-image]][travis-url]
|
8 |
|
|
[![Windows Build][appveyor-image]][appveyor-url]
|
9 |
|
|
[![Test Coverage][coveralls-image]][coveralls-url]
|
10 |
|
|
|
11 |
|
|
```js
|
12 |
|
|
const express = require('express')
|
13 |
|
|
const app = express()
|
14 |
|
|
|
15 |
|
|
app.get('/', function (req, res) {
|
16 |
|
|
res.send('Hello World')
|
17 |
|
|
})
|
18 |
|
|
|
19 |
|
|
app.listen(3000)
|
20 |
|
|
```
|
21 |
|
|
|
22 |
|
|
## Installation
|
23 |
|
|
|
24 |
|
|
This is a [Node.js](https://nodejs.org/en/) module available through the
|
25 |
|
|
[npm registry](https://www.npmjs.com/).
|
26 |
|
|
|
27 |
|
|
Before installing, [download and install Node.js](https://nodejs.org/en/download/).
|
28 |
|
|
Node.js 0.10 or higher is required.
|
29 |
|
|
|
30 |
|
|
Installation is done using the
|
31 |
|
|
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
32 |
|
|
|
33 |
|
|
```bash
|
34 |
|
|
$ npm install express
|
35 |
|
|
```
|
36 |
|
|
|
37 |
|
|
Follow [our installing guide](http://expressjs.com/en/starter/installing.html)
|
38 |
|
|
for more information.
|
39 |
|
|
|
40 |
|
|
## Features
|
41 |
|
|
|
42 |
|
|
* Robust routing
|
43 |
|
|
* Focus on high performance
|
44 |
|
|
* Super-high test coverage
|
45 |
|
|
* HTTP helpers (redirection, caching, etc)
|
46 |
|
|
* View system supporting 14+ template engines
|
47 |
|
|
* Content negotiation
|
48 |
|
|
* Executable for generating applications quickly
|
49 |
|
|
|
50 |
|
|
## Docs & Community
|
51 |
|
|
|
52 |
|
|
* [Website and Documentation](http://expressjs.com/) - [[website repo](https://github.com/expressjs/expressjs.com)]
|
53 |
|
|
* [#express](https://webchat.freenode.net/?channels=express) on freenode IRC
|
54 |
|
|
* [GitHub Organization](https://github.com/expressjs) for Official Middleware & Modules
|
55 |
|
|
* Visit the [Wiki](https://github.com/expressjs/express/wiki)
|
56 |
|
|
* [Google Group](https://groups.google.com/group/express-js) for discussion
|
57 |
|
|
* [Gitter](https://gitter.im/expressjs/express) for support and discussion
|
58 |
|
|
|
59 |
|
|
**PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/expressjs/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/expressjs/express/wiki/New-features-in-4.x).
|
60 |
|
|
|
61 |
|
|
### Security Issues
|
62 |
|
|
|
63 |
|
|
If you discover a security vulnerability in Express, please see [Security Policies and Procedures](Security.md).
|
64 |
|
|
|
65 |
|
|
## Quick Start
|
66 |
|
|
|
67 |
|
|
The quickest way to get started with express is to utilize the executable [`express(1)`](https://github.com/expressjs/generator) to generate an application as shown below:
|
68 |
|
|
|
69 |
|
|
Install the executable. The executable's major version will match Express's:
|
70 |
|
|
|
71 |
|
|
```bash
|
72 |
|
|
$ npm install -g express-generator@4
|
73 |
|
|
```
|
74 |
|
|
|
75 |
|
|
Create the app:
|
76 |
|
|
|
77 |
|
|
```bash
|
78 |
|
|
$ express /tmp/foo && cd /tmp/foo
|
79 |
|
|
```
|
80 |
|
|
|
81 |
|
|
Install dependencies:
|
82 |
|
|
|
83 |
|
|
```bash
|
84 |
|
|
$ npm install
|
85 |
|
|
```
|
86 |
|
|
|
87 |
|
|
Start the server:
|
88 |
|
|
|
89 |
|
|
```bash
|
90 |
|
|
$ npm start
|
91 |
|
|
```
|
92 |
|
|
|
93 |
|
|
View the website at: http://localhost:3000
|
94 |
|
|
|
95 |
|
|
## Philosophy
|
96 |
|
|
|
97 |
|
|
The Express philosophy is to provide small, robust tooling for HTTP servers, making
|
98 |
|
|
it a great solution for single page applications, web sites, hybrids, or public
|
99 |
|
|
HTTP APIs.
|
100 |
|
|
|
101 |
|
|
Express does not force you to use any specific ORM or template engine. With support for over
|
102 |
|
|
14 template engines via [Consolidate.js](https://github.com/tj/consolidate.js),
|
103 |
|
|
you can quickly craft your perfect framework.
|
104 |
|
|
|
105 |
|
|
## Examples
|
106 |
|
|
|
107 |
|
|
To view the examples, clone the Express repo and install the dependencies:
|
108 |
|
|
|
109 |
|
|
```bash
|
110 |
|
|
$ git clone git://github.com/expressjs/express.git --depth 1
|
111 |
|
|
$ cd express
|
112 |
|
|
$ npm install
|
113 |
|
|
```
|
114 |
|
|
|
115 |
|
|
Then run whichever example you want:
|
116 |
|
|
|
117 |
|
|
```bash
|
118 |
|
|
$ node examples/content-negotiation
|
119 |
|
|
```
|
120 |
|
|
|
121 |
|
|
## Tests
|
122 |
|
|
|
123 |
|
|
To run the test suite, first install the dependencies, then run `npm test`:
|
124 |
|
|
|
125 |
|
|
```bash
|
126 |
|
|
$ npm install
|
127 |
|
|
$ npm test
|
128 |
|
|
```
|
129 |
|
|
|
130 |
|
|
## Contributing
|
131 |
|
|
|
132 |
|
|
[Contributing Guide](Contributing.md)
|
133 |
|
|
|
134 |
|
|
## People
|
135 |
|
|
|
136 |
|
|
The original author of Express is [TJ Holowaychuk](https://github.com/tj)
|
137 |
|
|
|
138 |
|
|
The current lead maintainer is [Douglas Christopher Wilson](https://github.com/dougwilson)
|
139 |
|
|
|
140 |
|
|
[List of all contributors](https://github.com/expressjs/express/graphs/contributors)
|
141 |
|
|
|
142 |
|
|
## License
|
143 |
|
|
|
144 |
|
|
[MIT](LICENSE)
|
145 |
|
|
|
146 |
|
|
[npm-image]: https://img.shields.io/npm/v/express.svg
|
147 |
|
|
[npm-url]: https://npmjs.org/package/express
|
148 |
|
|
[downloads-image]: https://img.shields.io/npm/dm/express.svg
|
149 |
|
|
[downloads-url]: https://npmjs.org/package/express
|
150 |
|
|
[travis-image]: https://img.shields.io/travis/expressjs/express/master.svg?label=linux
|
151 |
|
|
[travis-url]: https://travis-ci.org/expressjs/express
|
152 |
|
|
[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/express/master.svg?label=windows
|
153 |
|
|
[appveyor-url]: https://ci.appveyor.com/project/dougwilson/express
|
154 |
|
|
[coveralls-image]: https://img.shields.io/coveralls/expressjs/express/master.svg
|
155 |
|
|
[coveralls-url]: https://coveralls.io/r/expressjs/express?branch=master
|