Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CoCo_Code_Op2
next.js
提交
ba65b07d
N
next.js
项目概览
CoCo_Code_Op2
/
next.js
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
next.js
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ba65b07d
编写于
8月 10, 2017
作者:
B
Brikou CARRE
提交者:
Tim Neutkens
8月 10, 2017
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ease running multiple examples at the same time with process.env.PORT (#2753)
上级
d0b95d9b
变更
23
隐藏空白更改
内联
并排
Showing
23 changed file
with
64 addition
and
44 deletion
+64
-44
examples/custom-server-express/server.js
examples/custom-server-express/server.js
+3
-2
examples/custom-server-hapi/server.js
examples/custom-server-hapi/server.js
+3
-2
examples/custom-server-koa/server.js
examples/custom-server-koa/server.js
+3
-2
examples/custom-server-micro/server.js
examples/custom-server-micro/server.js
+3
-2
examples/custom-server/server.js
examples/custom-server/server.js
+3
-2
examples/page-transitions/server.js
examples/page-transitions/server.js
+1
-1
examples/parameterized-routing/server.js
examples/parameterized-routing/server.js
+3
-2
examples/root-static-files/server.js
examples/root-static-files/server.js
+3
-2
examples/ssr-caching/server.js
examples/ssr-caching/server.js
+3
-2
examples/using-inferno/server.js
examples/using-inferno/server.js
+3
-2
examples/using-preact/server.js
examples/using-preact/server.js
+3
-2
examples/with-custom-reverse-proxy/server.es6.js
examples/with-custom-reverse-proxy/server.es6.js
+1
-1
examples/with-firebase-authentication/server.js
examples/with-firebase-authentication/server.js
+3
-2
examples/with-mobx/server.js
examples/with-mobx/server.js
+3
-2
examples/with-next-routes/server.js
examples/with-next-routes/server.js
+3
-2
examples/with-pkg/server.js
examples/with-pkg/server.js
+3
-2
examples/with-pretty-url-routing/server.js
examples/with-pretty-url-routing/server.js
+2
-2
examples/with-react-i18next/server.js
examples/with-react-i18next/server.js
+3
-2
examples/with-react-intl/server.js
examples/with-react-intl/server.js
+3
-2
examples/with-socket.io/server.js
examples/with-socket.io/server.js
+3
-2
examples/with-static-export/server.js
examples/with-static-export/server.js
+3
-2
examples/with-sw-precache/server.js
examples/with-sw-precache/server.js
+3
-2
examples/with-url-object-routing/server.js
examples/with-url-object-routing/server.js
+3
-2
未找到文件。
examples/custom-server-express/server.js
浏览文件 @
ba65b07d
const
express
=
require
(
'
express
'
)
const
next
=
require
(
'
next
'
)
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
app
=
next
({
dev
})
const
handle
=
app
.
getRequestHandler
()
...
...
@@ -21,8 +22,8 @@ app.prepare()
return
handle
(
req
,
res
)
})
server
.
listen
(
3000
,
(
err
)
=>
{
server
.
listen
(
port
,
(
err
)
=>
{
if
(
err
)
throw
err
console
.
log
(
'
> Ready on http://localhost:3000
'
)
console
.
log
(
`> Ready on http://localhost:
${
port
}
`
)
})
})
examples/custom-server-hapi/server.js
浏览文件 @
ba65b07d
...
...
@@ -3,6 +3,7 @@ const Hapi = require('hapi')
const
Good
=
require
(
'
good
'
)
const
{
pathWrapper
,
defaultHandlerWrapper
}
=
require
(
'
./next-wrapper
'
)
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
app
=
next
({
dev
})
const
server
=
new
Hapi
.
Server
()
...
...
@@ -23,7 +24,7 @@ const pluginOptions = [
app
.
prepare
()
.
then
(()
=>
{
server
.
connection
({
port
:
3000
})
server
.
connection
({
port
})
server
.
register
(
pluginOptions
)
.
then
(()
=>
{
server
.
route
({
...
...
@@ -48,7 +49,7 @@ app.prepare()
console
.
log
(
'
Error starting server
'
)
console
.
log
(
error
)
}).
then
(()
=>
{
console
.
log
(
'
> Ready on http://localhost:3000
'
)
console
.
log
(
`> Ready on http://localhost:
${
port
}
`
)
})
})
})
examples/custom-server-koa/server.js
浏览文件 @
ba65b07d
...
...
@@ -2,6 +2,7 @@ const Koa = require('koa')
const
next
=
require
(
'
next
'
)
const
Router
=
require
(
'
koa-router
'
)
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
app
=
next
({
dev
})
const
handle
=
app
.
getRequestHandler
()
...
...
@@ -32,8 +33,8 @@ app.prepare()
})
server
.
use
(
router
.
routes
())
server
.
listen
(
3000
,
(
err
)
=>
{
server
.
listen
(
port
,
(
err
)
=>
{
if
(
err
)
throw
err
console
.
log
(
'
> Ready on http://localhost:3000
'
)
console
.
log
(
`> Ready on http://localhost:
${
port
}
`
)
})
})
examples/custom-server-micro/server.js
浏览文件 @
ba65b07d
...
...
@@ -3,6 +3,7 @@ const match = require('micro-route/match')
const
{
parse
}
=
require
(
'
url
'
)
const
next
=
require
(
'
next
'
)
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
app
=
next
({
dev
})
const
handle
=
app
.
getRequestHandler
()
...
...
@@ -21,8 +22,8 @@ const server = micro(async (req, res) => {
})
app
.
prepare
().
then
(()
=>
{
server
.
listen
(
3000
,
err
=>
{
server
.
listen
(
port
,
err
=>
{
if
(
err
)
throw
err
console
.
log
(
'
> Ready on http://localhost:3000
'
)
console
.
log
(
`> Ready on http://localhost:
${
port
}
`
)
})
})
examples/custom-server/server.js
浏览文件 @
ba65b07d
...
...
@@ -2,6 +2,7 @@ const { createServer } = require('http')
const
{
parse
}
=
require
(
'
url
'
)
const
next
=
require
(
'
next
'
)
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
app
=
next
({
dev
})
const
handle
=
app
.
getRequestHandler
()
...
...
@@ -20,8 +21,8 @@ app.prepare()
handle
(
req
,
res
,
parsedUrl
)
}
})
.
listen
(
3000
,
(
err
)
=>
{
.
listen
(
port
,
(
err
)
=>
{
if
(
err
)
throw
err
console
.
log
(
'
> Ready on http://localhost:3000
'
)
console
.
log
(
`> Ready on http://localhost:
${
port
}
`
)
})
})
examples/page-transitions/server.js
浏览文件 @
ba65b07d
...
...
@@ -3,7 +3,7 @@ const routes = require('./routes')
const
express
=
require
(
'
express
'
)
const
compression
=
require
(
'
compression
'
)
const
port
=
p
rocess
.
env
.
PORT
||
3000
const
port
=
p
arseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
app
=
next
({
dev
})
...
...
examples/parameterized-routing/server.js
浏览文件 @
ba65b07d
...
...
@@ -3,6 +3,7 @@ const { parse } = require('url')
const
next
=
require
(
'
next
'
)
const
pathMatch
=
require
(
'
path-match
'
)
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
app
=
next
({
dev
})
const
handle
=
app
.
getRequestHandler
()
...
...
@@ -23,8 +24,8 @@ app.prepare()
// i.e. /blog/foo?show-comments=true
app
.
render
(
req
,
res
,
'
/blog
'
,
Object
.
assign
(
params
,
query
))
})
.
listen
(
3000
,
(
err
)
=>
{
.
listen
(
port
,
(
err
)
=>
{
if
(
err
)
throw
err
console
.
log
(
'
> Ready on http://localhost:3000
'
)
console
.
log
(
`> Ready on http://localhost:
${
port
}
`
)
})
})
examples/root-static-files/server.js
浏览文件 @
ba65b07d
...
...
@@ -3,6 +3,7 @@ const { parse } = require('url')
const
next
=
require
(
'
next
'
)
const
{
join
}
=
require
(
'
path
'
)
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
app
=
next
({
dev
})
const
handle
=
app
.
getRequestHandler
()
...
...
@@ -23,8 +24,8 @@ app.prepare()
handle
(
req
,
res
,
parsedUrl
)
}
})
.
listen
(
3000
,
(
err
)
=>
{
.
listen
(
port
,
(
err
)
=>
{
if
(
err
)
throw
err
console
.
log
(
'
> Ready on http://localhost:3000
'
)
console
.
log
(
`> Ready on http://localhost:
${
port
}
`
)
})
})
examples/ssr-caching/server.js
浏览文件 @
ba65b07d
...
...
@@ -2,6 +2,7 @@ const express = require('express')
const
next
=
require
(
'
next
'
)
const
LRUCache
=
require
(
'
lru-cache
'
)
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
app
=
next
({
dir
:
'
.
'
,
dev
})
const
handle
=
app
.
getRequestHandler
()
...
...
@@ -30,9 +31,9 @@ app.prepare()
return
handle
(
req
,
res
)
})
server
.
listen
(
3000
,
(
err
)
=>
{
server
.
listen
(
port
,
(
err
)
=>
{
if
(
err
)
throw
err
console
.
log
(
'
> Ready on http://localhost:3000
'
)
console
.
log
(
`> Ready on http://localhost:
${
port
}
`
)
})
})
...
...
examples/using-inferno/server.js
浏览文件 @
ba65b07d
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
moduleAlias
=
require
(
'
module-alias
'
)
...
...
@@ -22,8 +23,8 @@ app.prepare()
const
parsedUrl
=
parse
(
req
.
url
,
true
)
handle
(
req
,
res
,
parsedUrl
)
})
.
listen
(
3000
,
(
err
)
=>
{
.
listen
(
port
,
(
err
)
=>
{
if
(
err
)
throw
err
console
.
log
(
'
> Ready on http://localhost:3000
'
)
console
.
log
(
`> Ready on http://localhost:
${
port
}
`
)
})
})
examples/using-preact/server.js
浏览文件 @
ba65b07d
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
moduleAlias
=
require
(
'
module-alias
'
)
...
...
@@ -21,8 +22,8 @@ app.prepare()
const
parsedUrl
=
parse
(
req
.
url
,
true
)
handle
(
req
,
res
,
parsedUrl
)
})
.
listen
(
3000
,
(
err
)
=>
{
.
listen
(
port
,
(
err
)
=>
{
if
(
err
)
throw
err
console
.
log
(
'
> Ready on http://localhost:3000
'
)
console
.
log
(
`> Ready on http://localhost:
${
port
}
`
)
})
})
examples/with-custom-reverse-proxy/server.es6.js
浏览文件 @
ba65b07d
...
...
@@ -10,7 +10,7 @@ const devProxy = {
}
}
const
port
=
p
rocess
.
env
.
PORT
||
3000
const
port
=
p
arseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
env
=
process
.
env
.
NODE_ENV
const
dev
=
env
!==
'
production
'
const
app
=
next
({
...
...
examples/with-firebase-authentication/server.js
浏览文件 @
ba65b07d
...
...
@@ -5,6 +5,7 @@ const FileStore = require('session-file-store')(session)
const
next
=
require
(
'
next
'
)
const
admin
=
require
(
'
firebase-admin
'
)
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
app
=
next
({
dev
})
const
handle
=
app
.
getRequestHandler
()
...
...
@@ -56,8 +57,8 @@ app.prepare()
return
handle
(
req
,
res
)
})
server
.
listen
(
3000
,
(
err
)
=>
{
server
.
listen
(
port
,
(
err
)
=>
{
if
(
err
)
throw
err
console
.
log
(
'
> Ready on http://localhost:3000
'
)
console
.
log
(
`> Ready on http://localhost:
${
port
}
`
)
})
})
examples/with-mobx/server.js
浏览文件 @
ba65b07d
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
{
createServer
}
=
require
(
'
http
'
)
...
...
@@ -13,8 +14,8 @@ app.prepare().then(() => {
createServer
((
req
,
res
)
=>
{
const
parsedUrl
=
parse
(
req
.
url
,
true
)
handle
(
req
,
res
,
parsedUrl
)
}).
listen
(
3000
,
err
=>
{
}).
listen
(
port
,
err
=>
{
if
(
err
)
throw
err
console
.
log
(
'
> Ready on http://localhost:3000
'
)
console
.
log
(
`> Ready on http://localhost:
${
port
}
`
)
})
})
examples/with-next-routes/server.js
浏览文件 @
ba65b07d
...
...
@@ -2,6 +2,7 @@ const { createServer } = require('http')
const
next
=
require
(
'
next
'
)
const
routes
=
require
(
'
./routes
'
)
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
app
=
next
({
dev
})
const
handler
=
routes
.
getRequestHandler
(
app
)
...
...
@@ -9,8 +10,8 @@ const handler = routes.getRequestHandler(app)
app
.
prepare
()
.
then
(()
=>
{
createServer
(
handler
)
.
listen
(
3000
,
(
err
)
=>
{
.
listen
(
port
,
(
err
)
=>
{
if
(
err
)
throw
err
console
.
log
(
'
> Ready on http://localhost:3000
'
)
console
.
log
(
`> Ready on http://localhost:
${
port
}
`
)
})
})
examples/with-pkg/server.js
浏览文件 @
ba65b07d
...
...
@@ -2,6 +2,7 @@ const { createServer } = require('http')
const
{
parse
}
=
require
(
'
url
'
)
const
next
=
require
(
'
next
'
)
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
app
=
next
({
dev
})
const
handle
=
app
.
getRequestHandler
()
...
...
@@ -9,8 +10,8 @@ const handle = app.getRequestHandler()
app
.
prepare
()
.
then
(()
=>
{
createServer
((
req
,
res
)
=>
handle
(
req
,
res
,
parse
(
req
.
url
,
true
).
pathname
))
.
listen
(
3000
,
(
err
)
=>
{
.
listen
(
port
,
(
err
)
=>
{
if
(
err
)
throw
err
console
.
log
(
'
> Ready on http://localhost:3000
'
)
console
.
log
(
`> Ready on http://localhost:
${
port
}
`
)
})
})
examples/with-pretty-url-routing/server.js
浏览文件 @
ba65b07d
...
...
@@ -2,9 +2,9 @@ const express = require('express')
const
next
=
require
(
'
next
'
)
const
Router
=
require
(
'
./routes
'
).
Router
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
app
=
next
({
dev
})
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
app
=
next
({
dev
})
const
handle
=
app
.
getRequestHandler
()
app
.
prepare
()
...
...
examples/with-react-i18next/server.js
浏览文件 @
ba65b07d
...
...
@@ -2,6 +2,7 @@ const express = require('express')
const
path
=
require
(
'
path
'
)
const
next
=
require
(
'
next
'
)
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
app
=
next
({
dev
})
const
handle
=
app
.
getRequestHandler
()
...
...
@@ -40,9 +41,9 @@ i18n
// use next.js
server
.
get
(
'
*
'
,
(
req
,
res
)
=>
handle
(
req
,
res
))
server
.
listen
(
3000
,
(
err
)
=>
{
server
.
listen
(
port
,
(
err
)
=>
{
if
(
err
)
throw
err
console
.
log
(
'
> Ready on http://localhost:3000
'
)
console
.
log
(
`> Ready on http://localhost:
${
port
}
`
)
})
})
})
examples/with-react-intl/server.js
浏览文件 @
ba65b07d
...
...
@@ -11,6 +11,7 @@ const accepts = require('accepts')
const
glob
=
require
(
'
glob
'
)
const
next
=
require
(
'
next
'
)
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
app
=
next
({
dev
})
const
handle
=
app
.
getRequestHandler
()
...
...
@@ -46,8 +47,8 @@ app.prepare().then(() => {
req
.
localeDataScript
=
getLocaleDataScript
(
locale
)
req
.
messages
=
dev
?
{}
:
getMessages
(
locale
)
handle
(
req
,
res
)
}).
listen
(
3000
,
(
err
)
=>
{
}).
listen
(
port
,
(
err
)
=>
{
if
(
err
)
throw
err
console
.
log
(
'
> Read on http://localhost:3000
'
)
console
.
log
(
`> Ready on http://localhost:
${
port
}
`
)
})
})
examples/with-socket.io/server.js
浏览文件 @
ba65b07d
...
...
@@ -3,6 +3,7 @@ const server = require('http').Server(app)
const
io
=
require
(
'
socket.io
'
)(
server
)
const
next
=
require
(
'
next
'
)
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
nextApp
=
next
({
dev
})
const
nextHandler
=
nextApp
.
getRequestHandler
()
...
...
@@ -27,8 +28,8 @@ nextApp.prepare().then(() => {
return
nextHandler
(
req
,
res
)
})
server
.
listen
(
3000
,
(
err
)
=>
{
server
.
listen
(
port
,
(
err
)
=>
{
if
(
err
)
throw
err
console
.
log
(
'
> Ready on http://localhost:3000
'
)
console
.
log
(
`> Ready on http://localhost:
${
port
}
`
)
})
})
examples/with-static-export/server.js
浏览文件 @
ba65b07d
const
express
=
require
(
'
express
'
)
const
next
=
require
(
'
next
'
)
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
app
=
next
({
dev
})
const
handle
=
app
.
getRequestHandler
()
...
...
@@ -20,8 +21,8 @@ app.prepare()
return
handle
(
req
,
res
)
})
server
.
listen
(
3000
,
(
err
)
=>
{
server
.
listen
(
port
,
(
err
)
=>
{
if
(
err
)
throw
err
console
.
log
(
'
> Ready on http://localhost:3000
'
)
console
.
log
(
`> Ready on http://localhost:
${
port
}
`
)
})
})
examples/with-sw-precache/server.js
浏览文件 @
ba65b07d
...
...
@@ -3,6 +3,7 @@ const { join } = require('path')
const
{
parse
}
=
require
(
'
url
'
)
const
next
=
require
(
'
next
'
)
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
app
=
next
({
dev
})
const
handle
=
app
.
getRequestHandler
()
...
...
@@ -20,8 +21,8 @@ app.prepare()
handle
(
req
,
res
,
parsedUrl
)
}
})
.
listen
(
3000
,
(
err
)
=>
{
.
listen
(
port
,
(
err
)
=>
{
if
(
err
)
throw
err
console
.
log
(
'
> Ready on http://localhost:3000
'
)
console
.
log
(
`> Ready on http://localhost:
${
port
}
`
)
})
})
examples/with-url-object-routing/server.js
浏览文件 @
ba65b07d
...
...
@@ -3,6 +3,7 @@ const { parse } = require('url')
const
next
=
require
(
'
next
'
)
const
pathMatch
=
require
(
'
path-match
'
)
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
const
app
=
next
({
dev
})
const
handle
=
app
.
getRequestHandler
()
...
...
@@ -21,8 +22,8 @@ app.prepare()
app
.
render
(
req
,
res
,
'
/about
'
,
params
)
})
.
listen
(
3000
,
(
err
)
=>
{
.
listen
(
port
,
(
err
)
=>
{
if
(
err
)
throw
err
console
.
log
(
'
> Ready on http://localhost:3000
'
)
console
.
log
(
`> Ready on http://localhost:
${
port
}
`
)
})
})
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录