forked from expressjs/expressjs.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9e957d4
Showing
123 changed files
with
2,781 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
.DS_Store | ||
api.html | ||
index.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
expressjs.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
JADE = ./node_modules/.bin/jade | ||
|
||
HTML = index.html \ | ||
api.html \ | ||
guide.html \ | ||
applications.html \ | ||
community.html \ | ||
faq.html | ||
|
||
docs: $(HTML) | ||
|
||
%.html: %.jade | ||
$(JADE) --path $< < $< > $@ | ||
|
||
clean: | ||
rm -f *.html | ||
|
||
.PHONY: docs clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
# ExpressJS.com | ||
|
||
The site for Express. | ||
|
||
## Building | ||
|
||
Setup: | ||
|
||
``` | ||
$ npm install -g serve | ||
$ npm install | ||
$ make | ||
$ serve . & | ||
$ open http://localhost:3000 | ||
``` | ||
|
||
then rebuild changes with: | ||
|
||
``` | ||
$ make | ||
``` | ||
|
||
## Contributing | ||
|
||
- __dont__ edit the HTML directly, edit the _jade_. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
!!! 5 | ||
html | ||
head | ||
title Express - api reference | ||
include includes/head | ||
body.inner | ||
.bar | ||
section#content | ||
header | ||
include includes/logo | ||
active = '/api.html' | ||
include includes/menu | ||
|
||
include includes/mixins | ||
|
||
include en/api/menu | ||
|
||
#right | ||
include en/api/express | ||
|
||
h2 Application | ||
a(name='application') | ||
include en/api/app | ||
|
||
h2 Request | ||
a(name='request') | ||
include en/api/req | ||
|
||
h2 Response | ||
a(name='response') | ||
include en/api/res | ||
|
||
include includes/footer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
|
||
o = $; | ||
|
||
// misc junk | ||
|
||
o(function(){ | ||
var width = window.innerWidth; | ||
var height = window.innerHeight; | ||
var doc = o(document); | ||
|
||
// .onload | ||
o('html').addClass('onload'); | ||
|
||
// top link | ||
o('#top').click(function(e){ | ||
o('body').animate({ scrollTop: 0 }, 'fast'); | ||
e.preventDefault(); | ||
}); | ||
|
||
// scrolling links | ||
var added; | ||
doc.scroll(function(e){ | ||
if (doc.scrollTop() > 5) { | ||
if (added) return; | ||
added = true; | ||
o('body').addClass('scroll'); | ||
} else { | ||
o('body').removeClass('scroll'); | ||
added = false; | ||
} | ||
}) | ||
|
||
// highlight code | ||
o('pre.js code').each(function(){ | ||
o(this).html(highlight(o(this).text())); | ||
}) | ||
}) | ||
|
||
// active menu junk | ||
|
||
o(function(){ | ||
var prev; | ||
var n = 0; | ||
|
||
var headings = o('h3').map(function(i, el){ | ||
return { | ||
top: o(el).offset().top, | ||
id: el.id | ||
} | ||
}); | ||
|
||
function closest() { | ||
var h; | ||
var top = o(window).scrollTop(); | ||
var i = headings.length; | ||
while (i--) { | ||
h = headings[i]; | ||
if (top >= h.top) return h; | ||
} | ||
} | ||
|
||
o(document).scroll(function(){ | ||
var h = closest(); | ||
if (!h) return; | ||
|
||
if (prev) { | ||
prev.removeClass('active'); | ||
prev.parent().parent().removeClass('active'); | ||
} | ||
|
||
var a = o('a[href="#' + h.id + '"]'); | ||
a.addClass('active'); | ||
a.parent().parent().addClass('active'); | ||
|
||
prev = a; | ||
}) | ||
}) | ||
|
||
/** | ||
* Highlight the given `js`. | ||
*/ | ||
|
||
function highlight(js) { | ||
return js | ||
.replace(/</g, '<') | ||
.replace(/>/g, '>') | ||
.replace(/\/\/(.*)/gm, '<span class="comment">//$1</span>') | ||
.replace(/('.*?')/gm, '<span class="string">$1</span>') | ||
.replace(/(\d+\.\d+)/gm, '<span class="number">$1</span>') | ||
.replace(/(\d+)/gm, '<span class="number">$1</span>') | ||
.replace(/\bnew *(\w+)/gm, '<span class="keyword">new</span> <span class="init">$1</span>') | ||
.replace(/\b(function|new|throw|return|var|if|else)\b/gm, '<span class="keyword">$1</span>') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!DOCTYPE html><html><head><title>Express - applications</title><link rel="stylesheet" href="style.css"><link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,600,700&subset=latin,latin-ext"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script><script src="app.js"></script></head><body class="applications inner"><div class="bar"></div><section id="content"><header><section id="logo"><span class="express">express<em>3.0.0</em></span><span class="description"> | ||
web application framework for <a href="http://nodejs.org">node </a></span></section><nav class="clearfix"><a href="/" class=""> Home</a><a href="/api.html" class=""> API Reference</a><a href="/guide.html" class=""> Guide</a><a href="/applications.html" class="active"> Applications</a><a href="/community.html" class=""> Community</a><a href="/faq.html" class=""> FAQ</a></nav><div id="x"></div><div id="y"></div></header><section class="application"><h2>LearnBoost</h2><p>LearnBoost provides a free, easy to use online | ||
online education suite including gradebook, | ||
lesson plans, attendance, reporting, and calendars | ||
among other tools. | ||
</p><div class="link">Visit <a href="https://www.learnboost.com/">LearnBoost</a></div><img src="/images/apps/screenshots/learnboost.small.png"></section><section class="application"><h2>Storify</h2><p>Create stories using social media. Turn what people post | ||
on social media into compelling stories. Collect the best photos, video, | ||
tweets and more to publish | ||
</p><div class="link">Visit <a href="http://storify.com/">Storify</a></div><img src="/images/apps/screenshots/storify.small.png"></section><section class="application"><h2>Geekli.st</h2><p>A place for geeks to share what they've done, who they did it with and | ||
connect with great companies and communities. | ||
</p><div class="link">Visit <a href="http://geekli.st">Geekli.st</a></div><img src="/images/apps/screenshots/geeklist.small.png"></section><section class="application"><h2>Klout</h2><p>Klout is the Standard for Influence. Join Klout to discover your | ||
influence and compare with others you may know. | ||
</p><div class="link">Visit <a href="http://klout.com">Klout</a></div><img src="/images/apps/screenshots/klout.small.png"></section><section class="application"><h2>Prismatic</h2><p>Prismatic learns from how you interact on social networks so that we | ||
can show you the most interesting content and conversation from your friends. | ||
</p><div class="link">Visit <a href="http://getprismatic.com/">Prismatic</a></div><img src="/images/apps/screenshots/prismatic.small.png"></section><section class="application"><h2>Clipboard</h2><p>Clipboard is a powerful tool allowing to save live clips | ||
of your interests on the web, not just static images, | ||
but fully-functional fragments of anything online. | ||
</p><div class="link">Visit <a href="http://clipboard.com/">Clipboard</a></div><img src="/images/apps/screenshots/clipboard.small.png"></section><section class="application"><h2>Persona</h2><p>Persona, or "BrowserID" is Mozilla's answer | ||
to a better identification system for your browser, | ||
this promising tool is definitely worth checking out. | ||
</p><div class="link">Visit <a href="https://login.persona.org/">Persona</a></div><img src="/images/apps/screenshots/browserid.small.png"></section><section class="application"><h2>and more!</h2><p>Shodan search reports that there are well over <strong>26,000</strong> Express applications | ||
in the wild, we can't possibly list them all here, but if you feel | ||
your application helps showcase the framework open an issue on | ||
the <a href="github.com/visionmedia/expressjs.com/issues">github repo</a>. | ||
</p><img src="/images/apps/screenshots/more.small.png"></section></section><a id="top" href="#"><img src="images/arrow.png"></a><footer><div id="footer-content">© 2012 TJ Holowaychuk. All rights reserved.</div></footer></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
!!! 5 | ||
html | ||
head | ||
title Express - applications | ||
include includes/head | ||
body.applications.inner | ||
.bar | ||
section#content | ||
header | ||
include includes/logo | ||
active = '/applications.html' | ||
include includes/menu | ||
include en/applications | ||
include includes/footer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<!DOCTYPE html><html><head><title>Express - community</title><link rel="stylesheet" href="style.css"><link rel="stylesheet" href="//fonts.googleapis.com/css?family=Open+Sans:300,400,600,700&subset=latin,latin-ext"><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script><script src="app.js"></script></head><body class="community inner"><div class="bar"></div><section id="content"><header><section id="logo"><span class="express">express<em>3.0.0</em></span><span class="description"> | ||
web application framework for <a href="http://nodejs.org">node </a></span></section><nav class="clearfix"><a href="/" class=""> Home</a><a href="/api.html" class=""> API Reference</a><a href="/guide.html" class=""> Guide</a><a href="/applications.html" class=""> Applications</a><a href="/community.html" class="active"> Community</a><a href="/faq.html" class=""> FAQ</a></nav><div id="x"></div><div id="y"></div></header><div id="boxes" class="clearfix"><section id="mailing-list"><h3>Mailing List</h3><p>Join over 1500 Express users or browse over 5000 | ||
discussions in the <a href="https://groups.google.com/group/express-js">Google Group</a>. | ||
</p></section><section id="irc"><h3>IRC Channel</h3><p>Hundreds of developers idle in #express on freenode every day, | ||
if you have questions about the framework jump in for quick | ||
feedback. | ||
</p></section><section id="examples"><h3>Examples</h3><p>View dozens of Express application <a href="https://github.com/visionmedia/express/tree/master/examples">examples</a> | ||
in the github repository covering everything from API design and authentication | ||
to template engine integration. | ||
</p></section><section id="issues"><h3>Issues</h3><p>If you've come across what you think is a bug, or just want to make | ||
a feature request open a ticket in the <a href="https://github.com/visionmedia/express/issues">issue queue</a>. | ||
</p></section><section id="extending"><h3>Third Party</h3><p>Our vibrant community has created a large variety of extensions, | ||
<a href="https://github.com/senchalabs/connect/wiki">middleware</a> | ||
and higher level frameworks. Check them out in the | ||
<a href="https://github.com/visionmedia/express/wiki">wiki</a>.</p></section></div></section><a id="top" href="#"><img src="images/arrow.png"></a><footer><div id="footer-content">© 2012 TJ Holowaychuk. All rights reserved.</div></footer></body></html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
!!! 5 | ||
html | ||
head | ||
title Express - community | ||
include includes/head | ||
body.community.inner | ||
.bar | ||
section#content | ||
header | ||
include includes/logo | ||
active = '/community.html' | ||
include includes/menu | ||
include en/community | ||
include includes/footer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
section | ||
h3(id='app.VERB') app.VERB(path, [callback...], callback) | ||
|
||
p. | ||
The <code>app.VERB()</code> methods provide the routing functionality | ||
in Express, where <strong>VERB</strong> is one of the HTTP verbs, such | ||
as <code>app.post()</code>. Multiple callbacks may be give, all are treated | ||
equally, and behave just like middleware, with the one exception that | ||
these callbacks may invoke <code>next('route')</code> to bypass the | ||
remaining route callback(s). This mechanism can be used to perform pre-conditions | ||
on a route then pass control to subsequent routes when there is no reason to proceed | ||
with the route matched. | ||
|
||
p. | ||
The following snippet illustrates the most simple route definition possible. Express | ||
translates the path strings to regular expressions, used internally to match incoming requests. | ||
Query strings are <em>not</em> considered when peforming these matches, for example "GET /" | ||
would match the following route, as would "GET /?name=tobi". | ||
|
||
+js. | ||
app.get('/', function(req, res){ | ||
res.send('hello world'); | ||
}); | ||
|
||
p. | ||
Regular expressions may also be used, and can be useful | ||
if you have very specific restraints, for example the following | ||
would match "GET /commits/71dbb9c" as well as "GET /commits/71dbb9c..4c084f9". | ||
|
||
+js. | ||
app.get(/^\/commits\/(\d+)(?:\.\.(\d+))?$/, function(req, res){ | ||
var from = req.params[0]; | ||
var to = req.params[1] || 'HEAD'; | ||
res.send('commit range ' + from + '..' + to); | ||
}); | ||
|
||
p. | ||
Several callbacks may also be passed, useful for re-using middleware | ||
that load resources, perform validations, etc. | ||
|
||
+js. | ||
app.get('/user/:id', user.load, function(){ | ||
// ... | ||
}) | ||
|
||
p. | ||
These callbacks may be passed within arrays as well, these arrays are | ||
simply flattened when passed: | ||
|
||
+js. | ||
var middleware = [loadForum, loadThread]; | ||
|
||
app.get('/forum/:fid/thread/:tid', middleware, function(){ | ||
// ... | ||
}) | ||
|
||
app.post('/forum/:fid/thread/:tid', middleware, function(){ | ||
// ... | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
section | ||
h3(id='app.all') app.all(path, [callback...], callback) | ||
|
||
p. | ||
This method functions just like the <code>app.VERB()</code> methods, | ||
however it matches all HTTP verbs. | ||
|
||
p. | ||
This method is extremely useful for | ||
mapping "global" logic for specific path prefixes or arbitrary matches. | ||
For example if you placed the following route at the top of all other | ||
route definitions, it would require that all routes from that point on | ||
would require authentication, and automatically load a user. Keep in mind | ||
that these callbacks do not have to act as end points, <code>loadUser</code> | ||
can perform a task, then <code>next()</code> to continue matching subsequent | ||
routes. | ||
|
||
+js. | ||
app.all('*', requireAuthentication, loadUser); | ||
|
||
p. | ||
Or the equivalent: | ||
|
||
+js. | ||
app.all('*', requireAuthentication) | ||
app.all('*', loadUser); | ||
|
||
p. | ||
Another great example of this is white-listed "global" functionality. Here | ||
the example is much like before, however only restricting paths prefixed with | ||
"/api": | ||
|
||
+js. | ||
app.all('/api/*', requireAuthentication); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
section | ||
h3(id='app.configure') app.configure([env], callback) | ||
|
||
p. | ||
Conditionally invoke <code>callback</code> when <code>env</code> matches <code>app.get('env')</code>, | ||
aka <code>process.env.NODE_ENV</code>. This method remains for legacy reason, and is effectively | ||
an <code>if</code> statement as illustrated in the following snippets. These functions are <em>not</em> | ||
required in order to use <code>app.set()</code> and other configuration methods. | ||
|
||
+js. | ||
// all environments | ||
app.configure(function(){ | ||
app.set('title', 'My Application'); | ||
}) | ||
|
||
// development only | ||
app.configure('development', function(){ | ||
app.set('db uri', 'localhost/dev'); | ||
}) | ||
|
||
// production only | ||
app.configure('production', function(){ | ||
app.set('db uri', 'n.n.n.n/prod'); | ||
}) | ||
|
||
Is effectively sugar for: | ||
|
||
+js. | ||
// all environments | ||
app.set('title', 'My Application'); | ||
|
||
// development only | ||
if ('development' == app.get('env')) { | ||
app.set('db uri', 'localhost/dev'); | ||
} | ||
|
||
// production only | ||
if ('production' == app.get('env')) { | ||
app.set('db uri', 'n.n.n.n/prod'); | ||
} |
Oops, something went wrong.