8/30/2023 0 Comments Express server![]() ![]() Nest.js fully supports TypeScript and uses it by default, but you can use JavaScript instead if you prefer.Īdditionally, Nest.js has a CLI tool that makes development easier by automating tasks such as generating boilerplate code. Nest.js uses the Express.js framework by default, but you can configure it to use an alternative like Fastify. It provides an out-of-the-box application architecture inspired by Angular, which allows you to create testable, loosely coupled, maintainable applications. Nest.js is a progressive Node.js framework for building efficient and maintainable server-side applications. Previous: Basic Routing Next: More examplesĭocumentation translations provided by StrongLoop/IBM:įrench, German, Spanish, Italian, Japanese, Russian, Chinese, Traditional Chinese, Korean, Portuguese.Ĭommunity translation available for: Slovak, Ukrainian, Uzbek, Turkish and Thai.Explore some of the most popular Express.js alternatives and their key benefits and features. ![]() If you run the express app from another directory, it’s safer to use the absolute path of the directory that you want to serve: const path = require('path')Īpp.use('/static', express.static(path.join(_dirname, 'public')))įor more details about the serve-static function and its options, see serve-static. However, the path that you provide to the express.static function is relative to the directory from where you launch your node process. Now, you can load the files that are in the public directory from the /static path prefix. To create a virtual path prefix (where the path does not actually exist in the file system) for files that are served by the express.static function, specify a mount path for the static directory, as shown below: app.use('/static', express.static('public')) NOTE: For best results, use a reverse proxy cache to improve performance of serving static assets. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |