js - fastify的基本使用

访问量: 21

example

  server.get<{ Body: { name: string } }>("/rede/checkOwner", async function (request, reply) {
    let name = request.body.name;
    let res = await getOwner(name);
    return { result: "ok", res: res };
  }); 

日志

使用了pino

参考:https://getpino.io/#/docs/api?id=mergingobject

request.log.debug("===  message: %s , %d, %o", "hello", 123, {name: 'luelue'})

获得参数

从 post body 中 request.body.param1

从url 中: request.query.param2

订阅/RSS Feed

Subscribe