Compare commits

...

10 Commits

Author SHA1 Message Date
Harminder Virk
ad11b7abec
fix: limit bodyparser semver range to patch version only 2021-03-23 10:18:16 +05:30
Michael
5d33c006a2 gitignore all sqlite files inside db folder (#45) 2019-10-22 09:31:28 +02:00
Zane Chua
2112a60001 Update session.js redis configuration (#42) 2019-05-27 09:42:37 +02:00
mrpetrocket
7b9affcb8f Fix typos (#39) 2019-03-24 21:35:21 +01:00
Mahdi Tamadon
44d80187c6 feat(gitignore): Ignore VSCode & Webstorm history directories (#38)
Committing history and other IDE/Editor files make problem in team projects.
2019-02-06 18:59:15 +01:00
Will Vincent
fd621ca5ae fix(trait): syntax error (#37) 2019-01-21 10:04:24 +01:00
Romain Lanz
8e46d02ed1
feat: add NoTimestamp trait + ConvertEmptyStringsToNull middleware (#30)
Hey! 👋 

This PR add some middleware and traits by default.

**Middleware**:

- `AllowGuestOnly` throws an exception if you are authenticated.
- `ConvertEmptyStringsToNull` converts empty strings in the request body to `null`

**Trait**:

- `NoTimestamp` removes the need for `created_at` and `updated_at` fields.
- `FormatDate` formats the date following a convention.

**FormatDate**

The convention is:
- Ends with `_at` => DateTime
- Ends with `_on` => Date

You can change the format you use in your UI with two getters.

```js
class MyModel extends Model {
  static get formatDate () { return 'DD.MM.YYYY' }
  static get formatDateTime () { return 'DD.MM.YYYY HH:mm' }
}
```

You can also directly change default values inside the Trait since it is a user Trait and not defined in the core.

<hr>

If this is merged, I'll provide the same PR to the `API` blueprint.
2019-01-02 10:10:56 +01:00
Jonathan
29d8045f57 feat(views): link to the doc (#34)
* feat(views): link to the doc

* typo(views): removed extra space

Co-Authored-By: Grafikart <Grafikart@users.noreply.github.com>
2018-12-27 08:47:12 +01:00
Romain Lanz
403223214f
fix(route): fix import syntax 2018-10-05 15:14:58 +02:00
Harminder Virk
bbcefa9097 feat(middleware): add named guest middleware 2018-10-01 20:28:31 +02:00
10 changed files with 75 additions and 15 deletions

6
.gitignore vendored
View File

@ -9,4 +9,8 @@ tmp
.env .env
# The development sqlite file # The development sqlite file
database/development.sqlite database/*.sqlite
# VSCode & Webstorm history directories
.history
.idea

View File

@ -0,0 +1,17 @@
'use strict'
class ConvertEmptyStringsToNull {
async handle ({ request }, next) {
if (Object.keys(request.body).length) {
request.body = Object.assign(
...Object.keys(request.body).map(key => ({
[key]: request.body[key] !== '' ? request.body[key] : null
}))
)
}
await next()
}
}
module.exports = ConvertEmptyStringsToNull

View File

@ -0,0 +1,16 @@
'use strict'
class NoTimestamp {
register (Model) {
Object.defineProperties(Model, {
createdAtColumn: {
get: () => null,
},
updatedAtColumn: {
get: () => null,
},
})
}
}
module.exports = NoTimestamp

View File

@ -10,7 +10,7 @@ module.exports = {
| Application Name | Application Name
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| This value is the name of your application and can used when you | This value is the name of your application and can be used when you
| need to place the application's name in a email, view or | need to place the application's name in a email, view or
| other location. | other location.
| |
@ -35,7 +35,7 @@ module.exports = {
| Allow Method Spoofing | Allow Method Spoofing
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Method spoofing allows to make requests by spoofing the http verb. | Method spoofing allows you to make requests by spoofing the http verb.
| Which means you can make a GET request but instruct the server to | Which means you can make a GET request but instruct the server to
| treat as a POST or PUT request. If you want this feature, set the | treat as a POST or PUT request. If you want this feature, set the
| below value to true. | below value to true.
@ -48,10 +48,10 @@ module.exports = {
| Trust Proxy | Trust Proxy
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Trust proxy defines whether X-Forwaded-* headers should be trusted or not. | Trust proxy defines whether X-Forwarded-* headers should be trusted or not.
| When your application is behind a proxy server like nginx, these values | When your application is behind a proxy server like nginx, these values
| are set automatically and should be trusted. Apart from setting it | are set automatically and should be trusted. Apart from setting it
| to true or false Adonis supports handful or ways to allow proxy | to true or false Adonis supports a handful of ways to allow proxy
| values. Read documentation for that. | values. Read documentation for that.
| |
*/ */
@ -62,7 +62,7 @@ module.exports = {
| Subdomains | Subdomains
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Offset to be used for returning subdomains for a given request.For | Offset to be used for returning subdomains for a given request. For
| majority of applications it will be 2, until you have nested | majority of applications it will be 2, until you have nested
| sudomains. | sudomains.
| cheatsheet.adonisjs.com - offset - 2 | cheatsheet.adonisjs.com - offset - 2
@ -88,7 +88,7 @@ module.exports = {
| Etag | Etag
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Set etag on all HTTP response. In order to disable for selected routes, | Set etag on all HTTP responses. In order to disable for selected routes,
| you can call the `response.send` with an options object as follows. | you can call the `response.send` with an options object as follows.
| |
| response.send('Hello', { ignoreEtag: true }) | response.send('Hello', { ignoreEtag: true })
@ -116,9 +116,9 @@ module.exports = {
| Dot Files | Dot Files
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| |
| Define how to treat dot files when trying to server static resources. | Define how to treat dot files when trying to serve static resources.
| By default it is set to ignore, which will pretend that dotfiles | By default it is set to ignore, which will pretend that dotfiles
| does not exists. | do not exist.
| |
| Can be one of the following | Can be one of the following
| ignore, deny, allow | ignore, deny, allow

View File

@ -91,5 +91,11 @@ module.exports = {
| the redis file. But you are free to define an object here too. | the redis file. But you are free to define an object here too.
| |
*/ */
redis: 'self::redis.local' redis: {
host: '127.0.0.1',
port: 6379,
password: null,
db: 0,
keyPrefix: ''
}
} }

View File

@ -18,7 +18,7 @@
"dependencies": { "dependencies": {
"@adonisjs/ace": "^5.0.8", "@adonisjs/ace": "^5.0.8",
"@adonisjs/auth": "^3.0.7", "@adonisjs/auth": "^3.0.7",
"@adonisjs/bodyparser": "^2.0.5", "@adonisjs/bodyparser": "~2.0.9",
"@adonisjs/cors": "^1.0.7", "@adonisjs/cors": "^1.0.7",
"@adonisjs/fold": "^4.0.9", "@adonisjs/fold": "^4.0.9",
"@adonisjs/framework": "^5.0.9", "@adonisjs/framework": "^5.0.9",

View File

@ -67,6 +67,16 @@ section:before {
animation: slideUp 1s cubic-bezier(0.19, 1, 0.30, 1) 0.5s forwards; animation: slideUp 1s cubic-bezier(0.19, 1, 0.30, 1) 0.5s forwards;
} }
a {
color: inherit;
text-decoration: underline;
}
p {
margin: 0.83rem 0;
}
@keyframes slideUp { @keyframes slideUp {
0% { 0% {
transform: translateY(40px); transform: translateY(40px);

View File

@ -9,7 +9,12 @@
<section> <section>
<div class="logo"></div> <div class="logo"></div>
<div class="title"></div> <div class="title"></div>
<div class="subtitle"><p>AdonisJs simplicity will make you feel confident about your code</p></div> <div class="subtitle">
<p>AdonisJs simplicity will make you feel confident about your code</p>
<p>
Don't know where to start? Read the <a href="https://adonisjs.com/docs">documentation</a>.
</p>
</div>
</section> </section>
</body> </body>
</html> </html>

View File

@ -16,7 +16,8 @@ const globalMiddleware = [
'Adonis/Middleware/BodyParser', 'Adonis/Middleware/BodyParser',
'Adonis/Middleware/Session', 'Adonis/Middleware/Session',
'Adonis/Middleware/Shield', 'Adonis/Middleware/Shield',
'Adonis/Middleware/AuthInit' 'Adonis/Middleware/AuthInit',
'App/Middleware/ConvertEmptyStringsToNull',
] ]
/* /*
@ -37,7 +38,8 @@ const globalMiddleware = [
| |
*/ */
const namedMiddleware = { const namedMiddleware = {
auth: 'Adonis/Middleware/Auth' auth: 'Adonis/Middleware/Auth',
guest: 'Adonis/Middleware/AllowGuestOnly'
} }
/* /*

View File

@ -13,7 +13,7 @@
| |
*/ */
/** @type {typeof import('@adonisjs/framework/src/Route/Manager'} */ /** @type {typeof import('@adonisjs/framework/src/Route/Manager')} */
const Route = use('Route') const Route = use('Route')
Route.on('/').render('welcome') Route.on('/').render('welcome')