fastify#RouteOptions TypeScript Examples

The following examples show how to use fastify#RouteOptions. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ipLocate.ts    From iplocate with MIT License 6 votes vote down vote up
opts: Partial<RouteOptions> = {
  schema: {
    querystring: {
      required: ["ip"],
      type: "object",
      properties: {
        ip: {
          anyOf: [
            { type: "string", format: "ipv4" },
            { type: "string", format: "ipv6" },
          ],
        },
      },
    },
  },
  errorHandler: (error, _, reply) => {
    if (error.name === "AddressNotFoundError") {
      reply.status(404).send();
    } else {
      throw error;
    }
  },
}
Example #2
Source File: index.ts    From node-fastify-mongo-api with MIT License 5 votes vote down vote up
getCarsRoute: RouteOptions = {
	method: 'GET',
	url: '/api/cars',
	handler: carsController.getCars,
	schema: GetCarsSchema,
}
Example #3
Source File: index.ts    From node-fastify-mongo-api with MIT License 5 votes vote down vote up
getCarRoute: RouteOptions = {
	method: 'GET',
	url: '/api/cars/:id',
	handler: carsController.getSingleCar,
	schema: GetCarSchema,
}
Example #4
Source File: index.ts    From node-fastify-mongo-api with MIT License 5 votes vote down vote up
postCarRoute: RouteOptions = {
	method: 'POST',
	url: '/api/cars',
	handler: carsController.addCar,
	schema: AddCarSchema,
}
Example #5
Source File: index.ts    From node-fastify-mongo-api with MIT License 5 votes vote down vote up
putCarRoute: RouteOptions = {
	method: 'PUT',
	url: '/api/cars/:id',
	handler: carsController.updateCar,
	schema: PutCarSchema,
}
Example #6
Source File: index.ts    From node-fastify-mongo-api with MIT License 5 votes vote down vote up
deleteCarRoute: RouteOptions = {
	method: 'DELETE',
	url: '/api/cars/:id',
	handler: carsController.deleteCar,
	schema: DeleteCarSchema,
}