-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ce6b4d1
Showing
65 changed files
with
24,414 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
root = true | ||
|
||
end_of_line = lf | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = false | ||
insert_final_newline = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
docker-compose.yml | ||
docker-data/* | ||
.vsls | ||
.idea | ||
.env | ||
.vscode/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 Gabriel Roque | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Dockerfile | ||
.dockerignore | ||
.git/ | ||
.gitignore | ||
node_modules/ | ||
.env.example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
root = true | ||
|
||
end_of_line = lf | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = false | ||
insert_final_newline = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
HOST=0.0.0.0 | ||
PORT=8080 | ||
NODE_ENV=development | ||
|
||
APP_NAME=StarWarsBattle | ||
APP_URL=http://${HOST}:${PORT} | ||
|
||
CACHE_VIEWS=false | ||
|
||
APP_KEY= | ||
|
||
DB_CONNECTION=pg | ||
DB_HOST=127.0.0.1 | ||
DB_PORT=5432 | ||
DB_USER=adonis_usr | ||
DB_PASSWORD=123456 | ||
DB_DATABASE=adonis_db | ||
|
||
HASH_DRIVER=bcrypt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Node modules | ||
node_modules | ||
|
||
# Adonis directory for storing tmp files | ||
tmp | ||
|
||
# Environment variables, never commit this file | ||
.env | ||
|
||
# The development sqlite file | ||
database/*.sqlite |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM node:12.2.0-alpine | ||
|
||
WORKDIR /api | ||
|
||
COPY ./package.json /api | ||
RUN sh -c 'npm install' | ||
|
||
COPY ./ /api | ||
|
||
EXPOSE 8080 | ||
|
||
# CMD [ "npm", "start"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict' | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Ace Commands | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The ace file is just a regular Javascript file but with no extension. You | ||
| can call `node ace` followed by the command name and it just works. | ||
| | ||
| Also you can use `adonis` followed by the command name, since the adonis | ||
| global proxies all the ace commands. | ||
| | ||
*/ | ||
|
||
const { Ignitor } = require('@adonisjs/ignitor') | ||
|
||
new Ignitor(require('@adonisjs/fold')) | ||
.appRoot(__dirname) | ||
.fireAce() | ||
.catch(console.error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
'use strict' | ||
|
||
/** @type {typeof import('@adonisjs/lucid/src/Lucid/Model')} */ | ||
const Model = use('Model') | ||
|
||
class Token extends Model { | ||
} | ||
|
||
module.exports = Token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict' | ||
|
||
class NoTimestamp { | ||
register (Model) { | ||
Object.defineProperties(Model, { | ||
createdAtColumn: { | ||
get: () => null, | ||
}, | ||
updatedAtColumn: { | ||
get: () => null, | ||
} | ||
}) | ||
} | ||
} | ||
|
||
module.exports = NoTimestamp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'use strict' | ||
|
||
/** @type {typeof import('@adonisjs/lucid/src/Lucid/Model')} */ | ||
const Model = use('Model') | ||
|
||
/** @type {import('@adonisjs/framework/src/Hash')} */ | ||
const Hash = use('Hash') | ||
|
||
class User extends Model { | ||
static boot () { | ||
super.boot() | ||
|
||
/** | ||
* A hook to hash the user password before saving | ||
* it to the database. | ||
*/ | ||
this.addHook('beforeSave', async (userInstance) => { | ||
if (userInstance.dirty.password) { | ||
userInstance.password = await Hash.make(userInstance.password) | ||
} | ||
}) | ||
} | ||
|
||
/** | ||
* A relationship on tokens is required for auth to | ||
* work. Since features like `refreshTokens` or | ||
* `rememberToken` will be saved inside the | ||
* tokens table. | ||
* | ||
* @method tokens | ||
* | ||
* @return {Object} | ||
*/ | ||
tokens () { | ||
return this.hasMany('App/Models/Token') | ||
} | ||
} | ||
|
||
module.exports = User |
Oops, something went wrong.