Backend template with Core SDK and Web API.
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
737 B

  1. import { FastifyInstance } from 'fastify';
  2. import { AdderController, AdderControllerImpl } from './modules/adder';
  3. export const addRoutes = (server: FastifyInstance) => {
  4. const adderController: AdderController = new AdderControllerImpl();
  5. return server
  6. .route({
  7. method: 'POST',
  8. url: '/add',
  9. schema: {
  10. body: {
  11. type: 'object',
  12. properties: {
  13. a: { type: 'number' },
  14. b: { type: 'number' },
  15. }
  16. }
  17. },
  18. handler: adderController.addNumbers,
  19. })
  20. .route({
  21. method: 'POST',
  22. url: '/subtract',
  23. schema: {
  24. body: {
  25. type: 'object',
  26. properties: {
  27. a: { type: 'number' },
  28. b: { type: 'number' },
  29. }
  30. }
  31. },
  32. handler: adderController.subtractNumbers,
  33. });
  34. };