next runtime
v2.4.2

您需要在getServerSideProps中处理POST请求和文件上传。
所有文档和指南都可以在Next-runtime.meijer.ws上找到。
下一个跑步旨在将更多的逻辑移至下一个服务器的“运行时部分”,而静态站点的生成较少。使用适当的缓存标头,每个服务器都是(增量)静态站点生成器。
为此,我们为您提供方便的API:
getServerSideProps中的发布请求。getServerSideProps中的文件上传。getServerSideProps作为零config json api。 如果您不是人的文档类型,则是一个可以让您启动并运行的快速示例。如果这会给您带来疑问,请咨询文档。
import fs from 'fs' ;
import { handle , json } from 'next-runtime' ;
export const getServerSideProps = handle ( {
async upload ( { file , stream } ) {
stream . pipe ( fs . createWriteStream ( `/uploads/ ${ file . name } ` ) ) ;
} ,
async get ( { params , query } ) {
return json ( { name : 'Stephan Meijer' } ) ;
} ,
async post ( { req : { body } } ) {
return json ( { message : 'Thanks for your submission!' } ) ;
} ,
} ) ;
export default function Home ( { name , message } ) {
if ( message ) {
return < p > { message } </ p > ;
}
return (
< form method = "post" encType = "multipart/form-data" >
< input name = "name" defaultValue = { name } />
< input type = "file" name = "file" />
< button type = "submit" > submit </ button >
</ form >
) ;
} 您或您的雇主,满意的用户还是我的任何其他项目。然后,请考虑赞助我的工作,以便我可以花更多的时间来维护此类项目。
请检查贡献。它包含有关此存储库结构的信息,以帮助您启动和运行。
谢谢这些好人(表情符号钥匙):
斯蒂芬·梅杰(Stephan Meijer) ? ? ? | 加尔·施莱辛格(Gal Schlezinger) | 达里乌斯 | 乌玛·艾哈迈德(Umar Ahmed) | hikaru kobori | Koichi Kiyokawa | Gorka剖宫产 |
Pandiyan Murugan |
该项目遵循全企业规范。欢迎任何形式的贡献!