• Decorator for POST endpoints

    Parameters

    • path: string

      The route path

    Returns ((target, propertyKey, descriptor) => PropertyDescriptor)

      • (target, propertyKey, descriptor): PropertyDescriptor
      • Parameters

        • target: any
        • propertyKey: string
        • descriptor: PropertyDescriptor

        Returns PropertyDescriptor

    Example

    @post("/api/users")
    async createUser(req: KosRequest<"/api/users">, res: KosResponse) {
    const userData = req.body;
    const newUser = await this.userService.createUser(userData);
    res.status(201).send(newUser);
    }