koajs / koa

Expressive middleware for node.js using ES2017 async functions
https://koajs.com
MIT License
35.02k stars 3.22k forks source link

Better TypeScript support #1737

Open flycran opened 1 year ago

flycran commented 1 year ago

Do you want to consider using TypeScript to refactor code to get better TypeScript syntax support? And updated to koa3.

Shyam-Chen commented 1 year ago
import type { FastifyPluginAsyncTypebox } from '@fastify/type-provider-typebox';
import { Type } from '@sinclair/typebox';

export default (async (app) => {
  app.get(
    '/hello-world',
    {
      schema: {
        response: {
          200: Type.Object({
            message: Type.String(),
          }),
        },
      },
    },
    async (request, reply) => {
      return reply.send({
        message: 'Hello, World!',
      });
    },
  );
}) as FastifyPluginAsyncTypebox;