From ff7dab91041db8c1776011d1cc4b1313f0a94428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Margus=20Kevin=20S=C3=BCnter?= Date: Tue, 27 Aug 2019 15:01:04 +0300 Subject: [PATCH 1/2] Added initial public files doc --- 06-Digging-Deeper/05-Public-Files.adoc | 59 +++++++++++++++++++ .../{05-Helpers.adoc => 06-Helpers.adoc} | 0 ...tion.adoc => 07-Internationalization.adoc} | 0 .../{07-Mails.adoc => 08-Mails.adoc} | 0 ...ion.adoc => 09-Social-Authentication.adoc} | 0 5 files changed, 59 insertions(+) create mode 100644 06-Digging-Deeper/05-Public-Files.adoc rename 06-Digging-Deeper/{05-Helpers.adoc => 06-Helpers.adoc} (100%) rename 06-Digging-Deeper/{06-Internationalization.adoc => 07-Internationalization.adoc} (100%) rename 06-Digging-Deeper/{07-Mails.adoc => 08-Mails.adoc} (100%) rename 06-Digging-Deeper/{08-Social-Authentication.adoc => 09-Social-Authentication.adoc} (100%) diff --git a/06-Digging-Deeper/05-Public-Files.adoc b/06-Digging-Deeper/05-Public-Files.adoc new file mode 100644 index 0000000..a239930 --- /dev/null +++ b/06-Digging-Deeper/05-Public-Files.adoc @@ -0,0 +1,59 @@ +--- +title: Public Files +permalink: public-files +category: digging-deeper +--- + += Public Files + +toc::[] + +AdonisJS can serve static assets and public files + +NOTE: It would be better to use CDN or reverse proxy like Nginx / Apache etc to serve static files + +== Setup + +To serve public files `'Adonis/Middleware/Static',` server middleware must be enabled in `start/kernel.js` + +.start/kernel.js +[source, js] +---- +const serverMiddleware = [ + 'Adonis/Middleware/Static', +] +---- + +All files in `public` folder will be served as static files + +== Config +Static files configuration is in `config/app.js` and accepts the following options. + +=== dotfiles +Define how to treat dot files when trying to server static resources. + +You can return one of the following values: + +[ul-spaced] +- "ignore" - will ignore dot files and throw not found 404 error +- "deny" - will deny access to dot files and throw forbidden 403 error +- "allow" - will allow access to dot files + +=== etag +Enable or disable etag header generation + +It can be set to boolean `true` or `false` + + +=== extensions +Set file extension fallbacks. + +When set, if a file is not found, the given +extensions will be added to the file name and search for. The first +that exists will be served + +It can be set to array of strings. + +Example value: ['html', 'htm'] + +When there is file `hello-world.html` inside `public` folder visiting http://localhost:3333/hello-world would return `hello-world.html` diff --git a/06-Digging-Deeper/05-Helpers.adoc b/06-Digging-Deeper/06-Helpers.adoc similarity index 100% rename from 06-Digging-Deeper/05-Helpers.adoc rename to 06-Digging-Deeper/06-Helpers.adoc diff --git a/06-Digging-Deeper/06-Internationalization.adoc b/06-Digging-Deeper/07-Internationalization.adoc similarity index 100% rename from 06-Digging-Deeper/06-Internationalization.adoc rename to 06-Digging-Deeper/07-Internationalization.adoc diff --git a/06-Digging-Deeper/07-Mails.adoc b/06-Digging-Deeper/08-Mails.adoc similarity index 100% rename from 06-Digging-Deeper/07-Mails.adoc rename to 06-Digging-Deeper/08-Mails.adoc diff --git a/06-Digging-Deeper/08-Social-Authentication.adoc b/06-Digging-Deeper/09-Social-Authentication.adoc similarity index 100% rename from 06-Digging-Deeper/08-Social-Authentication.adoc rename to 06-Digging-Deeper/09-Social-Authentication.adoc From 3b4dd77cdc41a9930563fb1a2b7613ac25cffc19 Mon Sep 17 00:00:00 2001 From: McSneaky Date: Wed, 23 Oct 2019 08:14:30 +0300 Subject: [PATCH 2/2] Fix some wording and typos based on code review Co-Authored-By: Romain Lanz <2793951+RomainLanz@users.noreply.github.com> --- 06-Digging-Deeper/05-Public-Files.adoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/06-Digging-Deeper/05-Public-Files.adoc b/06-Digging-Deeper/05-Public-Files.adoc index a239930..3794bb1 100644 --- a/06-Digging-Deeper/05-Public-Files.adoc +++ b/06-Digging-Deeper/05-Public-Files.adoc @@ -10,11 +10,11 @@ toc::[] AdonisJS can serve static assets and public files -NOTE: It would be better to use CDN or reverse proxy like Nginx / Apache etc to serve static files +NOTE: It would be better to use a CDN or a reverse proxy(i.e Nginx or Apache) to serve static files. == Setup -To serve public files `'Adonis/Middleware/Static',` server middleware must be enabled in `start/kernel.js` +To serve public files, the `Adonis/Middleware/Static` server middleware must be enabled in the file `start/kernel.js`. .start/kernel.js [source, js]