1.0.3 • Published 5 years ago
@hal-wang/funceb v1.0.3
funceb(function hosting static website)
使用 nodejs (云函数, koa, express, ...) 托管静态网站
用法
Funceb 构造函数接收两个参数
- reqPath: 请求路径,如
/login、/product/funceb等 - webPath: 可选参数,如果
index.html不是在根目录,需要设置此参数,值为index.html相对路径,如/web、/webset/v2等
koa
const Koa = require("koa");
const Funceb = require("@hal-wang/funceb").default;
const app = new Koa();
app.use(async (ctx) => {
const funceb = new Funceb(ctx.request.path);
ctx.body = funceb.content;
ctx.type = funceb.mime;
ctx.status = funceb.status;
});
app.listen(3000);云函数
const Funceb = require("@hal-wang/funceb").default;
exports.main = async (event) => {
const funceb = new Funceb(event.path, '', "base64");
return {
isBase64Encoded: true,
statusCode: funceb.status,
headers: { "Content-Type": funceb.mine },
body: funceb.content,
};
};Demo
用 koa 托管 vue 静态网站。
在 demo 文件夹中,运行
npm install
npm start浏览器访问 http://localhost:3000
1.0.3
5 years ago
1.0.2
5 years ago
1.0.2-beta.1
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago
0.1.0
5 years ago
0.0.1-beta.11
5 years ago
0.0.1-beta.10
5 years ago
0.0.1-beta.8
5 years ago