diff --git a/06-Digging-Deeper/05-Public-Files.adoc b/06-Digging-Deeper/05-Public-Files.adoc new file mode 100644 index 0000000..3794bb1 --- /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 a CDN or a reverse proxy(i.e Nginx or Apache) to serve static files. + +== Setup + +To serve public files, the `Adonis/Middleware/Static` server middleware must be enabled in the file `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