├── .gitignore ├── README.md ├── meta.js └── template ├── .babelrc ├── .editorconfig ├── .env.example ├── .eslintignore ├── .eslintrc.js ├── .gitignore ├── README.md ├── ace ├── app ├── Commands │ └── Greet.js ├── Http │ ├── Controllers │ │ └── WebAppController.js │ ├── Middleware │ │ └── .gitkeep │ ├── kernel.js │ └── routes.js ├── Listeners │ └── Http.js └── Model │ └── Hooks │ └── .gitkeep ├── bootstrap ├── app.js ├── events.js ├── extend.js ├── http.js └── kernel.js ├── config ├── app.js ├── auth.js ├── bodyParser.js ├── cors.js ├── database.js ├── event.js ├── session.js ├── shield.js ├── vue.js └── webpack │ ├── base.config.js │ ├── client.config.js │ ├── server.config.js │ └── vue-loader.config.js ├── database ├── factory.js ├── migrations │ └── .gitkeep └── seeds │ └── Database.js ├── package.json ├── providers └── .gitkeep ├── public └── .gitkeep ├── resources ├── src │ ├── App.vue │ ├── app.js │ ├── assets │ │ └── img │ │ │ └── logo.png │ ├── client-entry.js │ ├── components │ │ └── Hello.vue │ ├── router │ │ ├── .gitkeep │ │ └── index.js │ ├── server-entry.js │ ├── store │ │ ├── .gitkeep │ │ └── index.js │ └── views │ │ ├── .gitkeep │ │ └── Home.vue └── views │ ├── app.njk │ └── errors │ ├── index.njk │ └── vue.njk ├── server.js └── storage └── .gitkeep /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | template/yarn.lock 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | # Adonis-Vue 4 | 5 | > AdonisJS + Vue.js = :fire: 6 | 7 | ## Features 8 | 9 | 1. Vue.js 2.0 with server-side rendering (+ cacheable components) 10 | 2. Hot reloading (via webpack) 11 | 3. Configurable via config/vue.js 12 | 4. vuex and vue-router are installed and ready to use (synced with vue-router-sync) 13 | 5. All the awesome features of AdonisJS 14 | 15 | :warning: **I now recommend to use [adonuxt](https://github.com/nuxt/adonuxt), it has all these features + code splitting, custom layouts, middlewares and it's easier to start with.** 16 | 17 | ## Installation 18 | 19 | This is a project template for [vue-cli](https://github.com/vuejs/vue-cli). 20 | 21 | ```bash 22 | vue init atinux/vue-adonis 23 | cd # move to your project 24 | mv .env.example .env # Add environment variables for Adonis 25 | npm install # or yarn install 26 | ``` 27 | 28 | ## Usage 29 | 30 | ### Development 31 | 32 | ```bash 33 | npm run dev 34 | ``` 35 | 36 | Go to [http://localhost:8080](http://localhost:8080) 37 | 38 | ### Production 39 | 40 | Set the env variables in your provider and add `ENV_SILENT=true` so Adonis will not try to load the .env file (see [docs](http://adonisjs.com/docs/3.1/env)). 41 | ``` 42 | npm start 43 | ``` 44 | 45 | ### Heroku 46 | 47 | Add `NPM_CONFIG_PRODUCTION=false` in your env variables so it will install the dev dependencies to build the sources (see [Heroku docs](https://devcenter.heroku.com/articles/nodejs-support#devdependencies)). 48 | 49 | ## Including Bootstrap 50 | 51 | You can use external libraries like bootstrap, please see [Issue #1](https://github.com/Atinux/vue-adonis/issues/1#issuecomment-255539896) 52 | 53 | ## Documentation 54 | 55 | - [AdonisJS](http://adonisjs.com/docs/) 56 | - [Vue.js](http://vuejs.org/guide/) 57 | 58 | To understand the `preFetch` method in the matched route components (`resources/src/server-entry.js`), I recommend to look at https://github.com/vuejs/vue-hackernews-2.0 59 | 60 | I recommend to use [axios](https://github.com/mzabriskie/axios) for making HTTP request for both client-side and server-side. 61 | 62 | Thanks to [Evan You](https://twitter.com/youyuxi), [Aman Virk](https://twitter.com/AmanVirk1) and their awesome communities for creating and maintaining Vue.js and AdonisJS :clap: 63 | 64 | ## Tests 65 | 66 | There is no tests in this template because it's hard to know exactly which tests you will use and even how you want to structure them in this isomorphic application. 67 | 68 | Here some ideas: 69 | 70 | - [adonis-rally](https://github.com/adonisjs/adonis-rally) project, it has a bunch of tests made by the creator of adonis-framework 71 | - [vue webpack template](https://github.com/vuejs-templates/webpack/tree/master/template) might help you to see how to structure end-to-end and unit test for you web-app 72 | 73 | ## Licenses 74 | 75 | - [AdonisJS license](https://github.com/adonisjs/adonis-framework/blob/develop/LICENSE.txt) 76 | - [VueJS license](https://github.com/vuejs/vue/blob/master/LICENSE) 77 | -------------------------------------------------------------------------------- /meta.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | helpers: { 3 | raw: function(options) { 4 | return options.fn(this) 5 | } 6 | }, 7 | prompts: { 8 | name: { 9 | 'type': 'string', 10 | 'required': true, 11 | 'message': 'Project name' 12 | }, 13 | description: { 14 | 'type': 'string', 15 | 'required': false, 16 | 'message': 'Project description', 17 | 'default': 'An Adonis and Vue.js project' 18 | }, 19 | author: { 20 | 'type': 'string', 21 | 'message': 'Author' 22 | }, 23 | }, 24 | completeMessage: '{{#inPlace}}To get started:\n\n mv .env.example .env\n npm install # Or yarn install\n npm run dev{{else}}To get started:\n\n cd {{destDirName}}\n mv .env.example .env\n npm install # Or yarn install\n npm run dev{{/inPlace}}' 25 | }; 26 | -------------------------------------------------------------------------------- /template/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": [ 3 | ["es2015", { "modules": false }], 4 | "stage-2" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /template/.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 | -------------------------------------------------------------------------------- /template/.env.example: -------------------------------------------------------------------------------- 1 | VUE_ENV=server 2 | HOST=localhost 3 | PORT=8080 4 | APP_KEY=mxnesMA%R&Xi3mt$rL94LE0QAKZTl$vQ 5 | NODE_ENV=development 6 | CACHE_VIEWS=false 7 | SESSION_DRIVER=cookie 8 | -------------------------------------------------------------------------------- /template/.eslintignore: -------------------------------------------------------------------------------- 1 | public/dist 2 | !.atom-build.js 3 | !.eslintrc.js 4 | -------------------------------------------------------------------------------- /template/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parser: 'babel-eslint', 4 | parserOptions: { 5 | sourceType: 'module' 6 | }, 7 | env: { 8 | browser: true, 9 | node: true, 10 | mocha: true 11 | }, 12 | extends: 'standard', 13 | // required to lint *.vue files 14 | plugins: [ 15 | 'html' 16 | ], 17 | // add your custom rules here 18 | rules: { 19 | // allow paren-less arrow functions 20 | 'arrow-parens': 0, 21 | // allow async-await 22 | 'generator-star-spacing': 0, 23 | // allow debugger during development 24 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0 25 | }, 26 | globals: { 27 | 'make': true, 28 | 'use': true 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /template/.gitignore: -------------------------------------------------------------------------------- 1 | # Node modules 2 | node_modules 3 | 4 | # Ignoring everything inside storage directory 5 | storage/* 6 | 7 | # Keeping storage directory 8 | !storage/.gitkeep 9 | 10 | # Environment files should be seperate for each environment 11 | .env 12 | 13 | # When npm runs error it write logs to the below file 14 | npm-debug.log 15 | 16 | # Coverage directory used by tools like istanbul 17 | coverage 18 | 19 | # Created by nightwatch 20 | reports 21 | 22 | # Directory for instrumented libs generated by jscoverage/JSCover 23 | lib-cov 24 | 25 | # Mac Only 26 | .DS_Store 27 | 28 | # Vue 29 | dist/ 30 | -------------------------------------------------------------------------------- /template/README.md: -------------------------------------------------------------------------------- 1 | # {{ name }} 2 | 3 | > {{ description }} 4 | 5 | ## Build Setup 6 | 7 | ``` bash 8 | # install dependencies 9 | npm install # Or yarn install 10 | 11 | # serve with hot reload at localhost:8080 12 | npm run dev 13 | 14 | # build for production and launch server 15 | # set env to NODE_ENV=production 16 | npm run start 17 | ``` 18 | 19 | For detailed explanation on how things work, checkout the [AdonisJS docs](http://adonisjs.com/docs/) and [Vue guide](http://vuejs.org/guide/). 20 | -------------------------------------------------------------------------------- /template/ace: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 'use strict' 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Running Console Commands 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Here we invoke console commands registered under Ace store. 9 | | 10 | */ 11 | const kernel = require('./bootstrap/kernel') 12 | kernel() 13 | -------------------------------------------------------------------------------- /template/app/Commands/Greet.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Command = use('Command') 4 | 5 | class Greet extends Command { 6 | 7 | /** 8 | * signature defines the requirements and name 9 | * of command. 10 | * 11 | * @return {String} 12 | */ 13 | get signature () { 14 | return 'greet {name}' 15 | } 16 | 17 | /** 18 | * description is the little helpful information displayed 19 | * on the console. 20 | * 21 | * @return {String} 22 | */ 23 | get description () { 24 | return 'Greet a user with a name' 25 | } 26 | 27 | /** 28 | * handle method is invoked automatically by ace, once your 29 | * command has been executed. 30 | * 31 | * @param {Object} args [description] 32 | * @param {Object} options [description] 33 | */ 34 | * handle (args, options) { 35 | this.info(`Hello ${args.name}`) 36 | } 37 | 38 | } 39 | 40 | module.exports = Greet 41 | -------------------------------------------------------------------------------- /template/app/Http/Controllers/WebAppController.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Env = use('Env') 4 | const Config = use('Config') 5 | const Helpers = use('Helpers') 6 | const fs = require('fs') 7 | const path = require('path') 8 | const serialize = require('serialize-javascript') 9 | const promisify = require('es6-promisify') 10 | const createBundleRenderer = require('vue-server-renderer').createBundleRenderer 11 | const ansiHTML = require('ansi-html') 12 | const vueConfig = Config.get('vue') 13 | const encodeHtml = (str) => str.replace(//g, '>') 14 | 15 | class AppController { 16 | 17 | constructor () { 18 | this.renderer = null 19 | this.isProd = Env.get('NODE_ENV') === 'production' 20 | this.isDev = Env.get('NODE_ENV') === 'development' 21 | if (this.isProd) { 22 | const bundlePath = path.resolve(Helpers.publicPath(), vueConfig.outputDir, vueConfig.filenames.server) 23 | this._createRenderer(fs.readFileSync(bundlePath, 'utf-8')) 24 | } 25 | if (this.isDev) { 26 | this._createWebpackMiddlewares() 27 | this._webpackWatchAndUpdate() 28 | } 29 | } 30 | 31 | getContext (request) { 32 | // Context given to resources/src/server-entry.js 33 | // You can for example get the authenticated user apiKey here and give it 34 | // to the vue.js app so all the API calls will be authenticated 35 | return { 36 | url: request.url() 37 | } 38 | } 39 | 40 | * render (request, response) { 41 | if (!this.renderer) { 42 | yield this._waitFor(1000) 43 | yield this.render(request, response) 44 | return 45 | } 46 | // Call webpack middlewares only in development 47 | if (this.isDev) { 48 | yield this._webpackMiddlewares(request, response) 49 | } 50 | 51 | const context = this.getContext(request) 52 | try { 53 | const html = yield this.renderToString(context) 54 | yield response.sendView('app', { 55 | isProd: this.isProd, // Use to add the extracted CSS in production 56 | APP: html, 57 | context: context, 58 | serialize: serialize, 59 | files: { 60 | css: path.join('/', vueConfig.outputDir, vueConfig.filenames.css), 61 | clientVendor: path.join('/', vueConfig.outputDir, vueConfig.filenames.clientVendor), 62 | client: path.join('/', vueConfig.outputDir, vueConfig.filenames.client) 63 | } 64 | }) 65 | } catch (err) { 66 | // throw err 67 | yield response.status(500).sendView('errors/vue', { err, ansiHTML, encodeHtml }) 68 | } 69 | } 70 | 71 | _createRenderer (bundle) { 72 | // Create bundle renderer to give a fresh context for every request 73 | let cacheConfig = false 74 | if (this.isProd && Config.get('vue.cache')) { 75 | cacheConfig = require('lru-cache')({ 76 | max: Config.get('vue.cacheOptions.max', 1000), 77 | maxAge: Config.get('vue.cacheOptions.max', 1000 * 60 * 15) 78 | }) 79 | } 80 | this.renderer = createBundleRenderer(bundle, { 81 | cache: cacheConfig 82 | }) 83 | this.renderToString = promisify(this.renderer.renderToString) 84 | } 85 | 86 | _webpackWatchAndUpdate () { 87 | // Watch and update server renderer 88 | const webpack = require('webpack') 89 | const MFS = require('memory-fs') // <- dependencies of webpack 90 | const mfs = new MFS() 91 | const serverConfig = require(path.resolve(Helpers.configPath(), vueConfig.webpack.serverConfig)) 92 | const serverCompiler = webpack(serverConfig) 93 | const outputPath = path.join(serverConfig.output.path, serverConfig.output.filename) 94 | serverCompiler.outputFileSystem = mfs 95 | serverCompiler.watch({}, (err, stats) => { 96 | if (err) throw err 97 | stats = stats.toJson() 98 | stats.errors.forEach(err => console.error(err)) 99 | stats.warnings.forEach(err => console.warn(err)) 100 | this._createRenderer(mfs.readFileSync(outputPath, 'utf-8')) 101 | }) 102 | } 103 | 104 | _createWebpackMiddlewares () { 105 | const webpack = require('webpack') 106 | const clientConfig = require(path.resolve(Helpers.configPath(), vueConfig.webpack.clientConfig)) 107 | 108 | // setup on the fly compilation + hot-reload 109 | clientConfig.entry.app = ['webpack-hot-middleware/client', clientConfig.entry.app] 110 | clientConfig.plugins.push( 111 | new webpack.HotModuleReplacementPlugin(), 112 | new webpack.NoErrorsPlugin() 113 | ) 114 | 115 | const clientCompiler = webpack(clientConfig) 116 | // Add the middlewares to the instance context 117 | this.webpackDevMiddleware = promisify(require('webpack-dev-middleware')(clientCompiler, { 118 | publicPath: clientConfig.output.publicPath, 119 | stats: { 120 | colors: true, 121 | chunks: false 122 | } 123 | })) 124 | this.webpackHotMiddleware = promisify(require('webpack-hot-middleware')(clientCompiler)) 125 | } 126 | 127 | * _webpackMiddlewares (request, response) { 128 | yield this.webpackDevMiddleware(request.request, response.response) 129 | yield this.webpackHotMiddleware(request.request, response.response) 130 | } 131 | 132 | * _waitFor (ms) { 133 | return new Promise(function (resolve) { 134 | setTimeout(resolve, (ms || 0)) 135 | }) 136 | } 137 | 138 | } 139 | 140 | // Config for ansi-html 141 | ansiHTML.setColors({ 142 | reset: ['efefef', 'a6004c'], 143 | darkgrey: '5a012b', 144 | yellow: 'ffab07', 145 | green: 'aeefba', 146 | magenta: 'ff84bf', 147 | blue: '3505a0', 148 | cyan: '56eaec', 149 | red: '4e053a' 150 | }) 151 | 152 | // Exports the instance so the constructor is called only once 153 | module.exports = new AppController() 154 | -------------------------------------------------------------------------------- /template/app/Http/Middleware/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atinux/vue-adonis/39e3794cea3668ee6a6fa97634a8d899bec8b80a/template/app/Http/Middleware/.gitkeep -------------------------------------------------------------------------------- /template/app/Http/kernel.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Middleware = use('Middleware') 4 | 5 | /* 6 | |-------------------------------------------------------------------------- 7 | | Global Middleware 8 | |-------------------------------------------------------------------------- 9 | | 10 | | Global middleware are executed on every request and must be defined 11 | | inside below array. 12 | | 13 | */ 14 | const globalMiddleware = [ 15 | 'Adonis/Middleware/Cors', 16 | 'Adonis/Middleware/BodyParser', 17 | 'Adonis/Middleware/Shield', 18 | 'Adonis/Middleware/Flash', 19 | 'Adonis/Middleware/AuthInit' 20 | ] 21 | 22 | /* 23 | |-------------------------------------------------------------------------- 24 | | Named Middleware 25 | |-------------------------------------------------------------------------- 26 | | 27 | | Named middleware are key/value pairs. Keys are later used on routes 28 | | which binds middleware to specific routes. 29 | | 30 | */ 31 | const namedMiddleware = { 32 | auth: 'Adonis/Middleware/Auth' 33 | } 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Register Middleware 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Here we finally register our defined middleware to Middleware provider. 41 | | 42 | */ 43 | Middleware.global(globalMiddleware) 44 | Middleware.named(namedMiddleware) 45 | -------------------------------------------------------------------------------- /template/app/Http/routes.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Router 6 | |-------------------------------------------------------------------------- 7 | | 8 | | AdonisJs Router helps you in defining urls and their actions. It supports 9 | | all major HTTP conventions to keep your routes file descriptive and 10 | | clean. 11 | | 12 | | @example 13 | | Route.get('/user', 'UserController.index') 14 | | Route.post('/user', 'UserController.store') 15 | | Route.resource('user', 'UserController') 16 | */ 17 | 18 | const Route = use('Route') 19 | 20 | Route.any('*', 'WebAppController.render') 21 | -------------------------------------------------------------------------------- /template/app/Listeners/Http.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Env = use('Env') 4 | const Http = exports = module.exports = {} 5 | 6 | /** 7 | * handle errors occured during a Http request. 8 | * 9 | * @param {Object} error 10 | * @param {Object} request 11 | * @param {Object} response 12 | */ 13 | Http.handleError = function * (error, request, response) { 14 | /** 15 | * DEVELOPMENT REPORTER 16 | */ 17 | if (Env.get('NODE_ENV') === 'development') { 18 | const Ouch = use('youch') 19 | const ouch = new Ouch().pushHandler( 20 | new Ouch.handlers.PrettyPageHandler('blue', null, 'sublime') 21 | ) 22 | ouch.handleException(error, request.request, response.response, (output) => { 23 | console.error(error.stack) 24 | }) 25 | return 26 | } 27 | 28 | /** 29 | * PRODUCTION REPORTER 30 | */ 31 | const status = error.status || 500 32 | console.error(error.stack) 33 | yield response.status(status).sendView('errors/index', {error}) 34 | } 35 | 36 | /** 37 | * listener for Http.start event, emitted after 38 | * starting http server. 39 | */ 40 | Http.onStart = function () { 41 | } 42 | -------------------------------------------------------------------------------- /template/app/Model/Hooks/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atinux/vue-adonis/39e3794cea3668ee6a6fa97634a8d899bec8b80a/template/app/Model/Hooks/.gitkeep -------------------------------------------------------------------------------- /template/bootstrap/app.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Application Providers 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Here we configure the providers required to run adonis application. They 9 | | are registered only once and can be used inside any file using `use` 10 | | keyword. 11 | | 12 | */ 13 | const providers = [ 14 | 'adonis-framework/providers/ConfigProvider', 15 | 'adonis-framework/providers/EnvProvider', 16 | 'adonis-framework/providers/EventProvider', 17 | 'adonis-framework/providers/HelpersProvider', 18 | 'adonis-framework/providers/HashProvider', 19 | 'adonis-framework/providers/MiddlewareProvider', 20 | 'adonis-framework/providers/RequestProvider', 21 | 'adonis-framework/providers/ResponseProvider', 22 | 'adonis-framework/providers/RouteProvider', 23 | 'adonis-framework/providers/ServerProvider', 24 | 'adonis-framework/providers/SessionProvider', 25 | 'adonis-framework/providers/StaticProvider', 26 | 'adonis-framework/providers/ViewProvider', 27 | 'adonis-lucid/providers/DatabaseProvider', 28 | 'adonis-lucid/providers/LucidProvider', 29 | 'adonis-lucid/providers/FactoryProvider', 30 | 'adonis-middleware/providers/AppMiddlewareProvider', 31 | 'adonis-auth/providers/AuthManagerProvider' 32 | ] 33 | 34 | /* 35 | |-------------------------------------------------------------------------- 36 | | Ace Providers 37 | |-------------------------------------------------------------------------- 38 | | 39 | | Ace providers are specific to ace, and are not registered when starting 40 | | http server. It helps in reducing boot time. 41 | | 42 | */ 43 | const aceProviders = [ 44 | 'adonis-lucid/providers/CommandsProvider', 45 | 'adonis-lucid/providers/MigrationsProvider', 46 | 'adonis-lucid/providers/SchemaProvider', 47 | 'adonis-lucid/providers/SeederProvider', 48 | 'adonis-ace/providers/CommandProvider', 49 | 'adonis-commands/providers/GeneratorsProvider', 50 | 'adonis-commands/providers/HelperCommandsProvider', 51 | 'adonis-commands/providers/ReplProvider' 52 | ] 53 | 54 | /* 55 | |-------------------------------------------------------------------------- 56 | | Namespace Aliases 57 | |-------------------------------------------------------------------------- 58 | | 59 | | Each provider is registered with a long unique namespace. Here we alias 60 | | them with a short unique name to keep our import statements short and 61 | | sweet. 62 | | 63 | */ 64 | const aliases = { 65 | Command: 'Adonis/Src/Command', 66 | Config: 'Adonis/Src/Config', 67 | Database: 'Adonis/Src/Database', 68 | Env: 'Adonis/Src/Env', 69 | Event: 'Adonis/Src/Event', 70 | Factory: 'Adonis/Src/Factory', 71 | Hash: 'Adonis/Src/Hash', 72 | Helpers: 'Adonis/Src/Helpers', 73 | Lucid: 'Adonis/Src/Lucid', 74 | Middleware: 'Adonis/Src/Middleware', 75 | Route: 'Adonis/Src/Route', 76 | Schema: 'Adonis/Src/Schema', 77 | View: 'Adonis/Src/View' 78 | } 79 | 80 | /* 81 | |-------------------------------------------------------------------------- 82 | | Ace Commands 83 | |-------------------------------------------------------------------------- 84 | | 85 | | Ace Commands are also are registered inside the IoC container. Here we 86 | | register with Ace Kernel using their unique namespace. 87 | | 88 | */ 89 | const commands = [ 90 | 'App/Commands/Greet', 91 | 'Adonis/Commands/Auth:Setup', 92 | 'Adonis/Commands/Repl', 93 | 'Adonis/Commands/Make:Controller', 94 | 'Adonis/Commands/Route:List', 95 | 'Adonis/Commands/Make:Migration', 96 | 'Adonis/Commands/Make:Model', 97 | 'Adonis/Commands/Make:View', 98 | 'Adonis/Commands/Make:Command', 99 | 'Adonis/Commands/Make:Hook', 100 | 'Adonis/Commands/Make:Middleware', 101 | 'Adonis/Commands/Make:Seed', 102 | 'Adonis/Commands/Make:Listener', 103 | 'Adonis/Commands/Migration:Run', 104 | 'Adonis/Commands/Migration:Rollback', 105 | 'Adonis/Commands/Migration:Refresh', 106 | 'Adonis/Commands/Migration:Reset', 107 | 'Adonis/Commands/DB:Seed', 108 | 'Adonis/Commands/Migration:Status', 109 | 'Adonis/Commands/Key:Generate' 110 | ] 111 | 112 | module.exports = { providers, aceProviders, aliases, commands } 113 | -------------------------------------------------------------------------------- /template/bootstrap/events.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Events 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Here you register events and define their listeners, which can be inline 9 | | closures or reference to a Listener inside app/Listeners. Also your 10 | | listeners can be async. 11 | | 12 | | Listeners are saved in app/Listeners directory. 13 | | 14 | | @example 15 | | Event.when('login', 'User.login') 16 | | 17 | */ 18 | const Event = use('Event') 19 | 20 | Event.when('Http.error.*', 'Http.handleError') 21 | Event.when('Http.start', 'Http.onStart') 22 | -------------------------------------------------------------------------------- /template/bootstrap/extend.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Extend Providers 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Some providers give options to be extended like SessionProvider. In this 9 | | file you can easily track which providers are extended. 10 | | 11 | | @note - Here you do not have access to any providers, which means this file 12 | | is called before loading service providers. But have access to the Ioc 13 | | container and you can use it extend providers, which are about to get 14 | | registered. 15 | | 16 | | @example 17 | | Ioc.extend('Adonis/Src/Session', 'redis', function (app) { 18 | | // your redis driver implementation 19 | | }) 20 | | 21 | */ 22 | -------------------------------------------------------------------------------- /template/bootstrap/http.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | HTTP Server Setup 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Here we join different pieces and start the HTTP server. It will be 9 | | a matter of seconds to start your shiny Adonis application. 10 | | 11 | */ 12 | 13 | const app = require('./app') 14 | const fold = require('adonis-fold') 15 | const path = require('path') 16 | const packageFile = path.join(__dirname, '../package.json') 17 | require('./extend') 18 | 19 | module.exports = function (callback) { 20 | fold.Registrar 21 | .register(app.providers) 22 | .then(() => { 23 | /* 24 | |-------------------------------------------------------------------------- 25 | | Register Aliases 26 | |-------------------------------------------------------------------------- 27 | | 28 | | After registering all the providers, we need to setup aliases so that 29 | | providers can be referenced with short sweet names. 30 | | 31 | */ 32 | fold.Ioc.aliases(app.aliases) 33 | 34 | /* 35 | |-------------------------------------------------------------------------- 36 | | Register Package File 37 | |-------------------------------------------------------------------------- 38 | | 39 | | Adonis application package.json file has the reference to the autoload 40 | | directory. Here we register the package file with the Helpers provider 41 | | to setup autoloading. 42 | | 43 | */ 44 | const Helpers = use('Helpers') 45 | const Env = use('Env') 46 | Helpers.load(packageFile, fold.Ioc) 47 | 48 | /* 49 | |-------------------------------------------------------------------------- 50 | | Register Events 51 | |-------------------------------------------------------------------------- 52 | | 53 | | Here we require the event.js file to register events defined inside 54 | | events.js file. 55 | | 56 | */ 57 | require('./events') 58 | 59 | /* 60 | |-------------------------------------------------------------------------- 61 | | Load Middleware And Routes 62 | |-------------------------------------------------------------------------- 63 | | 64 | | Middleware and Routes are required to oil up your HTTP server. Here we 65 | | require defined files for same. 66 | | 67 | */ 68 | use(Helpers.makeNameSpace('Http', 'kernel')) 69 | use(Helpers.makeNameSpace('Http', 'routes')) 70 | 71 | /* 72 | |-------------------------------------------------------------------------- 73 | | Load Database Factory 74 | |-------------------------------------------------------------------------- 75 | | 76 | | All database/model blueprints are defined inside the below file. We 77 | | autoload it to be used inside the entire application. 78 | | 79 | */ 80 | use(Helpers.databasePath('factory')) 81 | 82 | /* 83 | |-------------------------------------------------------------------------- 84 | | Start Http Server 85 | |-------------------------------------------------------------------------- 86 | | 87 | | We are all set to fire the Http Server and start receiving new requests. 88 | | 89 | */ 90 | const Server = use('Adonis/Src/Server') 91 | Server.listen(Env.get('HOST'), Env.get('PORT')) 92 | if (typeof (callback) === 'function') { 93 | callback() 94 | } 95 | }) 96 | .catch((error) => console.error(error.stack)) 97 | } 98 | -------------------------------------------------------------------------------- /template/bootstrap/kernel.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Ace Setup 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Ace is the command line utility to create and run terminal commands. 9 | | Here we setup the environment and register ace commands. 10 | | 11 | */ 12 | 13 | const app = require('./app') 14 | const fold = require('adonis-fold') 15 | const Ace = require('adonis-ace') 16 | const path = require('path') 17 | const packageFile = path.join(__dirname, '../package.json') 18 | require('./extend') 19 | 20 | module.exports = function () { 21 | fold.Registrar 22 | .register(app.providers.concat(app.aceProviders)) 23 | .then(() => { 24 | /* 25 | |-------------------------------------------------------------------------- 26 | | Register Aliases 27 | |-------------------------------------------------------------------------- 28 | | 29 | | After registering all the providers, we need to setup aliases so that 30 | | providers can be referenced with short sweet names. 31 | | 32 | */ 33 | fold.Ioc.aliases(app.aliases) 34 | 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Register Package File 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Adonis application package.json file has the reference to the autoload 41 | | directory. Here we register the package file with the Helpers provider 42 | | to setup autoloading. 43 | | 44 | */ 45 | const Helpers = use('Helpers') 46 | Helpers.load(packageFile, fold.Ioc) 47 | 48 | /* 49 | |-------------------------------------------------------------------------- 50 | | Register Events 51 | |-------------------------------------------------------------------------- 52 | | 53 | | Here we require the event.js file to register events defined inside 54 | | events.js file. 55 | | 56 | */ 57 | require('./events') 58 | 59 | /* 60 | |-------------------------------------------------------------------------- 61 | | Load Middleware And Routes 62 | |-------------------------------------------------------------------------- 63 | | 64 | | Middleware and Routes are required to oil up your HTTP server. Here we 65 | | require defined files for same. 66 | | 67 | */ 68 | use(Helpers.makeNameSpace('Http', 'kernel')) 69 | use(Helpers.makeNameSpace('Http', 'routes')) 70 | 71 | /* 72 | |-------------------------------------------------------------------------- 73 | | Load Database Factory 74 | |-------------------------------------------------------------------------- 75 | | 76 | | All database/model blueprints are defined inside the below file. We 77 | | autoload it to be used inside the entire application. 78 | | 79 | */ 80 | use(Helpers.databasePath('factory')) 81 | 82 | /* 83 | |-------------------------------------------------------------------------- 84 | | Register/Invoke Commands 85 | |-------------------------------------------------------------------------- 86 | | 87 | | Here we register commands with the Ace kernel and invoke the currently 88 | | executed command. It's so simple :) 89 | | 90 | */ 91 | Ace.register(app.commands) 92 | Ace.invoke(require(packageFile)) 93 | }) 94 | .catch((error) => console.error(error.stack)) 95 | } 96 | -------------------------------------------------------------------------------- /template/config/app.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Env = use('Env') 4 | 5 | module.exports = { 6 | 7 | /* 8 | |-------------------------------------------------------------------------- 9 | | App Key 10 | |-------------------------------------------------------------------------- 11 | | 12 | | App key is a randomly generated 16 or 32 characters long string required 13 | | to encrypted cookies, sessions and other sensitive data. 14 | | 15 | */ 16 | appKey: Env.get('APP_KEY'), 17 | 18 | encryption: { 19 | /* 20 | |-------------------------------------------------------------------------- 21 | | Encryption algorithm 22 | |-------------------------------------------------------------------------- 23 | | 24 | | Encryption algorithm defines the algorithm to be used while encrypting 25 | | values. Under the hood adonis makes of node-crypto. 26 | | 27 | | aes-256-cbc requires 32 characters long string 28 | | aes-128-cbc requires 16 characters long string 29 | | 30 | */ 31 | algorithm: 'aes-256-cbc' 32 | }, 33 | 34 | http: { 35 | /* 36 | |-------------------------------------------------------------------------- 37 | | Allow Method Spoofing 38 | |-------------------------------------------------------------------------- 39 | | 40 | | Method spoofing allows to make requests by spoofing the http verb. 41 | | Which means you can make a GET request but instruct the server to 42 | | treat as a POST or PUT request. If you want this feature, set the 43 | | below value to true. 44 | | 45 | */ 46 | allowMethodSpoofing: true, 47 | 48 | /* 49 | |-------------------------------------------------------------------------- 50 | | Trust Proxy 51 | |-------------------------------------------------------------------------- 52 | | 53 | | Trust proxy defines whether X-Forwaded-* headers should be trusted or not. 54 | | When your application is behind a proxy server like nginx, these values 55 | | are set automatically and should be trusted. Apart from setting it 56 | | to true or false Adonis supports handful or ways to allow proxy 57 | | values. Read documentation for that. 58 | | 59 | */ 60 | trustProxy: false, 61 | 62 | /* 63 | |-------------------------------------------------------------------------- 64 | | Subdomains 65 | |-------------------------------------------------------------------------- 66 | | 67 | | Offset to be used for returning subdomains for a given request.For 68 | | majority of applications it will be 2, until you have nested 69 | | sudomains. 70 | | cheatsheet.adonisjs.com - offset - 2 71 | | virk.cheatsheet.adonisjs.com - offset - 3 72 | | 73 | */ 74 | subdomainOffset: 2, 75 | 76 | /* 77 | |-------------------------------------------------------------------------- 78 | | Set Powered By 79 | |-------------------------------------------------------------------------- 80 | | 81 | | Adonis will set response header X-Powered-By if below value is set to 82 | | true. Consider this as a way of saying thanks to us. 83 | | 84 | */ 85 | setPoweredBy: true, 86 | 87 | /* 88 | |-------------------------------------------------------------------------- 89 | | JSONP Callback 90 | |-------------------------------------------------------------------------- 91 | | 92 | | Default jsonp callback to be used when callback query string is missing 93 | | in request url. 94 | | 95 | */ 96 | jsonpCallback: 'callback' 97 | }, 98 | 99 | views: { 100 | /* 101 | |-------------------------------------------------------------------------- 102 | | Cache Views 103 | |-------------------------------------------------------------------------- 104 | | 105 | | Define whether or not to cache the compiled view. Set it to true in 106 | | production to optimize view loading time. 107 | | 108 | */ 109 | cache: Env.get('CACHE_VIEWS', true), 110 | 111 | /* 112 | |-------------------------------------------------------------------------- 113 | | Service Injection 114 | |-------------------------------------------------------------------------- 115 | | 116 | | Inside your nunjucks views, you can inject models, services etc using 117 | | IoC container. Setting it to false will disable this feature. 118 | | 119 | */ 120 | injectServices: true 121 | }, 122 | 123 | static: { 124 | /* 125 | |-------------------------------------------------------------------------- 126 | | Dot Files 127 | |-------------------------------------------------------------------------- 128 | | 129 | | Define how to treat dot files when trying to server static resources. 130 | | By default it is set to ignore, which will pretend that dotfiles 131 | | does not exists. 132 | | 133 | | Can be one of the following 134 | | ignore, deny, allow 135 | | 136 | */ 137 | dotfiles: 'ignore', 138 | 139 | /* 140 | |-------------------------------------------------------------------------- 141 | | ETag 142 | |-------------------------------------------------------------------------- 143 | | 144 | | Enable or disable etag generation 145 | | 146 | */ 147 | etag: true, 148 | 149 | /* 150 | |-------------------------------------------------------------------------- 151 | | Extensions 152 | |-------------------------------------------------------------------------- 153 | | 154 | | Set file extension fallbacks. When set, if a file is not found, the given 155 | | extensions will be added to the file name and search for. The first 156 | | that exists will be served. Example: ['html', 'htm']. 157 | | 158 | */ 159 | extensions: false 160 | }, 161 | 162 | locales: { 163 | /* 164 | |-------------------------------------------------------------------------- 165 | | Driver 166 | |-------------------------------------------------------------------------- 167 | | 168 | | The driver to be used for fetching and updating locales. Below is the 169 | | list of available options. 170 | | 171 | | file, database 172 | | 173 | */ 174 | driver: 'file', 175 | 176 | /* 177 | |-------------------------------------------------------------------------- 178 | | Default Locale 179 | |-------------------------------------------------------------------------- 180 | | 181 | | Default locale to be used by Antl provider. You can always switch drivers 182 | | in runtime or use the official Antl middleware to detect the driver 183 | | based on HTTP headers/query string. 184 | | 185 | */ 186 | locale: 'en', 187 | 188 | /* 189 | |-------------------------------------------------------------------------- 190 | | Fallback Locale 191 | |-------------------------------------------------------------------------- 192 | | 193 | | Fallback locale to be used when actual locale is not supported. 194 | | 195 | */ 196 | fallbackLocale: 'en' 197 | } 198 | } 199 | -------------------------------------------------------------------------------- /template/config/auth.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Config = use('Config') 4 | 5 | module.exports = { 6 | 7 | /* 8 | |-------------------------------------------------------------------------- 9 | | Authenticator 10 | |-------------------------------------------------------------------------- 11 | | 12 | | Authenticator is a combination of HTTP Authentication scheme and the 13 | | serializer to be used for retrieving users. Below is the default 14 | | authenticator to be used for every request. 15 | | 16 | | Available Schemes - basic, session, jwt, api 17 | | Available Serializers - Lucid, Database 18 | | 19 | */ 20 | authenticator: 'session', 21 | 22 | /* 23 | |-------------------------------------------------------------------------- 24 | | Session Authenticator 25 | |-------------------------------------------------------------------------- 26 | | 27 | | Session authenticator will make use of sessions to maintain the login 28 | | state for a given user. 29 | | 30 | */ 31 | session: { 32 | serializer: 'Lucid', 33 | model: 'App/Model/User', 34 | scheme: 'session', 35 | uid: 'email', 36 | password: 'password' 37 | }, 38 | 39 | /* 40 | |-------------------------------------------------------------------------- 41 | | Basic Auth Authenticator 42 | |-------------------------------------------------------------------------- 43 | | 44 | | Basic Authentication works on Http Basic auth header. 45 | | 46 | */ 47 | basic: { 48 | serializer: 'Lucid', 49 | model: 'App/Model/User', 50 | scheme: 'basic', 51 | uid: 'email', 52 | password: 'password' 53 | }, 54 | 55 | /* 56 | |-------------------------------------------------------------------------- 57 | | JWT Authenticator 58 | |-------------------------------------------------------------------------- 59 | | 60 | | Jwt authentication works with a payload sent with every request under 61 | | Http Authorization header. 62 | | 63 | */ 64 | jwt: { 65 | serializer: 'Lucid', 66 | model: 'App/Model/User', 67 | scheme: 'jwt', 68 | uid: 'email', 69 | password: 'password', 70 | secret: Config.get('app.appKey') 71 | }, 72 | 73 | /* 74 | |-------------------------------------------------------------------------- 75 | | API Authenticator 76 | |-------------------------------------------------------------------------- 77 | | 78 | | Api authenticator authenticates are requests based on Authorization 79 | | header. 80 | | 81 | | Make sure to define relationships on User and Token model as defined 82 | | in documentation 83 | | 84 | */ 85 | api: { 86 | serializer: 'Lucid', 87 | model: 'App/Model/Token', 88 | scheme: 'api' 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /template/config/bodyParser.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | /* 5 | |-------------------------------------------------------------------------- 6 | | Data Limit 7 | |-------------------------------------------------------------------------- 8 | | 9 | | Data limit to be sent on a POST request. 10 | | 11 | */ 12 | limit: '1mb', 13 | 14 | /* 15 | |-------------------------------------------------------------------------- 16 | | Strict 17 | |-------------------------------------------------------------------------- 18 | | 19 | | Keeping strict to true will make body parse only parse array and objects 20 | | using JSON.parse. Keeping it to false will force the parse to parse all 21 | | values include null. 22 | | 23 | */ 24 | strict: true, 25 | 26 | qs: { 27 | /* 28 | |-------------------------------------------------------------------------- 29 | | Depth 30 | |-------------------------------------------------------------------------- 31 | | 32 | | How deep to parse nested values submitted as form body. 33 | | 34 | */ 35 | depth: 5, 36 | 37 | /* 38 | |-------------------------------------------------------------------------- 39 | | Parameter Limit 40 | |-------------------------------------------------------------------------- 41 | | 42 | | Max number of parameters to parse. 1000 is a way decent number for any 43 | | normal application. 44 | | 45 | */ 46 | parameterLimit: 1000, 47 | 48 | /* 49 | |-------------------------------------------------------------------------- 50 | | Delimiter 51 | |-------------------------------------------------------------------------- 52 | | 53 | | Delimiter to be used for parsing values. Example - a=b&b=c 54 | | 55 | */ 56 | delimiter: '&', 57 | 58 | /* 59 | |-------------------------------------------------------------------------- 60 | | Allow Dots 61 | |-------------------------------------------------------------------------- 62 | | 63 | | Keeping this value to true will enable dot notation. For example 64 | | 'a.b=c' will be parsed as {a: {b: 'c'}} 65 | | 66 | */ 67 | allowDots: false 68 | }, 69 | uploads: { 70 | 71 | /* 72 | |-------------------------------------------------------------------------- 73 | | Multiple 74 | |-------------------------------------------------------------------------- 75 | | 76 | | Whether or not to allow multiple file uploads. 77 | | 78 | */ 79 | multiple: true, 80 | 81 | /* 82 | |-------------------------------------------------------------------------- 83 | | CheckSums 84 | |-------------------------------------------------------------------------- 85 | | 86 | | This option will enable checksums for uploaded files. Following are 87 | | the support options. 88 | | 89 | | md5, sha1 90 | | 91 | */ 92 | hash: false, 93 | 94 | /* 95 | |-------------------------------------------------------------------------- 96 | | Max Upload Size 97 | |-------------------------------------------------------------------------- 98 | | 99 | | Max file upload size for all files. Example - 2 files of 1mb will reach 100 | | the maximum limit. 101 | | 102 | */ 103 | maxSize: '2mb' 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /template/config/cors.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | /* 5 | |-------------------------------------------------------------------------- 6 | | Origin 7 | |-------------------------------------------------------------------------- 8 | | 9 | | Setting up origin true will allow the request origin. You can also 10 | | define multiple origins as string. 11 | | 12 | */ 13 | origin: false, 14 | 15 | /* 16 | |-------------------------------------------------------------------------- 17 | | Methods 18 | |-------------------------------------------------------------------------- 19 | | 20 | | Comma seperated HTTP methods to be allowed. 21 | | 22 | */ 23 | methods: 'GET, PUT, POST', 24 | 25 | /* 26 | |-------------------------------------------------------------------------- 27 | | Headers 28 | |-------------------------------------------------------------------------- 29 | | 30 | | Headers to allow. Keep it true will allow headers defined in 31 | | Access-Control-Request-Headers. 32 | | 33 | */ 34 | headers: true, 35 | 36 | /* 37 | |-------------------------------------------------------------------------- 38 | | Expose Headers 39 | |-------------------------------------------------------------------------- 40 | | 41 | | Expose headers to Access-Control-Expose-Headers. 42 | | 43 | */ 44 | exposeHeaders: false, 45 | 46 | /* 47 | |-------------------------------------------------------------------------- 48 | | Credentials 49 | |-------------------------------------------------------------------------- 50 | | 51 | | Define Access-Control-Allow-Credentials header 52 | | 53 | */ 54 | credentials: false, 55 | 56 | /* 57 | |-------------------------------------------------------------------------- 58 | | MaxAge 59 | |-------------------------------------------------------------------------- 60 | | 61 | | Define Access-Control-Allow-Max-Age 62 | | 63 | */ 64 | maxAge: 90 65 | } 66 | -------------------------------------------------------------------------------- /template/config/database.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Env = use('Env') 4 | const Helpers = use('Helpers') 5 | 6 | module.exports = { 7 | 8 | /* 9 | |-------------------------------------------------------------------------- 10 | | Default Connection 11 | |-------------------------------------------------------------------------- 12 | | 13 | | Connection defines the default connection settings to be used while 14 | | interacting with SQL databases. 15 | | 16 | */ 17 | connection: Env.get('DB_CONNECTION', 'sqlite'), 18 | 19 | /* 20 | |-------------------------------------------------------------------------- 21 | | Sqlite 22 | |-------------------------------------------------------------------------- 23 | | 24 | | Sqlite is a flat file database and can be good choice under development 25 | | environment. 26 | | 27 | | npm i --save sqlite3 28 | | 29 | */ 30 | sqlite: { 31 | client: 'sqlite3', 32 | connection: { 33 | filename: Helpers.databasePath(Env.get('NODE_ENV', 'development') + '.sqlite') 34 | }, 35 | useNullAsDefault: true 36 | }, 37 | 38 | /* 39 | |-------------------------------------------------------------------------- 40 | | MySQL 41 | |-------------------------------------------------------------------------- 42 | | 43 | | Here we define connection settings for MySQL database. 44 | | 45 | | npm i --save mysql 46 | | 47 | */ 48 | mysql: { 49 | client: 'mysql', 50 | connection: { 51 | host: Env.get('DB_HOST', 'localhost'), 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 | user: Env.get('DB_USER', 'root'), 73 | password: Env.get('DB_PASSWORD', ''), 74 | database: Env.get('DB_DATABASE', 'adonis') 75 | } 76 | } 77 | 78 | } 79 | -------------------------------------------------------------------------------- /template/config/event.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | 5 | /* 6 | |-------------------------------------------------------------------------- 7 | | WildCard 8 | |-------------------------------------------------------------------------- 9 | | 10 | | Keeping wildcard true will let you register listeners using wildcards 11 | | instead of always using full names. 12 | | 13 | */ 14 | wildcard: true, 15 | 16 | /* 17 | |-------------------------------------------------------------------------- 18 | | Handle New Listener 19 | |-------------------------------------------------------------------------- 20 | | 21 | | Whether or not to emit new listener event, it's set to false by default. 22 | | 23 | */ 24 | newListener: false, 25 | 26 | /* 27 | |-------------------------------------------------------------------------- 28 | | Max Listeners/Event 29 | |-------------------------------------------------------------------------- 30 | | 31 | | Maximum number of listeners to be registered for a single event. 10 32 | | seems to be a good number. 33 | | 34 | */ 35 | maxListeners: 10 36 | 37 | } 38 | -------------------------------------------------------------------------------- /template/config/session.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | const Env = use('Env') 4 | 5 | module.exports = { 6 | /* 7 | |-------------------------------------------------------------------------- 8 | | Session Driver 9 | |-------------------------------------------------------------------------- 10 | | 11 | | Cookie driver will save session on cookies, but make sure to setup 12 | | APP_KEY inside .env file to keep cookies encrypted and signed. 13 | | 14 | | Available Options are :- 15 | | cookie, file, redis 16 | */ 17 | driver: Env.get('SESSION_DRIVER', 'cookie'), 18 | 19 | /* 20 | |-------------------------------------------------------------------------- 21 | | Cookie Name 22 | |-------------------------------------------------------------------------- 23 | | 24 | | Cookie name defines the name of key to used for saving session cookie. 25 | | Cookie name is required even if you are not using cookie driver. 26 | | 27 | */ 28 | cookie: 'adonis-session', 29 | 30 | /* 31 | |-------------------------------------------------------------------------- 32 | | Session Age 33 | |-------------------------------------------------------------------------- 34 | | 35 | | Define session life in minutes. Session will be destroyed after defined 36 | | minutes of inactivity. 37 | | 38 | */ 39 | age: 120, 40 | 41 | /* 42 | |-------------------------------------------------------------------------- 43 | | Clear on browser close 44 | |-------------------------------------------------------------------------- 45 | | 46 | | You can make your sessions to be removed once browser has been closed/killed 47 | | by setting below value to true. Also it will disregard age parameter. 48 | | 49 | */ 50 | clearWithBrowser: false, 51 | 52 | /* 53 | |-------------------------------------------------------------------------- 54 | | Http Only Cookie 55 | |-------------------------------------------------------------------------- 56 | | 57 | | Keep cookie http only, which means javascript cannot access the cookie 58 | | by document.cookie. 59 | | 60 | */ 61 | httpOnly: true, 62 | 63 | /* 64 | |-------------------------------------------------------------------------- 65 | | Same site only 66 | |-------------------------------------------------------------------------- 67 | | 68 | | Keep cookie accessible from the same domain. Available values are 69 | | true, false, lax and strict. 70 | | https://tools.ietf.org/html/draft-west-first-party-cookies-07 71 | | 72 | */ 73 | sameSite: true, 74 | 75 | /* 76 | |-------------------------------------------------------------------------- 77 | | Domain 78 | |-------------------------------------------------------------------------- 79 | | 80 | | Set domain for session cookie. If not defined it will be set to current 81 | | domain. For single and subdomains use. ".adonisjs.com" 82 | | 83 | */ 84 | domain: null, 85 | 86 | /* 87 | |-------------------------------------------------------------------------- 88 | | Path 89 | |-------------------------------------------------------------------------- 90 | | 91 | | Path defines where the session will be available. If you want to access 92 | | it anywhere on your website. Set it to / 93 | | 94 | */ 95 | path: '/', 96 | 97 | /* 98 | |-------------------------------------------------------------------------- 99 | | Secure 100 | |-------------------------------------------------------------------------- 101 | | 102 | | Define whether to keep session cookie secure or not. Secured cookies 103 | | are only served over HTTPS. 104 | | 105 | */ 106 | secure: false, 107 | 108 | /* 109 | |-------------------------------------------------------------------------- 110 | | File Driver Config 111 | |-------------------------------------------------------------------------- 112 | | 113 | | Here we define settings for file driver. For now we define directory 114 | | in which we want to store our sessions. Defined directory will be 115 | | created inside storage directory. 116 | | 117 | */ 118 | file: { 119 | directory: 'sessions' 120 | } 121 | 122 | } 123 | -------------------------------------------------------------------------------- /template/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 | | @examples 13 | | directives: { 14 | | defaultSrc: ['self', '@nonce', 'cdnjs.cloudflare.com'] 15 | | } 16 | */ 17 | csp: { 18 | directives: { 19 | }, 20 | reportOnly: false, 21 | setAllHeaders: false, 22 | disableAndroid: true 23 | }, 24 | 25 | /* 26 | |-------------------------------------------------------------------------- 27 | | X-XSS-Protection 28 | |-------------------------------------------------------------------------- 29 | | 30 | | X-XSS Protection saves from applications from XSS attacks. It is adopted 31 | | by IE and later followed by some other browsers. 32 | | 33 | */ 34 | xss: { 35 | enabled: true, 36 | enableOnOldIE: false 37 | }, 38 | 39 | /* 40 | |-------------------------------------------------------------------------- 41 | | Iframe Options 42 | |-------------------------------------------------------------------------- 43 | | 44 | | xframe defines whether or not your website can be embedded inside an 45 | | iframe. Choose from one of the following options. 46 | | @available options 47 | | DENY, SAMEORIGIN, ALLOW-FROM http://example.com 48 | */ 49 | xframe: 'DENY', 50 | 51 | /* 52 | |-------------------------------------------------------------------------- 53 | | No Sniff 54 | |-------------------------------------------------------------------------- 55 | | 56 | | Browsers have a habit of sniffing content-type of a response. Which means 57 | | files with .txt extension containing Javascript code will be executed as 58 | | Javascript. You can disable this behavior by setting nosniff to false. 59 | | 60 | */ 61 | nosniff: true, 62 | 63 | /* 64 | |-------------------------------------------------------------------------- 65 | | No Open 66 | |-------------------------------------------------------------------------- 67 | | 68 | | IE users can execute webpages in the context of your website, which is 69 | | a serious security risk. Below options will manage this for you. 70 | | 71 | */ 72 | noopen: true, 73 | 74 | /* 75 | |-------------------------------------------------------------------------- 76 | | CSRF Protection 77 | |-------------------------------------------------------------------------- 78 | | 79 | | CSRF Protection adds another layer of security by making sure, actionable 80 | | routes does have a valid token to execute an action. 81 | | 82 | */ 83 | csrf: { 84 | enable: true, 85 | methods: ['POST', 'PUT', 'DELETE'], 86 | filterUris: [], 87 | compareHostAndOrigin: true 88 | } 89 | 90 | } 91 | -------------------------------------------------------------------------------- /template/config/vue.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | module.exports = { 4 | 5 | /* 6 | |-------------------------------------------------------------------------- 7 | | Output directory for generated files 8 | |-------------------------------------------------------------------------- 9 | | 10 | | Directory where the generated files will be added (in public/) 11 | | By default, il will be in the public/dist/ 12 | | 13 | */ 14 | outputDir: 'dist', 15 | 16 | /* 17 | |-------------------------------------------------------------------------- 18 | | Generated Files Names 19 | |-------------------------------------------------------------------------- 20 | */ 21 | filenames: { 22 | clientVendor: 'client-vendor-bundle.js', 23 | client: 'client-bundle.js', 24 | server: 'server-bundle.js', 25 | css: 'style.css' 26 | }, 27 | 28 | /* 29 | |-------------------------------------------------------------------------- 30 | | Cache Components (activated only in production) 31 | |-------------------------------------------------------------------------- 32 | | If set to true, please install the lru-cache module (npm i -s lru-cache) 33 | */ 34 | cache: true, 35 | /* 36 | | max: , maximum number omponents cached 37 | | maxAge: , after ms, the cached component will be removed 38 | */ 39 | cacheOptions: { 40 | max: 1000, 41 | maxAge: 15 * 60 * 1000 42 | }, 43 | 44 | /* 45 | |-------------------------------------------------------------------------- 46 | | Webpack Configuration 47 | |-------------------------------------------------------------------------- 48 | | 49 | | The generated files will be added in the public/dist/ directory 50 | | 51 | */ 52 | webpack: { 53 | /* 54 | |-------------------------------------------------------------------------- 55 | | Server Configuration 56 | |-------------------------------------------------------------------------- 57 | | 58 | | Path to the webpack configuration for the server-bundle.js file 59 | | You can change the name of the file generated in above (filenames.server) 60 | | 61 | */ 62 | serverConfig: 'webpack/server.config', 63 | 64 | /* 65 | |-------------------------------------------------------------------------- 66 | | Client Configuration 67 | |-------------------------------------------------------------------------- 68 | | 69 | | Path to the webpack configuration for the client-vendor-bundle.js and 70 | | client-bundle.js file 71 | | You can change the name of the files generated above 72 | | (filenames.clientVendor and filenames.client) 73 | | 74 | | In production, the CSS will be extracted and created as a single file in 75 | | the public/dist/ directory 76 | | You can change the name of the css file above (filenames.css) 77 | | 78 | */ 79 | clientConfig: 'webpack/client.config' 80 | 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /template/config/webpack/base.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | const resolve = file => path.resolve(__dirname, file) 3 | const CleanWebpackPlugin = require('clean-webpack-plugin') 4 | const vueLoaderConfig = require('./vue-loader.config') 5 | const outputDir = require('../vue').outputDir 6 | const urlJoin = function () { return [].slice.call(arguments).join('/').replace(/\/+/g, '/') } 7 | 8 | /* 9 | |-------------------------------------------------------------------------- 10 | | Webpack Shared Config 11 | | 12 | | This is the config which is extented by the server and client 13 | | webpack config files 14 | |-------------------------------------------------------------------------- 15 | */ 16 | module.exports = { 17 | devtool: '#source-map', 18 | entry: { 19 | app: resolve('../../resources/src/client-entry.js'), 20 | vendor: ['vue', 'vue-router', 'vuex', 'es6-promise'] 21 | }, 22 | output: { 23 | path: resolve('../../public/' + outputDir), 24 | publicPath: urlJoin('/', outputDir, '/') 25 | }, 26 | performance: { 27 | hints: (process.env.NODE_ENV === 'production' ? 'warning' : false) 28 | }, 29 | module: { 30 | rules: [ 31 | { 32 | test: /\.vue$/, 33 | loader: 'vue-loader', 34 | options: vueLoaderConfig 35 | }, 36 | { 37 | test: /\.js$/, 38 | loader: 'babel-loader', 39 | exclude: /node_modules/ 40 | }, 41 | { 42 | test: /\.(png|jpg|gif|svg)$/, 43 | loader: 'url-loader', 44 | options: { 45 | limit: 1000, // 1KO 46 | name: 'img/[name].[ext]?[hash]' 47 | } 48 | }, 49 | { 50 | test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/, 51 | loader: 'url-loader', 52 | query: { 53 | limit: 1000, // 1 KO 54 | name: 'fonts/[name].[hash:7].[ext]' 55 | } 56 | } 57 | ] 58 | }, 59 | plugins: [ 60 | new CleanWebpackPlugin([ outputDir ], { 61 | root: resolve('../../public') 62 | }) 63 | ] 64 | } 65 | -------------------------------------------------------------------------------- /template/config/webpack/client.config.js: -------------------------------------------------------------------------------- 1 | const webpack = require('webpack') 2 | const base = require('./base.config') 3 | const vueConfig = require('./vue-loader.config') 4 | const filenames = require('../vue').filenames 5 | 6 | /* 7 | |-------------------------------------------------------------------------- 8 | | Webpack Client Config 9 | | 10 | | Generate public/dist/client-vendor-bundle.js 11 | | Generate public/dist/client-bundle.js 12 | | 13 | | In production, will generate public/dist/style.css 14 | |-------------------------------------------------------------------------- 15 | */ 16 | 17 | const config = Object.assign({}, base, { 18 | output: Object.assign({}, base.output, { 19 | filename: filenames.client 20 | }), 21 | plugins: (base.plugins || []).concat([ 22 | // strip comments in Vue code 23 | new webpack.DefinePlugin({ 24 | 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development') 25 | }), 26 | // extract vendor chunks for better caching 27 | new webpack.optimize.CommonsChunkPlugin({ 28 | name: 'vendor', 29 | filename: filenames.clientVendor 30 | }) 31 | ]) 32 | }) 33 | 34 | if (process.env.NODE_ENV === 'production') { 35 | // Use ExtractTextPlugin to extract CSS into a single file 36 | // so it's applied on initial render 37 | const ExtractTextPlugin = require('extract-text-webpack-plugin') 38 | 39 | // vueConfig is already included in the config via LoaderOptionsPlugin 40 | // here we overwrite the loader config for 32 | -------------------------------------------------------------------------------- /template/resources/src/app.js: -------------------------------------------------------------------------------- 1 | // The Vue build version to load with the `import` command 2 | // (runtime-only or standalone) has been set in webpack.base.conf with an alias. 3 | import Vue from 'vue' 4 | import store from './store' 5 | import router from './router' 6 | import { sync } from 'vuex-router-sync' 7 | 8 | // sync the router with the vuex store. 9 | // this registers `store.state.route` 10 | sync(store, router) 11 | 12 | import App from './App.vue' 13 | // create the app instance. 14 | // here we inject the router and store to all child components, 15 | // making them available everywhere as `this.$router` and `this.$store`. 16 | const app = new Vue({ 17 | router, 18 | store, 19 | ...App 20 | }) 21 | 22 | export { app, router, store } 23 | -------------------------------------------------------------------------------- /template/resources/src/assets/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atinux/vue-adonis/39e3794cea3668ee6a6fa97634a8d899bec8b80a/template/resources/src/assets/img/logo.png -------------------------------------------------------------------------------- /template/resources/src/client-entry.js: -------------------------------------------------------------------------------- 1 | require('es6-promise').polyfill() 2 | import { app, store } from './app' 3 | 4 | // prime the store with server-initialized state. 5 | // the state is determined during SSR and inlined in the page markup. 6 | store.replaceState(window.__INITIAL_STATE__) 7 | 8 | // actually mount to DOM 9 | app.$mount('#app') 10 | -------------------------------------------------------------------------------- /template/resources/src/components/Hello.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 16 | 17 | 18 | 23 | -------------------------------------------------------------------------------- /template/resources/src/router/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atinux/vue-adonis/39e3794cea3668ee6a6fa97634a8d899bec8b80a/template/resources/src/router/.gitkeep -------------------------------------------------------------------------------- /template/resources/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Router from 'vue-router' 3 | 4 | Vue.use(Router) 5 | 6 | import Home from '../views/Home.vue' 7 | 8 | export default new Router({ 9 | mode: 'history', 10 | scrollBehavior: () => ({ y: 0 }), 11 | routes: [ 12 | { path: '*', component: Home } 13 | ] 14 | }) 15 | -------------------------------------------------------------------------------- /template/resources/src/server-entry.js: -------------------------------------------------------------------------------- 1 | import { app, router, store } from './app' 2 | 3 | const isDev = process.env.NODE_ENV !== 'production' 4 | 5 | // This exported function will be called by `bundleRenderer`. 6 | // This is where we perform data-prefetching to determine the 7 | // state of our application before actually rendering it. 8 | // Since data fetching is async, this function is expected to 9 | // return a Promise that resolves to the app instance. 10 | export default context => { 11 | // set router's location 12 | router.push(context.url) 13 | 14 | const s = isDev && Date.now() 15 | 16 | // Call preFetch hooks on components matched by the route. 17 | // A preFetch hook dispatches a store action and returns a Promise, 18 | // which is resolved when the action is complete and store state has been 19 | // updated. 20 | return Promise.all(router.getMatchedComponents().map(component => { 21 | if (component.preFetch) { 22 | return component.preFetch(store) 23 | } 24 | })).then(() => { 25 | isDev && console.log(`data pre-fetch: ${Date.now() - s}ms`) 26 | // After all preFetch hooks are resolved, our store is now 27 | // filled with the state needed to render the app. 28 | // Expose the state on the render context, and let the request handler 29 | // inline the state in the HTML response. This allows the client-side 30 | // store to pick-up the server-side state without having to duplicate 31 | // the initial data fetching on the client. 32 | context.initialState = store.state 33 | return app 34 | }) 35 | } 36 | -------------------------------------------------------------------------------- /template/resources/src/store/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atinux/vue-adonis/39e3794cea3668ee6a6fa97634a8d899bec8b80a/template/resources/src/store/.gitkeep -------------------------------------------------------------------------------- /template/resources/src/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | 4 | Vue.use(Vuex) 5 | 6 | const store = new Vuex.Store({ 7 | state: {}, 8 | 9 | actions: {}, 10 | 11 | mutations: {}, 12 | 13 | getters: {} 14 | }) 15 | 16 | export default store 17 | -------------------------------------------------------------------------------- /template/resources/src/views/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atinux/vue-adonis/39e3794cea3668ee6a6fa97634a8d899bec8b80a/template/resources/src/views/.gitkeep -------------------------------------------------------------------------------- /template/resources/src/views/Home.vue: -------------------------------------------------------------------------------- 1 | 22 | 23 | 32 | 33 | 39 | -------------------------------------------------------------------------------- /template/resources/views/app.njk: -------------------------------------------------------------------------------- 1 | {{{{raw}}}} 2 | 3 | 4 | 5 | 6 | vue-adonis 7 | 8 | {# #} 9 | {% if isProd %}{% endif %} 10 | 11 | 12 | {% if context.initialState %} 13 | 14 | {% endif %} 15 | {{ APP | safe }} 16 | 17 | 18 | 19 | 20 | {{{{/raw}}}} 21 | -------------------------------------------------------------------------------- /template/resources/views/errors/index.njk: -------------------------------------------------------------------------------- 1 | {{{{raw}}}} 2 |

An unexpected error occured, please forgive us and try again later.

3 | {{{{/raw}}}} 4 | -------------------------------------------------------------------------------- /template/resources/views/errors/vue.njk: -------------------------------------------------------------------------------- 1 | {{{{raw}}}} 2 | 3 |

Vue.js error

4 |
{{ ansiHTML(encodeHtml(err.stack)) | safe }}
5 | 6 | {{{{/raw}}}} 7 | -------------------------------------------------------------------------------- /template/server.js: -------------------------------------------------------------------------------- 1 | 'use strict' 2 | 3 | /* 4 | |-------------------------------------------------------------------------- 5 | | Http Server 6 | |-------------------------------------------------------------------------- 7 | | 8 | | Here we boot the HTTP Server by calling the exported method. A callback 9 | | function is optionally passed which is executed, once the HTTP server 10 | | is running. 11 | | 12 | */ 13 | 14 | const http = require('./bootstrap/http') 15 | http(function () { 16 | use('Event').fire('Http.start') 17 | 18 | // Start the renderer bundle as soon as possible 19 | use('App/Http/Controllers/WebAppController') 20 | }) 21 | -------------------------------------------------------------------------------- /template/storage/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atinux/vue-adonis/39e3794cea3668ee6a6fa97634a8d899bec8b80a/template/storage/.gitkeep --------------------------------------------------------------------------------