灏天阁

Node/Koa2[46]: 微博页面生成

· Yin灏

首页页面模板

src/views/index.ejs

首页模板路由定义

src/routes/view/blog.js

const router = require("koa-router")();
const { loginRedirect } = require("../../middlewares/loginChecks");

router.get("/", loginRedirect, async (ctx, next) => {
  await ctx.render("index", {});
});

module.exports = router;

app.js 中注册路由

// app.js
//...
const blogViewRouter = require("./routes/view/blog");
//...
app.use(blogViewRouter.routes(), blogViewRouter.allowedMethods());

- Book Lists -