Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
CoCo_Code_Op2
next.js
提交
ef637b38
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,发现更多精彩内容 >>
未验证
提交
ef637b38
编写于
7月 21, 2020
作者:
B
Bruno Bernardino
提交者:
GitHub
7月 21, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes Hapi custom server example (#15292)
上级
7a266a91
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
22 addition
and
33 deletion
+22
-33
examples/custom-server-hapi/next-wrapper.js
examples/custom-server-hapi/next-wrapper.js
+4
-9
examples/custom-server-hapi/pages/index.js
examples/custom-server-hapi/pages/index.js
+15
-12
examples/custom-server-hapi/public/logo.svg
examples/custom-server-hapi/public/logo.svg
+1
-0
examples/custom-server-hapi/server.js
examples/custom-server-hapi/server.js
+2
-12
未找到文件。
examples/custom-server-hapi/next-wrapper.js
浏览文件 @
ef637b38
...
...
@@ -5,14 +5,6 @@ const nextHandlerWrapper = (app) => {
return
h
.
close
}
}
const
defaultHandlerWrapper
=
(
app
)
=>
async
(
{
raw
:
{
req
,
res
},
url
},
h
)
=>
{
const
{
pathname
,
query
}
=
url
const
html
=
await
app
.
renderToHTML
(
req
,
res
,
pathname
,
query
)
return
h
.
response
(
html
).
code
(
res
.
statusCode
)
}
const
pathWrapper
=
(
app
,
pathName
,
opts
)
=>
async
(
{
raw
,
query
,
params
},
...
...
@@ -28,4 +20,7 @@ const pathWrapper = (app, pathName, opts) => async (
return
h
.
response
(
html
).
code
(
raw
.
res
.
statusCode
)
}
module
.
exports
=
{
pathWrapper
,
defaultHandlerWrapper
,
nextHandlerWrapper
}
module
.
exports
=
{
pathWrapper
,
nextHandlerWrapper
,
}
examples/custom-server-hapi/pages/index.js
浏览文件 @
ef637b38
...
...
@@ -2,6 +2,7 @@ import Link from 'next/link'
export
default
function
Home
()
{
return
(
<>
<
ul
>
<
li
>
<
Link
href
=
"
/b
"
as
=
"
/a
"
>
...
...
@@ -14,5 +15,7 @@ export default function Home() {
<
/Link
>
<
/li
>
<
/ul
>
<
img
src
=
"
/logo.svg
"
width
=
"
200
"
/>
<
/
>
)
}
examples/custom-server-hapi/public/logo.svg
0 → 100644
浏览文件 @
ef637b38
<?xml version="1.0" encoding="UTF-8" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg
width=
"100%"
height=
"100%"
viewBox=
"0 0 884 200"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
xml:space=
"preserve"
xmlns:serif=
"http://www.serif.com/"
style=
"fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;"
><path
d=
"M440.75,50c-34.5,0 -59.375,22.5 -59.375,56.25c0,33.75 28,56.25 62.5,56.25c20.844,0 39.219,-8.25 50.594,-22.156l-23.907,-13.813c-6.312,6.907 -15.906,10.938 -26.687,10.938c-14.969,0 -27.688,-7.813 -32.406,-20.313l87.562,0c0.688,-3.5 1.094,-7.125 1.094,-10.937c0,-33.719 -24.875,-56.219 -59.375,-56.219Zm-29.563,45.313c3.907,-12.469 14.594,-20.313 29.532,-20.313c14.968,0 25.656,7.844 29.531,20.313l-59.063,0Zm366.063,-45.313c-34.5,0 -59.375,22.5 -59.375,56.25c0,33.75 28,56.25 62.5,56.25c20.844,0 39.219,-8.25 50.594,-22.156l-23.906,-13.813c-6.313,6.907 -15.907,10.938 -26.688,10.938c-14.969,0 -27.687,-7.813 -32.406,-20.313l87.562,0c0.688,-3.5 1.094,-7.125 1.094,-10.937c0,-33.719 -24.875,-56.219 -59.375,-56.219Zm-29.531,45.313c3.906,-12.469 14.593,-20.313 29.531,-20.313c14.969,0 25.656,7.844 29.531,20.313l-59.062,0Zm-121.969,10.937c0,18.75 12.25,31.25 31.25,31.25c12.875,0 22.531,-5.844 27.5,-15.375l24,13.844c-9.938,16.562 -28.563,26.531 -51.5,26.531c-34.531,0 -59.375,-22.5 -59.375,-56.25c0,-33.75 24.875,-56.25 59.375,-56.25c22.938,0 41.531,9.969 51.5,26.531l-24,13.844c-4.969,-9.531 -14.625,-15.375 -27.5,-15.375c-18.969,0 -31.25,12.5 -31.25,31.25Zm257.75,-90.625l0,143.75l-28.125,0l0,-143.75l28.125,0Zm-768.031,-15.625l115.468,200l-230.937,0l115.469,-200Zm288.687,15.625l-86.594,150l-86.593,-150l32.468,0l54.125,93.75l54.125,-93.75l32.469,0Zm184.094,37.5l0,30.281c-3.125,-0.906 -6.438,-1.531 -10,-1.531c-18.156,0 -31.25,12.5 -31.25,31.25l0,46.25l-28.125,0l0,-106.25l28.125,0l0,28.75c0,-15.875 18.469,-28.75 41.25,-28.75Z"
style=
"fill-rule:nonzero;"
/></svg>
\ No newline at end of file
examples/custom-server-hapi/server.js
浏览文件 @
ef637b38
const
next
=
require
(
'
next
'
)
const
Hapi
=
require
(
'
@hapi/hapi
'
)
const
{
pathWrapper
,
defaultHandlerWrapper
,
nextHandlerWrapper
,
}
=
require
(
'
./next-wrapper
'
)
const
{
pathWrapper
,
nextHandlerWrapper
}
=
require
(
'
./next-wrapper
'
)
const
port
=
parseInt
(
process
.
env
.
PORT
,
10
)
||
3000
const
dev
=
process
.
env
.
NODE_ENV
!==
'
production
'
...
...
@@ -32,16 +28,10 @@ app.prepare().then(async () => {
handler
:
nextHandlerWrapper
(
app
),
})
server
.
route
({
method
:
'
GET
'
,
path
:
'
/static/{p*}
'
/* use next to handle static files */
,
handler
:
nextHandlerWrapper
(
app
),
})
server
.
route
({
method
:
'
*
'
,
path
:
'
/{p*}
'
/* catch all route */
,
handler
:
defaul
tHandlerWrapper
(
app
),
handler
:
nex
tHandlerWrapper
(
app
),
})
try
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录