1 | <p align="center">
|
2 | <a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo_text.svg" width="320" alt="Nest Logo" /></a>
|
3 | </p>
|
4 |
|
5 | [travis-image]: https://api.travis-ci.org/nestjs/nest.svg?branch=master
|
6 | [travis-url]: https://travis-ci.org/nestjs/nest
|
7 | [linux-image]: https://img.shields.io/travis/nestjs/nest/master.svg?label=linux
|
8 | [linux-url]: https://travis-ci.org/nestjs/nest
|
9 |
|
10 | <p align="center">A progressive <a href="http://nodejs.org" target="blank">Node.js</a> framework for building efficient and scalable server-side applications, heavily inspired by <a href="https://angular.io" target="blank">Angular</a>.</p>
|
11 | <p align="center">
|
12 | <a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
13 | <a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
14 | <a href="https://www.npmjs.com/~nestjscore"><img src="https://img.shields.io/npm/dm/@nestjs/core.svg" alt="NPM Downloads" /></a>
|
15 | <a href="https://travis-ci.org/nestjs/nest"><img src="https://api.travis-ci.org/nestjs/nest.svg?branch=master" alt="Travis" /></a>
|
16 | <a href="https://travis-ci.org/nestjs/nest"><img src="https://img.shields.io/travis/nestjs/nest/master.svg?label=linux" alt="Linux" /></a>
|
17 | <a href="https://coveralls.io/github/nestjs/nest?branch=master"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#5" alt="Coverage" /></a>
|
18 | <a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
19 | <a href="https://opencollective.com/nest#backer"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
20 | <a href="https://opencollective.com/nest#sponsor"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
21 | <a href="https://paypal.me/kamilmysliwiec"><img src="https://img.shields.io/badge/Donate-PayPal-dc3d53.svg"/></a>
|
22 | <a href="https://twitter.com/nestframework"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
|
23 | </p>
|
24 | |
25 | [![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
|
26 |
|
27 | ## Description
|
28 |
|
29 | Serve Static module for [Nest](https://github.com/nestjs/nest).
|
30 |
|
31 | ## Installation
|
32 |
|
33 | ```bash
|
34 | $ npm i --save @nestjs/serve-static
|
35 | ```
|
36 |
|
37 | ## Example
|
38 |
|
39 | See full example [here](https://github.com/nestjs/nest/tree/master/sample/24-serve-static).
|
40 |
|
41 | ## Usage
|
42 |
|
43 | Simply import `ServeStaticModule` in your Nest application.
|
44 |
|
45 | ```typescript
|
46 | import { Module } from '@nestjs/common';
|
47 | import { join } from 'path';
|
48 | import { ServeStaticModule } from '@nestjs/serve-static';
|
49 |
|
50 | @Module({
|
51 | imports: [
|
52 | ServeStaticModule.forRoot({
|
53 | rootPath: join(__dirname, '..', 'client'),
|
54 | }),
|
55 | ],
|
56 | })
|
57 | export class ApplicationModule {}
|
58 | ```
|
59 |
|
60 | ## API Spec
|
61 |
|
62 | The `forRoot()` method takes an options object with a few useful properties.
|
63 |
|
64 | | Property | Type | Description |
|
65 | | ------------- | ------------- | ----- |
|
66 | | `rootPath` | string | Static files root directory. Default: "client/dist"|
|
67 | | `renderPath` | string | Path to render static app. Default: * (wildcard - all paths)|
|
68 | | `serveStaticOptions` | Object | Serve static options (static files) |
|
69 |
|
70 | ## Support
|
71 |
|
72 | Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
73 |
|
74 | ## Stay in touch
|
75 |
|
76 | * Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
|
77 | * Website - [https://nestjs.com](https://nestjs.com/)
|
78 | * Twitter - [@nestframework](https://twitter.com/nestframework)
|
79 |
|
80 | ## License
|
81 |
|
82 | Nest is [MIT licensed](LICENSE).
|