├── .editorconfig ├── .env.example ├── .gitignore ├── README.md ├── ace ├── app └── Models │ ├── Token.js │ └── User.js ├── config ├── app.js ├── auth.js ├── bodyParser.js ├── cors.js ├── database.js ├── hash.js ├── session.js └── shield.js ├── database ├── factory.js └── migrations │ ├── 1503248427885_user.js │ └── 1503248427886_token.js ├── package-lock.json ├── package.json ├── public ├── css │ └── app.css ├── favicon.ico ├── images │ ├── logo.svg │ ├── pyramid.png │ ├── splash.png │ └── title.svg ├── js │ └── app.js ├── mix-manifest.json └── robots.txt ├── resources ├── assets │ ├── images │ │ ├── logo.svg │ │ ├── pyramid.png │ │ ├── splash.png │ │ └── title.svg │ ├── js │ │ ├── app.js │ │ ├── bootstrap.js │ │ └── components │ │ │ └── Sentence.vue │ └── sass │ │ └── app.scss └── views │ └── welcome.edge ├── server.js ├── start ├── app.js ├── hooks.js ├── kernel.js └── routes.js └── webpack.mix.js /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_size = 2 6 | indent_style = space 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | HOST=127.0.0.1 2 | PORT=3333 3 | NODE_ENV=development 4 | APP_URL=http://${HOST}:${PORT} 5 | 6 | CACHE_VIEWS=false 7 | 8 | APP_KEY= 9 | 10 | DB_CONNECTION=sqlite 11 | DB_HOST=127.0.0.1 12 | DB_PORT=3306 13 | DB_USER=root 14 | DB_PASSWORD= 15 | DB_DATABASE=adonis 16 | 17 | SESSION_DRIVER=cookie 18 | HASH_DRIVER=bcrypt 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Node modules 2 | node_modules 3 | 4 | # Adonis directory for storing tmp files 5 | tmp 6 | 7 | # Environment variables, never commit this file 8 | .env 9 | 10 | # The development sqlite file 11 | database/development.sqlite 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## NOTE: 2 | 3 | **This project moved to: [marcim/adonis-fullstack-app-laravelmix](https://github.com/marcim/adonis-fullstack-app-laravelmix).** 4 | 5 | On attempt to simplify Adonis updates, the repository content was migrated to: [marcim/adonis-fullstack-app-laravelmix](https://github.com/marcim/adonis-fullstack-app-laravelmix) and this page is outdated. Sorry for inconvenience, I hope you understand! 6 | 7 | # AdonisJs Laravel Mix 8 | 9 | [AdonisJs](http://adonisjs.com/) + [Laravel Mix](https://laravel.com/docs/5.6/mix) 10 | 11 | 12 | When you start a new project with *AdonisJs* it makes use of blueprints to create the project files structure. This repository is just a blueprint that integrates *Laravel Mix* with *Adonis fullstack app*. 13 | 14 | 15 | ## Install 16 | 17 | Create a new project with: 18 | 19 | ```shell 20 | adonis new --blueprint marcim/adonisjs-laravel-mix 21 | ``` 22 | 23 | > Change `` to your project name. 24 | 25 | 26 | ## Usage 27 | 28 | The following commands are available: 29 | 30 | | Command | Description | 31 | |---------|-------------| 32 | | npm run asset-dev | Compiles assets in development mode. | 33 | | npm run asset-watch | Compiles assets in development mode and watches changes. | 34 | | npm run asset-watch-pool | Same as above, used in [some cases](https://laravel.com/docs/5.6/mix#running-mix). | 35 | | npm run asset-hot | Compiles assets in development mode with hot reload option activated. | 36 | | npm run asset-prod | Compiles assets for production. | 37 | 38 | 39 | ## Features 40 | 41 | For more information see: [AdonisJs documentation](http://adonisjs.com/docs) and [Laravel Mix documentation](https://laravel.com/docs/5.6/mix). 42 | 43 | 44 | ## Licenses 45 | 46 | [AdonisJs license](https://github.com/adonisjs/adonis-framework/blob/develop/LICENSE.txt) 47 | [Laravel Mix license](https://github.com/JeffreyWay/laravel-mix/blob/master/LICENSE) 48 | [VueJs license](https://github.com/vuejs/vue/blob/master/LICENSE) 49 | 50 | 51 | ## Contributing 52 | 53 | Suggestions and contributions are welcome via Pull Requests. 54 | 55 | 56 | Thanks! 57 | -------------------------------------------------------------------------------- /ace: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Ace Commands 6 | |-------------------------------------------------------------------------- 7 | | 8 | | The ace file is just a regular Javascript file but with no extension. You 9 | | can call `node ace` followed by the command name and it just works. 10 | | 11 | | Also you can use `adonis` followed by the command name, since the adonis 12 | | global proxy all the ace commands. 13 | | 14 | */ 15 | 16 | const { Ignitor } = require('@adonisjs/ignitor') 17 | 18 | new Ignitor(require('@adonisjs/fold')) 19 | .appRoot(__dirname) 20 | .fireAce() 21 | .catch(console.error) 22 | -------------------------------------------------------------------------------- /app/Models/Token.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Model = use('Model') 4 | 5 | class Token extends Model { 6 | } 7 | 8 | module.exports = Token 9 | -------------------------------------------------------------------------------- /app/Models/User.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Hash = use('Hash') 4 | const Model = use('Model') 5 | 6 | class User extends Model { 7 | static boot () { 8 | super.boot() 9 | 10 | /** 11 | * A hook to hash the user password before saving 12 | * it to the database. 13 | */ 14 | this.addHook('beforeCreate', async (userInstance) => { 15 | if (userInstance.dirty.password) { 16 | userInstance.password = await Hash.make(userInstance.password) 17 | } 18 | }) 19 | } 20 | 21 | /** 22 | * A relationship on tokens is required for auth to 23 | * work. Since features like `refreshTokens` or 24 | * `rememberToken` will be saved inside the 25 | * tokens table. 26 | * 27 | * @method tokens 28 | * 29 | * @return {Object} 30 | */ 31 | tokens () { 32 | return this.hasMany('App/Models/Token') 33 | } 34 | } 35 | 36 | module.exports = User 37 | -------------------------------------------------------------------------------- /config/app.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Env = use('Env') 4 | 5 | module.exports = { 6 | /* 7 | |-------------------------------------------------------------------------- 8 | | App Key 9 | |-------------------------------------------------------------------------- 10 | | 11 | | App key is a randomly generated 16 or 32 characters long string required 12 | | to encrypted cookies, sessions and other sensitive data. 13 | | 14 | */ 15 | appKey: Env.get('APP_KEY'), 16 | 17 | http: { 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Allow Method Spoofing 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Method spoofing allows to make requests by spoofing the http verb. 24 | | Which means you can make a GET request but instruct the server to 25 | | treat as a POST or PUT request. If you want this feature, set the 26 | | below value to true. 27 | | 28 | */ 29 | allowMethodSpoofing: true, 30 | 31 | /* 32 | |-------------------------------------------------------------------------- 33 | | Trust Proxy 34 | |-------------------------------------------------------------------------- 35 | | 36 | | Trust proxy defines whether X-Forwaded-* headers should be trusted or not. 37 | | When your application is behind a proxy server like nginx, these values 38 | | are set automatically and should be trusted. Apart from setting it 39 | | to true or false Adonis supports handful or ways to allow proxy 40 | | values. Read documentation for that. 41 | | 42 | */ 43 | trustProxy: false, 44 | 45 | /* 46 | |-------------------------------------------------------------------------- 47 | | Subdomains 48 | |-------------------------------------------------------------------------- 49 | | 50 | | Offset to be used for returning subdomains for a given request.For 51 | | majority of applications it will be 2, until you have nested 52 | | sudomains. 53 | | cheatsheet.adonisjs.com - offset - 2 54 | | virk.cheatsheet.adonisjs.com - offset - 3 55 | | 56 | */ 57 | subdomainOffset: 2, 58 | 59 | /* 60 | |-------------------------------------------------------------------------- 61 | | JSONP Callback 62 | |-------------------------------------------------------------------------- 63 | | 64 | | Default jsonp callback to be used when callback query string is missing 65 | | in request url. 66 | | 67 | */ 68 | jsonpCallback: 'callback', 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | Etag 73 | |-------------------------------------------------------------------------- 74 | | 75 | | Set etag on all HTTP response. In order to disable for selected routes, 76 | | you can call the `response.send` with an options object as follows. 77 | | 78 | | response.send('Hello', { ignoreEtag: true }) 79 | | 80 | */ 81 | etag: false 82 | }, 83 | 84 | views: { 85 | /* 86 | |-------------------------------------------------------------------------- 87 | | Cache Views 88 | |-------------------------------------------------------------------------- 89 | | 90 | | Define whether or not to cache the compiled view. Set it to true in 91 | | production to optimize view loading time. 92 | | 93 | */ 94 | cache: Env.get('CACHE_VIEWS', true) 95 | }, 96 | 97 | static: { 98 | /* 99 | |-------------------------------------------------------------------------- 100 | | Dot Files 101 | |-------------------------------------------------------------------------- 102 | | 103 | | Define how to treat dot files when trying to server static resources. 104 | | By default it is set to ignore, which will pretend that dotfiles 105 | | does not exists. 106 | | 107 | | Can be one of the following 108 | | ignore, deny, allow 109 | | 110 | */ 111 | dotfiles: 'ignore', 112 | 113 | /* 114 | |-------------------------------------------------------------------------- 115 | | ETag 116 | |-------------------------------------------------------------------------- 117 | | 118 | | Enable or disable etag generation 119 | | 120 | */ 121 | etag: true, 122 | 123 | /* 124 | |-------------------------------------------------------------------------- 125 | | Extensions 126 | |-------------------------------------------------------------------------- 127 | | 128 | | Set file extension fallbacks. When set, if a file is not found, the given 129 | | extensions will be added to the file name and search for. The first 130 | | that exists will be served. Example: ['html', 'htm']. 131 | | 132 | */ 133 | extensions: false 134 | }, 135 | 136 | locales: { 137 | /* 138 | |-------------------------------------------------------------------------- 139 | | Loader 140 | |-------------------------------------------------------------------------- 141 | | 142 | | The loader to be used for fetching and updating locales. Below is the 143 | | list of available options. 144 | | 145 | | file, database 146 | | 147 | */ 148 | loader: 'file', 149 | 150 | /* 151 | |-------------------------------------------------------------------------- 152 | | Default Locale 153 | |-------------------------------------------------------------------------- 154 | | 155 | | Default locale to be used by Antl provider. You can always switch drivers 156 | | in runtime or use the official Antl middleware to detect the driver 157 | | based on HTTP headers/query string. 158 | | 159 | */ 160 | locale: 'en' 161 | }, 162 | 163 | logger: { 164 | /* 165 | |-------------------------------------------------------------------------- 166 | | Transport 167 | |-------------------------------------------------------------------------- 168 | | 169 | | Transport to be used for logging messages. You can have multiple 170 | | transports using same driver. 171 | | 172 | | Available drivers are: `file` and `console`. 173 | | 174 | */ 175 | transport: 'console', 176 | 177 | /* 178 | |-------------------------------------------------------------------------- 179 | | Console Transport 180 | |-------------------------------------------------------------------------- 181 | | 182 | | Using `console` driver for logging. This driver writes to `stdout` 183 | | and `stderr` 184 | | 185 | */ 186 | console: { 187 | driver: 'console', 188 | name: 'adonis-app', 189 | level: 'info' 190 | }, 191 | 192 | /* 193 | |-------------------------------------------------------------------------- 194 | | File Transport 195 | |-------------------------------------------------------------------------- 196 | | 197 | | File transport uses file driver and writes log messages for a given 198 | | file inside `tmp` directory for your app. 199 | | 200 | | For a different directory, set an absolute path for the filename. 201 | | 202 | */ 203 | file: { 204 | driver: 'file', 205 | name: 'adonis-app', 206 | filename: 'adonis.log', 207 | level: 'info' 208 | } 209 | } 210 | } 211 | -------------------------------------------------------------------------------- /config/auth.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Env = use('Env') 4 | 5 | module.exports = { 6 | /* 7 | |-------------------------------------------------------------------------- 8 | | Authenticator 9 | |-------------------------------------------------------------------------- 10 | | 11 | | Authentication is a combination of serializer and scheme with extra 12 | | config to define on how to authenticate a user. 13 | | 14 | | Available Schemes - basic, session, jwt, api 15 | | Available Serializers - lucid, database 16 | | 17 | */ 18 | authenticator: 'session', 19 | 20 | /* 21 | |-------------------------------------------------------------------------- 22 | | Session 23 | |-------------------------------------------------------------------------- 24 | | 25 | | Session authenticator makes use of sessions to authenticate a user. 26 | | Session authentication is always persistent. 27 | | 28 | */ 29 | session: { 30 | serializer: 'lucid', 31 | model: 'App/Models/User', 32 | scheme: 'session', 33 | uid: 'email', 34 | password: 'password' 35 | }, 36 | 37 | /* 38 | |-------------------------------------------------------------------------- 39 | | Basic Auth 40 | |-------------------------------------------------------------------------- 41 | | 42 | | The basic auth authenticator uses basic auth header to authenticate a 43 | | user. 44 | | 45 | | NOTE: 46 | | This scheme is not persistent and users are supposed to pass 47 | | login credentials on each request. 48 | | 49 | */ 50 | basic: { 51 | serializer: 'lucid', 52 | model: 'App/Models/User', 53 | scheme: 'basic', 54 | uid: 'email', 55 | password: 'password' 56 | }, 57 | 58 | /* 59 | |-------------------------------------------------------------------------- 60 | | Jwt 61 | |-------------------------------------------------------------------------- 62 | | 63 | | The jwt authenticator works by passing a jwt token on each HTTP request 64 | | via HTTP `Authorization` header. 65 | | 66 | */ 67 | jwt: { 68 | serializer: 'lucid', 69 | model: 'App/Models/User', 70 | scheme: 'jwt', 71 | uid: 'email', 72 | password: 'password', 73 | options: { 74 | secret: Env.get('APP_KEY') 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /config/bodyParser.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | /* 5 | |-------------------------------------------------------------------------- 6 | | JSON Parser 7 | |-------------------------------------------------------------------------- 8 | | 9 | | Below settings are applied when request body contains JSON payload. If 10 | | you want body parser to ignore JSON payload, then simply set `types` 11 | | to an empty array. 12 | */ 13 | json: { 14 | /* 15 | |-------------------------------------------------------------------------- 16 | | limit 17 | |-------------------------------------------------------------------------- 18 | | 19 | | Defines the limit of JSON that can be sent by the client. If payload 20 | | is over 1mb it will not be processed. 21 | | 22 | */ 23 | limit: '1mb', 24 | 25 | /* 26 | |-------------------------------------------------------------------------- 27 | | strict 28 | |-------------------------------------------------------------------------- 29 | | 30 | | When `scrict` is set to true, body parser will only parse Arrays and 31 | | Object. Otherwise everything parseable by `JSON.parse` is parsed. 32 | | 33 | */ 34 | strict: true, 35 | 36 | /* 37 | |-------------------------------------------------------------------------- 38 | | types 39 | |-------------------------------------------------------------------------- 40 | | 41 | | Which content types are processed as JSON payloads. You are free to 42 | | add your own types here, but the request body should be parseable 43 | | by `JSON.parse` method. 44 | | 45 | */ 46 | types: [ 47 | 'application/json', 48 | 'application/json-patch+json', 49 | 'application/vnd.api+json', 50 | 'application/csp-report' 51 | ] 52 | }, 53 | 54 | /* 55 | |-------------------------------------------------------------------------- 56 | | Raw Parser 57 | |-------------------------------------------------------------------------- 58 | | 59 | | 60 | | 61 | */ 62 | raw: { 63 | types: [ 64 | 'text/*' 65 | ] 66 | }, 67 | 68 | /* 69 | |-------------------------------------------------------------------------- 70 | | Form Parser 71 | |-------------------------------------------------------------------------- 72 | | 73 | | 74 | | 75 | */ 76 | form: { 77 | types: [ 78 | 'application/x-www-form-urlencoded' 79 | ] 80 | }, 81 | 82 | /* 83 | |-------------------------------------------------------------------------- 84 | | Files Parser 85 | |-------------------------------------------------------------------------- 86 | | 87 | | 88 | | 89 | */ 90 | files: { 91 | types: [ 92 | 'multipart/form-data' 93 | ], 94 | 95 | /* 96 | |-------------------------------------------------------------------------- 97 | | Max Size 98 | |-------------------------------------------------------------------------- 99 | | 100 | | Below value is the max size of all the files uploaded to the server. It 101 | | is validated even before files have been processed and hard exception 102 | | is thrown. 103 | | 104 | | Consider setting a reasonable value here, otherwise people may upload GB's 105 | | of files which will keep your server busy. 106 | | 107 | | Also this value is considered when `autoProcess` is set to true. 108 | | 109 | */ 110 | maxSize: '20mb', 111 | 112 | /* 113 | |-------------------------------------------------------------------------- 114 | | Auto Process 115 | |-------------------------------------------------------------------------- 116 | | 117 | | Whether or not to auto-process files. Since HTTP servers handle files via 118 | | couple of specific endpoints. It is better to set this value off and 119 | | manually process the files when required. 120 | | 121 | | This value can contain a boolean or an array of route patterns 122 | | to be autoprocessed. 123 | */ 124 | autoProcess: true, 125 | 126 | /* 127 | |-------------------------------------------------------------------------- 128 | | Process Manually 129 | |-------------------------------------------------------------------------- 130 | | 131 | | The list of routes that should not process files and instead rely on 132 | | manual process. This list should only contain routes when autoProcess 133 | | is to true. Otherwise everything is processed manually. 134 | | 135 | */ 136 | processManually: [] 137 | 138 | /* 139 | |-------------------------------------------------------------------------- 140 | | Temporary file name 141 | |-------------------------------------------------------------------------- 142 | | 143 | | Define a function, which should return a string to be used as the 144 | | tmp file name. 145 | | 146 | | If not defined, Bodyparser will use `uuid` as the tmp file name. 147 | | 148 | | To be defined as. If you are defining the function, then do make sure 149 | | to return a value from it. 150 | | 151 | | tmpFileName () { 152 | | return 'some-unique-value' 153 | | } 154 | | 155 | */ 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /config/cors.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | /* 5 | |-------------------------------------------------------------------------- 6 | | Origin 7 | |-------------------------------------------------------------------------- 8 | | 9 | | Set a list of origins to be allowed. The value can be one of the following 10 | | 11 | | Boolean: true - Allow current request origin 12 | | Boolean: false - Disallow all 13 | | String - Comma seperated list of allowed origins 14 | | Array - An array of allowed origins 15 | | String: * - A wildcard to allow current request origin 16 | | Function - Receives the current origin and should return one of the above values. 17 | | 18 | */ 19 | origin: false, 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Methods 24 | |-------------------------------------------------------------------------- 25 | | 26 | | HTTP methods to be allowed. The value can be one of the following 27 | | 28 | | String - Comma seperated list of allowed methods 29 | | Array - An array of allowed methods 30 | | 31 | */ 32 | methods: ['GET', 'PUT', 'POST'], 33 | 34 | /* 35 | |-------------------------------------------------------------------------- 36 | | Headers 37 | |-------------------------------------------------------------------------- 38 | | 39 | | List of headers to be allowed via Access-Control-Request-Headers header. 40 | | The value can be on of the following. 41 | | 42 | | Boolean: true - Allow current request headers 43 | | Boolean: false - Disallow all 44 | | String - Comma seperated list of allowed headers 45 | | Array - An array of allowed headers 46 | | String: * - A wildcard to allow current request headers 47 | | Function - Receives the current header and should return one of the above values. 48 | | 49 | */ 50 | headers: true, 51 | 52 | /* 53 | |-------------------------------------------------------------------------- 54 | | Expose Headers 55 | |-------------------------------------------------------------------------- 56 | | 57 | | A list of headers to be exposed via `Access-Control-Expose-Headers` 58 | | header. The value can be on of the following. 59 | | 60 | | Boolean: false - Disallow all 61 | | String: Comma seperated list of allowed headers 62 | | Array - An array of allowed headers 63 | | 64 | */ 65 | exposeHeaders: false, 66 | 67 | /* 68 | |-------------------------------------------------------------------------- 69 | | Credentials 70 | |-------------------------------------------------------------------------- 71 | | 72 | | Define Access-Control-Allow-Credentials header. It should always be a 73 | | boolean. 74 | | 75 | */ 76 | credentials: false, 77 | 78 | /* 79 | |-------------------------------------------------------------------------- 80 | | MaxAge 81 | |-------------------------------------------------------------------------- 82 | | 83 | | Define Access-Control-Allow-Max-Age 84 | | 85 | */ 86 | maxAge: 90 87 | } 88 | -------------------------------------------------------------------------------- /config/database.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Env = use('Env') 4 | const Helpers = use('Helpers') 5 | 6 | module.exports = { 7 | /* 8 | |-------------------------------------------------------------------------- 9 | | Default Connection 10 | |-------------------------------------------------------------------------- 11 | | 12 | | Connection defines the default connection settings to be used while 13 | | interacting with SQL databases. 14 | | 15 | */ 16 | connection: Env.get('DB_CONNECTION', 'sqlite'), 17 | 18 | /* 19 | |-------------------------------------------------------------------------- 20 | | Sqlite 21 | |-------------------------------------------------------------------------- 22 | | 23 | | Sqlite is a flat file database and can be good choice under development 24 | | environment. 25 | | 26 | | npm i --save sqlite3 27 | | 28 | */ 29 | sqlite: { 30 | client: 'sqlite3', 31 | connection: { 32 | filename: Helpers.databasePath(`${Env.get('DB_DATABASE', 'development')}.sqlite`) 33 | }, 34 | useNullAsDefault: true 35 | }, 36 | 37 | /* 38 | |-------------------------------------------------------------------------- 39 | | MySQL 40 | |-------------------------------------------------------------------------- 41 | | 42 | | Here we define connection settings for MySQL database. 43 | | 44 | | npm i --save mysql 45 | | 46 | */ 47 | mysql: { 48 | client: 'mysql', 49 | connection: { 50 | host: Env.get('DB_HOST', 'localhost'), 51 | port: Env.get('DB_PORT', ''), 52 | user: Env.get('DB_USER', 'root'), 53 | password: Env.get('DB_PASSWORD', ''), 54 | database: Env.get('DB_DATABASE', 'adonis') 55 | } 56 | }, 57 | 58 | /* 59 | |-------------------------------------------------------------------------- 60 | | PostgreSQL 61 | |-------------------------------------------------------------------------- 62 | | 63 | | Here we define connection settings for PostgreSQL database. 64 | | 65 | | npm i --save pg 66 | | 67 | */ 68 | pg: { 69 | client: 'pg', 70 | connection: { 71 | host: Env.get('DB_HOST', 'localhost'), 72 | port: Env.get('DB_PORT', ''), 73 | user: Env.get('DB_USER', 'root'), 74 | password: Env.get('DB_PASSWORD', ''), 75 | database: Env.get('DB_DATABASE', 'adonis') 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /config/hash.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Env = use('Env') 4 | 5 | module.exports = { 6 | /* 7 | |-------------------------------------------------------------------------- 8 | | Driver 9 | |-------------------------------------------------------------------------- 10 | | 11 | | Driver to be used for hashing values. The same driver is used by the 12 | | auth module too. 13 | | 14 | */ 15 | driver: Env.get('HASH_DRIVER', 'bcrypt'), 16 | 17 | /* 18 | |-------------------------------------------------------------------------- 19 | | Bcrypt 20 | |-------------------------------------------------------------------------- 21 | | 22 | | Config related to bcrypt hashing. https://www.npmjs.com/package/bcrypt 23 | | package is used internally. 24 | | 25 | */ 26 | bcrypt: { 27 | rounds: 10 28 | }, 29 | 30 | /* 31 | |-------------------------------------------------------------------------- 32 | | Argon 33 | |-------------------------------------------------------------------------- 34 | | 35 | | Config related to argon. https://www.npmjs.com/package/argon2 package is 36 | | used internally. 37 | | 38 | | Since argon is optional, you will have to install the dependency yourself 39 | | 40 | |============================================================================ 41 | | npm i argon2 42 | |============================================================================ 43 | | 44 | */ 45 | argon: { 46 | type: 1 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /config/session.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Env = use('Env') 4 | 5 | module.exports = { 6 | /* 7 | |-------------------------------------------------------------------------- 8 | | Session Driver 9 | |-------------------------------------------------------------------------- 10 | | 11 | | The session driver to be used for storing session values. It can be 12 | | cookie, file or redis. 13 | | 14 | | For `redis` driver, make sure to install and register `@adonisjs/redis` 15 | | 16 | */ 17 | driver: Env.get('SESSION_DRIVER', 'cookie'), 18 | 19 | /* 20 | |-------------------------------------------------------------------------- 21 | | Cookie Name 22 | |-------------------------------------------------------------------------- 23 | | 24 | | The name of the cookie to be used for saving session id. Session ids 25 | | are signed and encrypted. 26 | | 27 | */ 28 | cookieName: 'adonis-session', 29 | 30 | /* 31 | |-------------------------------------------------------------------------- 32 | | Clear session when browser closes 33 | |-------------------------------------------------------------------------- 34 | | 35 | | If this value is true, the session cookie will be temporary and will be 36 | | removed when browser closes. 37 | | 38 | */ 39 | clearWithBrowser: true, 40 | 41 | /* 42 | |-------------------------------------------------------------------------- 43 | | Session age 44 | |-------------------------------------------------------------------------- 45 | | 46 | | This value is only used when `clearWithBrowser` is set to false. The 47 | | age must be a valid https://npmjs.org/package/ms string or should 48 | | be in milliseconds. 49 | | 50 | | Valid values are: 51 | | '2h', '10d', '5y', '2.5 hrs' 52 | | 53 | */ 54 | age: '2h', 55 | 56 | /* 57 | |-------------------------------------------------------------------------- 58 | | Cookie options 59 | |-------------------------------------------------------------------------- 60 | | 61 | | Cookie options defines the options to be used for setting up session 62 | | cookie 63 | | 64 | */ 65 | cookie: { 66 | httpOnly: true, 67 | sameSite: true, 68 | path: '/' 69 | }, 70 | 71 | /* 72 | |-------------------------------------------------------------------------- 73 | | Sessions location 74 | |-------------------------------------------------------------------------- 75 | | 76 | | If driver is set to file, we need to define the relative location from 77 | | the temporary path or absolute url to any location. 78 | | 79 | */ 80 | file: { 81 | location: 'sessions' 82 | }, 83 | 84 | /* 85 | |-------------------------------------------------------------------------- 86 | | Redis config 87 | |-------------------------------------------------------------------------- 88 | | 89 | | The configuration for the redis driver. By default we reference it from 90 | | the redis file. But you are free to define an object here too. 91 | | 92 | */ 93 | redis: 'self::redis.local' 94 | } 95 | -------------------------------------------------------------------------------- /config/shield.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | /* 5 | |-------------------------------------------------------------------------- 6 | | Content Security Policy 7 | |-------------------------------------------------------------------------- 8 | | 9 | | Content security policy filters out the origins not allowed to execute 10 | | and load resources like scripts, styles and fonts. There are wide 11 | | variety of options to choose from. 12 | */ 13 | csp: { 14 | /* 15 | |-------------------------------------------------------------------------- 16 | | Directives 17 | |-------------------------------------------------------------------------- 18 | | 19 | | All directives are defined in camelCase and here is the list of 20 | | available directives and their possible values. 21 | | 22 | | https://content-security-policy.com 23 | | 24 | | @example 25 | | directives: { 26 | | defaultSrc: ['self', '@nonce', 'cdnjs.cloudflare.com'] 27 | | } 28 | | 29 | */ 30 | directives: { 31 | }, 32 | /* 33 | |-------------------------------------------------------------------------- 34 | | Report only 35 | |-------------------------------------------------------------------------- 36 | | 37 | | Setting `reportOnly=true` will not block the scripts from running and 38 | | instead report them to a URL. 39 | | 40 | */ 41 | reportOnly: false, 42 | /* 43 | |-------------------------------------------------------------------------- 44 | | Set all headers 45 | |-------------------------------------------------------------------------- 46 | | 47 | | Headers staring with `X` have been depreciated, since all major browsers 48 | | supports the standard CSP header. So its better to disable deperciated 49 | | headers, unless you want them to be set. 50 | | 51 | */ 52 | setAllHeaders: false, 53 | 54 | /* 55 | |-------------------------------------------------------------------------- 56 | | Disable on android 57 | |-------------------------------------------------------------------------- 58 | | 59 | | Certain versions of android are buggy with CSP policy. So you can set 60 | | this value to true, to disable it for Android versions with buggy 61 | | behavior. 62 | | 63 | | Here is an issue reported on a different package, but helpful to read 64 | | if you want to know the behavior. https://github.com/helmetjs/helmet/pull/82 65 | | 66 | */ 67 | disableAndroid: true 68 | }, 69 | 70 | /* 71 | |-------------------------------------------------------------------------- 72 | | X-XSS-Protection 73 | |-------------------------------------------------------------------------- 74 | | 75 | | X-XSS Protection saves applications from XSS attacks. It is adopted 76 | | by IE and later followed by some other browsers. 77 | | 78 | | Learn more at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-XSS-Protection 79 | | 80 | */ 81 | xss: { 82 | enabled: true, 83 | enableOnOldIE: false 84 | }, 85 | 86 | /* 87 | |-------------------------------------------------------------------------- 88 | | Iframe Options 89 | |-------------------------------------------------------------------------- 90 | | 91 | | xframe defines whether or not your website can be embedded inside an 92 | | iframe. Choose from one of the following options. 93 | | @available options 94 | | DENY, SAMEORIGIN, ALLOW-FROM http://example.com 95 | | 96 | | Learn more at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options 97 | */ 98 | xframe: 'DENY', 99 | 100 | /* 101 | |-------------------------------------------------------------------------- 102 | | No Sniff 103 | |-------------------------------------------------------------------------- 104 | | 105 | | Browsers have a habit of sniffing content-type of a response. Which means 106 | | files with .txt extension containing Javascript code will be executed as 107 | | Javascript. You can disable this behavior by setting nosniff to false. 108 | | 109 | | Learn more at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options 110 | | 111 | */ 112 | nosniff: true, 113 | 114 | /* 115 | |-------------------------------------------------------------------------- 116 | | No Open 117 | |-------------------------------------------------------------------------- 118 | | 119 | | IE users can execute webpages in the context of your website, which is 120 | | a serious security risk. Below option will manage this for you. 121 | | 122 | */ 123 | noopen: true, 124 | 125 | /* 126 | |-------------------------------------------------------------------------- 127 | | CSRF Protection 128 | |-------------------------------------------------------------------------- 129 | | 130 | | CSRF Protection adds another layer of security by making sure, actionable 131 | | routes does have a valid token to execute an action. 132 | | 133 | */ 134 | csrf: { 135 | enable: true, 136 | methods: ['POST', 'PUT', 'DELETE'], 137 | filterUris: [], 138 | cookieOptions: { 139 | httpOnly: false, 140 | sameSite: true, 141 | path: '/', 142 | maxAge: 7200 143 | } 144 | } 145 | } 146 | -------------------------------------------------------------------------------- /database/factory.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Factory 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Factories are used to define blueprints for database tables or Lucid 9 | | models. Later you can use these blueprints to seed your database 10 | | with dummy data. 11 | | 12 | */ 13 | 14 | // const Factory = use('Factory') 15 | 16 | /** 17 | Factory.blueprint('App/Models/User', (faker) => { 18 | return { 19 | username: faker.username() 20 | } 21 | }) 22 | */ 23 | -------------------------------------------------------------------------------- /database/migrations/1503248427885_user.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Schema = use('Schema') 4 | 5 | class UserSchema extends Schema { 6 | up () { 7 | this.create('users', (table) => { 8 | table.increments() 9 | table.string('username', 80).notNullable().unique() 10 | table.string('email', 254).notNullable().unique() 11 | table.string('password', 60).notNullable() 12 | table.timestamps() 13 | }) 14 | } 15 | 16 | down () { 17 | this.drop('users') 18 | } 19 | } 20 | 21 | module.exports = UserSchema 22 | -------------------------------------------------------------------------------- /database/migrations/1503248427886_token.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Schema = use('Schema') 4 | 5 | class TokensSchema extends Schema { 6 | up () { 7 | this.create('tokens', (table) => { 8 | table.increments() 9 | table.integer('user_id').unsigned().references('id').inTable('users') 10 | table.string('token', 255).notNullable().unique().index() 11 | table.string('type', 80).notNullable() 12 | table.boolean('is_revoked').defaultTo(false) 13 | table.timestamps() 14 | }) 15 | } 16 | 17 | down () { 18 | this.drop('tokens') 19 | } 20 | } 21 | 22 | module.exports = TokensSchema 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "adonisjs-laravel-mix", 3 | "version": "4.1.0", 4 | "adonis-version": "4.1.0", 5 | "description": "An AdonisJs blueprint with 'adonis fullstack application' and 'laravel mix'", 6 | "main": "index.js", 7 | "scripts": { 8 | "start": "node server.js", 9 | "test": "node ace test", 10 | "asset-dev": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js", 11 | "asset-watch": "npm run asset-dev -- --watch", 12 | "asset-watch-poll": "npm run asset-watch -- --watch-poll", 13 | "asset-hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js", 14 | "asset-prod": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js" 15 | }, 16 | "keywords": [ 17 | "adonisjs", 18 | "adonis-app", 19 | "laravel-mix" 20 | ], 21 | "author": "", 22 | "license": "MIT", 23 | "private": true, 24 | "dependencies": { 25 | "@adonisjs/ace": "^5.0.2", 26 | "@adonisjs/auth": "^3.0.5", 27 | "@adonisjs/bodyparser": "^2.0.3", 28 | "@adonisjs/cors": "^1.0.6", 29 | "@adonisjs/fold": "^4.0.8", 30 | "@adonisjs/framework": "^5.0.7", 31 | "@adonisjs/ignitor": "^2.0.6", 32 | "@adonisjs/lucid": "^5.0.4", 33 | "@adonisjs/session": "^1.0.25", 34 | "@adonisjs/shield": "^1.0.6" 35 | }, 36 | "devDependencies": { 37 | "axios": "^0.18", 38 | "bootstrap": "^4.0.0", 39 | "popper.js": "^1.12", 40 | "cross-env": "^5.1", 41 | "jquery": "^3.2", 42 | "laravel-mix": "^2.0", 43 | "lodash": "^4.17.4", 44 | "vue": "^2.5.7" 45 | }, 46 | "autoload": { 47 | "App": "./app" 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /public/css/app.css: -------------------------------------------------------------------------------- 1 | @import url(https://fonts.googleapis.com/css?family=Montserrat:300);html, 2 | body { 3 | height: 100%; 4 | width: 100%; 5 | } 6 | 7 | body { 8 | font-family: 'Montserrat', sans-serif; 9 | font-weight: 300; 10 | background-image: url("/images/splash.png"); 11 | background-color: #220052; 12 | } 13 | 14 | * { 15 | margin: 0; 16 | padding: 0; 17 | } 18 | 19 | section { 20 | height: 100%; 21 | display: -webkit-box; 22 | display: -ms-flexbox; 23 | display: flex; 24 | -webkit-box-orient: vertical; 25 | -webkit-box-direction: normal; 26 | -ms-flex-direction: column; 27 | flex-direction: column; 28 | -webkit-box-pack: center; 29 | -ms-flex-pack: center; 30 | justify-content: center; 31 | -webkit-box-align: center; 32 | -ms-flex-align: center; 33 | align-items: center; 34 | max-width: 536px; 35 | margin: auto; 36 | position: relative; 37 | } 38 | 39 | section:before { 40 | content: ""; 41 | position: absolute; 42 | background: url("/images/pyramid.png") no-repeat; 43 | background-size: 100%; 44 | width: 100%; 45 | height: 402px; 46 | z-index: -1; 47 | } 48 | 49 | .logo { 50 | background: url("/images/logo.svg") no-repeat; 51 | width: 36px; 52 | height: 33px; 53 | background-size: 100%; 54 | margin-bottom: 35px; 55 | opacity: 0; 56 | -webkit-animation: slideUp 1s cubic-bezier(0.19, 1, 0.3, 1) 1.3s forwards; 57 | animation: slideUp 1s cubic-bezier(0.19, 1, 0.3, 1) 1.3s forwards; 58 | } 59 | 60 | .title { 61 | background: url("/images/title.svg") no-repeat; 62 | width: 219px; 63 | height: 36px; 64 | background-size: 100%; 65 | opacity: 0; 66 | -webkit-animation: slideUp 1s cubic-bezier(0.19, 1, 0.3, 1) 0.2s forwards; 67 | animation: slideUp 1s cubic-bezier(0.19, 1, 0.3, 1) 0.2s forwards; 68 | } 69 | 70 | .subtitle { 71 | margin-top: 25px; 72 | color: #BDB3CB; 73 | font-size: 17px; 74 | text-align: center; 75 | letter-spacing: 0.5; 76 | opacity: 0; 77 | -webkit-animation: slideUp 1s cubic-bezier(0.19, 1, 0.3, 1) 0.5s forwards; 78 | animation: slideUp 1s cubic-bezier(0.19, 1, 0.3, 1) 0.5s forwards; 79 | } 80 | 81 | @-webkit-keyframes slideUp { 82 | 0% { 83 | -webkit-transform: translateY(40px); 84 | transform: translateY(40px); 85 | opacity: 0; 86 | } 87 | 88 | 50% { 89 | opacity: 0.2%; 90 | } 91 | 92 | 100% { 93 | opacity: 1; 94 | -webkit-transform: none; 95 | transform: none; 96 | } 97 | } 98 | 99 | @keyframes slideUp { 100 | 0% { 101 | -webkit-transform: translateY(40px); 102 | transform: translateY(40px); 103 | opacity: 0; 104 | } 105 | 106 | 50% { 107 | opacity: 0.2%; 108 | } 109 | 110 | 100% { 111 | opacity: 1; 112 | -webkit-transform: none; 113 | transform: none; 114 | } 115 | } 116 | 117 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcio4ugusto/adonisjs-laravel-mix/20dfb0b3b779488a7218116190e8e06b26965c25/public/favicon.ico -------------------------------------------------------------------------------- /public/images/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /public/images/pyramid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcio4ugusto/adonisjs-laravel-mix/20dfb0b3b779488a7218116190e8e06b26965c25/public/images/pyramid.png -------------------------------------------------------------------------------- /public/images/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcio4ugusto/adonisjs-laravel-mix/20dfb0b3b779488a7218116190e8e06b26965c25/public/images/splash.png -------------------------------------------------------------------------------- /public/images/title.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /public/mix-manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "/js/app.js": "/js/app.js", 3 | "/css/app.css": "/css/app.css" 4 | } -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | User-agent: * 2 | Disallow: 3 | -------------------------------------------------------------------------------- /resources/assets/images/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /resources/assets/images/pyramid.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcio4ugusto/adonisjs-laravel-mix/20dfb0b3b779488a7218116190e8e06b26965c25/resources/assets/images/pyramid.png -------------------------------------------------------------------------------- /resources/assets/images/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/marcio4ugusto/adonisjs-laravel-mix/20dfb0b3b779488a7218116190e8e06b26965c25/resources/assets/images/splash.png -------------------------------------------------------------------------------- /resources/assets/images/title.svg: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /resources/assets/js/app.js: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * First we will load all of this project's JavaScript dependencies which 4 | * includes Vue and other libraries. It is a great starting point when 5 | * building robust, powerful web applications using Vue and Adonis. 6 | */ 7 | 8 | require('./bootstrap'); 9 | 10 | window.Vue = require('vue'); 11 | 12 | /** 13 | * Next, we will create a fresh Vue application instance and attach it to 14 | * the page. Then, you may begin adding components to this application 15 | * or customize the JavaScript scaffolding to fit your unique needs. 16 | */ 17 | 18 | Vue.component('sentence-component', require('./components/Sentence.vue')); 19 | 20 | const app = new Vue({ 21 | el: '#app' 22 | }); 23 | -------------------------------------------------------------------------------- /resources/assets/js/bootstrap.js: -------------------------------------------------------------------------------- 1 | 2 | window._ = require('lodash'); 3 | window.Popper = require('popper.js').default; 4 | 5 | /** 6 | * We'll load jQuery and the Bootstrap jQuery plugin which provides support 7 | * for JavaScript based Bootstrap features such as modals and tabs. This 8 | * code may be modified to fit the specific needs of your application. 9 | */ 10 | 11 | try { 12 | window.$ = window.jQuery = require('jquery'); 13 | 14 | require('bootstrap'); 15 | } catch (e) {} 16 | 17 | /** 18 | * We'll load the axios HTTP library which allows us to easily issue requests 19 | * to our Adonis back-end. This library automatically handles sending the 20 | * CSRF token as a header based on the value of the "XSRF" token cookie. 21 | */ 22 | 23 | window.axios = require('axios'); 24 | 25 | window.axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest'; 26 | 27 | /** 28 | * Next we will register the CSRF Token as a common header with Axios so that 29 | * all outgoing HTTP requests automatically have it attached. This is just 30 | * a simple convenience so we don't have to attach every token manually. 31 | */ 32 | 33 | let token = document.head.querySelector('meta[name="csrf-token"]'); 34 | 35 | if (token) { 36 | window.axios.defaults.headers.common['X-CSRF-TOKEN'] = token.content; 37 | } else { 38 | console.error('CSRF token not found: http://adonisjs.com/docs/4.1/csrf'); 39 | } 40 | -------------------------------------------------------------------------------- /resources/assets/js/components/Sentence.vue: -------------------------------------------------------------------------------- 1 | 4 | 5 | 15 | -------------------------------------------------------------------------------- /resources/assets/sass/app.scss: -------------------------------------------------------------------------------- 1 | @import url('https://fonts.googleapis.com/css?family=Montserrat:300'); 2 | 3 | html, body { 4 | height: 100%; 5 | width: 100%; 6 | } 7 | 8 | body { 9 | font-family: 'Montserrat', sans-serif; 10 | font-weight: 300; 11 | background-image: url("/images/splash.png"); 12 | background-color: #220052; 13 | } 14 | 15 | * { 16 | margin: 0; 17 | padding: 0; 18 | } 19 | 20 | section { 21 | height: 100%; 22 | display: flex; 23 | flex-direction: column; 24 | justify-content: center; 25 | align-items: center; 26 | max-width: 536px; 27 | margin: auto; 28 | position: relative; 29 | } 30 | 31 | section:before { 32 | content: ""; 33 | position: absolute; 34 | background: url("/images/pyramid.png") no-repeat; 35 | background-size: 100%; 36 | width: 100%; 37 | height: 402px; 38 | z-index: -1; 39 | } 40 | 41 | .logo { 42 | background: url("/images/logo.svg") no-repeat; 43 | width: 36px; 44 | height: 33px; 45 | background-size: 100%; 46 | margin-bottom: 35px; 47 | opacity: 0; 48 | animation: slideUp 1s cubic-bezier(0.19, 1, 0.30, 1) 1.3s forwards; 49 | } 50 | 51 | .title { 52 | background: url("/images/title.svg") no-repeat; 53 | width: 219px; 54 | height: 36px; 55 | background-size: 100%; 56 | opacity: 0; 57 | animation: slideUp 1s cubic-bezier(0.19, 1, 0.30, 1) 0.2s forwards; 58 | } 59 | 60 | .subtitle { 61 | margin-top: 25px; 62 | color: #BDB3CB; 63 | font-size: 17px; 64 | text-align: center; 65 | letter-spacing: 0.5; 66 | opacity: 0; 67 | animation: slideUp 1s cubic-bezier(0.19, 1, 0.30, 1) 0.5s forwards; 68 | } 69 | 70 | @keyframes slideUp { 71 | 0% { 72 | transform: translateY(40px); 73 | opacity: 0; 74 | } 75 | 50% { 76 | opacity: 0.2%; 77 | } 78 | 100% { 79 | opacity: 1; 80 | transform: none; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /resources/views/welcome.edge: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Hello Adonis 7 | 8 | 9 | 10 |
11 | 12 |
13 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Http server 6 | |-------------------------------------------------------------------------- 7 | | 8 | | This file bootstrap Adonisjs to start the HTTP server. You are free to 9 | | customize the process of booting the http server. 10 | | 11 | | """ Loading ace commands """ 12 | | At times you may want to load ace commands when starting the HTTP server. 13 | | Same can be done by chaining `loadCommands()` method after 14 | | 15 | | """ Preloading files """ 16 | | Also you can preload files by calling `preLoad('path/to/file')` method. 17 | | Make sure to pass relative path from the project root. 18 | */ 19 | 20 | const { Ignitor } = require('@adonisjs/ignitor') 21 | 22 | new Ignitor(require('@adonisjs/fold')) 23 | .appRoot(__dirname) 24 | .fireHttpServer() 25 | .catch(console.error) 26 | -------------------------------------------------------------------------------- /start/app.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Providers 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Providers are building blocks for your Adonis app. Anytime you install 9 | | a new Adonis specific package, chances are you will register the 10 | | provider here. 11 | | 12 | */ 13 | const providers = [ 14 | '@adonisjs/framework/providers/AppProvider', 15 | '@adonisjs/framework/providers/ViewProvider', 16 | '@adonisjs/lucid/providers/LucidProvider', 17 | '@adonisjs/bodyparser/providers/BodyParserProvider', 18 | '@adonisjs/cors/providers/CorsProvider', 19 | '@adonisjs/shield/providers/ShieldProvider', 20 | '@adonisjs/session/providers/SessionProvider', 21 | '@adonisjs/auth/providers/AuthProvider' 22 | ] 23 | 24 | /* 25 | |-------------------------------------------------------------------------- 26 | | Ace Providers 27 | |-------------------------------------------------------------------------- 28 | | 29 | | Ace providers are required only when running ace commands. For example 30 | | Providers for migrations, tests etc. 31 | | 32 | */ 33 | const aceProviders = [ 34 | '@adonisjs/lucid/providers/MigrationsProvider' 35 | ] 36 | 37 | /* 38 | |-------------------------------------------------------------------------- 39 | | Aliases 40 | |-------------------------------------------------------------------------- 41 | | 42 | | Aliases are short unique names for IoC container bindings. You are free 43 | | to create your own aliases. 44 | | 45 | | For example: 46 | | { Route: 'Adonis/Src/Route' } 47 | | 48 | */ 49 | const aliases = {} 50 | 51 | /* 52 | |-------------------------------------------------------------------------- 53 | | Commands 54 | |-------------------------------------------------------------------------- 55 | | 56 | | Here you store ace commands for your package 57 | | 58 | */ 59 | const commands = [] 60 | 61 | module.exports = { providers, aceProviders, aliases, commands } 62 | -------------------------------------------------------------------------------- /start/hooks.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const {hooks} = require('@adonisjs/ignitor') 4 | const path = require('path') 5 | 6 | /* 7 | |-------------------------------------------------------------------------- 8 | | Laravel mix hook 9 | |-------------------------------------------------------------------------- 10 | | 11 | | This hook adds the `mix()` - versioning function of laravel to adonis views. 12 | | See more about Adonis views hooks at: 13 | | https://adonisjs.com/docs/4.1/views#_extending_views 14 | | See more about Laravel mix at: 15 | | https://laravel.com/docs/5.6/mix 16 | | 17 | */ 18 | 19 | hooks.after.providersBooted(() => { 20 | const View = use('Adonis/Src/View') 21 | const Helpers = use('Helpers') 22 | 23 | View.global('mix', text => { 24 | if (!text) return 25 | const manifest = require(path.join(Helpers.publicPath(), 'mix-manifest.json')) 26 | return manifest[text] 27 | }) 28 | }) 29 | -------------------------------------------------------------------------------- /start/kernel.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Server = use('Server') 4 | 5 | /* 6 | |-------------------------------------------------------------------------- 7 | | Global Middleware 8 | |-------------------------------------------------------------------------- 9 | | 10 | | Global middleware are executed on each http request only when the routes 11 | | match. 12 | | 13 | */ 14 | const globalMiddleware = [ 15 | 'Adonis/Middleware/BodyParser', 16 | 'Adonis/Middleware/Session', 17 | 'Adonis/Middleware/Shield', 18 | 'Adonis/Middleware/AuthInit' 19 | ] 20 | 21 | /* 22 | |-------------------------------------------------------------------------- 23 | | Named Middleware 24 | |-------------------------------------------------------------------------- 25 | | 26 | | Named middleware is key/value object to conditionally add middleware on 27 | | specific routes or group of routes. 28 | | 29 | | // define 30 | | { 31 | | auth: 'Adonis/Middleware/Auth' 32 | | } 33 | | 34 | | // use 35 | | Route.get().middleware('auth') 36 | | 37 | */ 38 | const namedMiddleware = { 39 | auth: 'Adonis/Middleware/Auth' 40 | } 41 | 42 | /* 43 | |-------------------------------------------------------------------------- 44 | | Server Middleware 45 | |-------------------------------------------------------------------------- 46 | | 47 | | Server level middleware are executed even when route for a given URL is 48 | | not registered. Features like `static assets` and `cors` needs better 49 | | control over request lifecycle. 50 | | 51 | */ 52 | const serverMiddleware = [ 53 | 'Adonis/Middleware/Static', 54 | 'Adonis/Middleware/Cors' 55 | ] 56 | 57 | Server 58 | .registerGlobal(globalMiddleware) 59 | .registerNamed(namedMiddleware) 60 | .use(serverMiddleware) 61 | -------------------------------------------------------------------------------- /start/routes.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Routes 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Http routes are entry points to your web application. You can create 9 | | routes for different URL's and bind Controller actions to them. 10 | | 11 | | A complete guide on routing is available here. 12 | | http://adonisjs.com/docs/4.0/routing 13 | | 14 | */ 15 | 16 | const Route = use('Route') 17 | 18 | Route.on('/').render('welcome') 19 | -------------------------------------------------------------------------------- /webpack.mix.js: -------------------------------------------------------------------------------- 1 | let mix = require('laravel-mix'); 2 | 3 | mix.setPublicPath('public'); 4 | 5 | /* 6 | |-------------------------------------------------------------------------- 7 | | Mix Asset Management 8 | |-------------------------------------------------------------------------- 9 | | 10 | | Mix provides a clean, fluent API for defining some Webpack build steps 11 | | for your Adonis application. By default, we are compiling the Sass 12 | | file for the application as well as bundling up all the JS files. 13 | | 14 | */ 15 | 16 | mix.js('resources/assets/js/app.js', 'public/js') 17 | .sass('resources/assets/sass/app.scss', 'public/css') 18 | .copyDirectory('resources/assets/images', 'public/images'); 19 | 20 | // mix.version(); 21 | 22 | 23 | // Full API 24 | // mix.js(src, output); 25 | // mix.react(src, output); <-- Identical to mix.js(), but registers React Babel compilation. 26 | // mix.ts(src, output); <-- Requires tsconfig.json to exist in the same folder as webpack.mix.js 27 | // mix.extract(vendorLibs); 28 | // mix.sass(src, output); 29 | // mix.standaloneSass('src', output); <-- Faster, but isolated from Webpack. 30 | // mix.fastSass('src', output); <-- Alias for mix.standaloneSass(). 31 | // mix.less(src, output); 32 | // mix.stylus(src, output); 33 | // mix.postCss(src, output, [require('postcss-some-plugin')()]); 34 | // mix.browserSync('my-site.dev'); 35 | // mix.combine(files, destination); 36 | // mix.babel(files, destination); <-- Identical to mix.combine(), but also includes Babel compilation. 37 | // mix.copy(from, to); 38 | // mix.copyDirectory(fromDir, toDir); 39 | // mix.minify(file); 40 | // mix.sourceMaps(); // Enable sourcemaps 41 | // mix.version(); // Enable versioning. 42 | // mix.disableNotifications(); 43 | // mix.setPublicPath('path/to/public'); 44 | // mix.setResourceRoot('prefix/for/resource/locators'); 45 | // mix.autoload({}); <-- Will be passed to Webpack's ProvidePlugin. 46 | // mix.webpackConfig({}); <-- Override webpack.config.js, without editing the file directly. 47 | // mix.then(function () {}) <-- Will be triggered each time Webpack finishes building. 48 | // mix.options({ 49 | // extractVueStyles: false, // Extract .vue component styling to file, rather than inline. 50 | // globalVueStyles: file, // Variables file to be imported in every component. 51 | // processCssUrls: true, // Process/optimize relative stylesheet url()'s. Set to false, if you don't want them touched. 52 | // purifyCss: false, // Remove unused CSS selectors. 53 | // uglify: {}, // Uglify-specific options. https://webpack.github.io/docs/list-of-plugins.html#uglifyjsplugin 54 | // postCss: [] // Post-CSS options: https://github.com/postcss/postcss/blob/master/docs/plugins.md 55 | // }); 56 | --------------------------------------------------------------------------------