0.2.2 • Published 6 years ago

@travetto/asset-express v0.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 years ago

travetto: Asset-Express

Asset Express, provides a clean and direct mechanism for handling uploads via the express framework, as well as some best practices with respect to temporary file deletion.

Once the files are uploaded, they are exposed on express's request object as req.files. The uploaded files are constructed as Asset instances, which allows for easy interoperability with the Asset module for storage.

@Controller('/avatar')
class Controller {

  constructor(assetService: AssetService, imageService: ImageService) {}

  @AssetUpload()
  @Post('/')
  async setAvatar(req:Request, res:Response) {
    const stored = await this.assetService.store(req.files[0]);
    return {
      path: stored.path
    };
  }

  @Get('/:path')
  async getAvatar(req:Request) {
    return await this.imageService.get(req.params.path, {w: req.query.w, h: req.query.h});
  }
}
0.2.2

6 years ago

0.2.0

6 years ago

0.1.11

6 years ago

0.1.10

6 years ago

0.1.9

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago