diff --git a/template/.editorconfig b/template/.editorconfig new file mode 100644 index 0000000..5d12634 --- /dev/null +++ b/template/.editorconfig @@ -0,0 +1,13 @@ +# editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/template/.eslintrc.js b/template/.eslintrc.js index b44e099..8cc5d3a 100644 --- a/template/.eslintrc.js +++ b/template/.eslintrc.js @@ -1,16 +1,18 @@ module.exports = { root: true, - parser: 'babel-eslint', env: { browser: true, node: true }, - extends: 'standard', - // required to lint *.vue files + parserOptions: { + parser: 'babel-eslint' + }, + extends: [ + '@nuxtjs', + 'plugin:nuxt/recommended' + ], plugins: [ - 'html' ], // add your custom rules here - rules: {}, - globals: {} + rules: {} } diff --git a/template/.gitignore b/template/.gitignore index 7b356cd..e8f682b 100644 --- a/template/.gitignore +++ b/template/.gitignore @@ -1,14 +1,90 @@ -# dependencies -node_modules +# Created by .ignore support plugin (hsz.mobi) +### Node template +# Logs +/logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* -# logs -npm-debug.log +# Runtime data +pids +*.pid +*.seed +*.pid.lock -# Nuxt build +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# next.js build output +.next + +# nuxt.js build output .nuxt # Nuxt generate dist -# Backpack build -build +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless + +# IDE / Editor +.idea + +# Service worker +sw.* + +# macOS +.DS_Store + +# Vim swap files +*.swp diff --git a/template/README.md b/template/README.md index e427779..87aa59d 100644 --- a/template/README.md +++ b/template/README.md @@ -1,18 +1,20 @@ -# {{ name }} - -> {{ description }} +# nuxt-express ## Build Setup -``` bash +```bash # install dependencies -$ npm install # Or yarn install +$ yarn install # serve with hot reload at localhost:3000 -$ npm run dev +$ yarn dev # build for production and launch server -$ npm start +$ yarn build +$ yarn start + +# generate static project +$ yarn generate ``` -For detailed explanation on how things work, checkout the [Nuxt.js docs](https://github.com/nuxt/nuxt.js). \ No newline at end of file +For detailed explanation on how things work, check out [Nuxt.js docs](https://nuxtjs.org). diff --git a/template/api/index.js b/template/api/index.js index a18db51..1138030 100644 --- a/template/api/index.js +++ b/template/api/index.js @@ -5,12 +5,19 @@ const app = express() // Require API routes const users = require('./routes/users') +const test = require('./routes/test') // Import API Routes app.use(users) +app.use(test) -// Export the server middleware -module.exports = { - path: '/api', - handler: app +// Export express app +module.exports = app + +// Start standalone server if directly running +if (require.main === module) { + const port = process.env.PORT || 3001 + app.listen(port, () => { + console.log(`API server listening on port ${port}`) + }) } diff --git a/template/api/routes/test.js b/template/api/routes/test.js new file mode 100644 index 0000000..43bd813 --- /dev/null +++ b/template/api/routes/test.js @@ -0,0 +1,10 @@ +const { Router } = require('express') + +const router = Router() + +// Test route +router.use('/test', (req, res) => { + res.end('Test API!') +}) + +module.exports = router diff --git a/template/assets/README.md b/template/assets/README.md new file mode 100644 index 0000000..34766f9 --- /dev/null +++ b/template/assets/README.md @@ -0,0 +1,7 @@ +# ASSETS + +**This directory is not required, you can delete it if you don't want to use it.** + +This directory contains your un-compiled assets such as LESS, SASS, or JavaScript. + +More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/assets#webpacked). diff --git a/template/assets/css/main.css b/template/assets/css/main.css deleted file mode 100644 index e3f28fe..0000000 --- a/template/assets/css/main.css +++ /dev/null @@ -1,28 +0,0 @@ -html, body -{ - background-color: #fff; - color: #000; - letter-spacing: 0.5px; - font-family: "Source Sans Pro", Arial, sans-serif; - height: 100vh; - margin: 0; -} - -footer -{ - padding: 20px; - text-align: center; - border-top: 1px solid #ddd; -} - -a, a:hover, a:focus, a:visited -{ - color: #000; -} - -.logo { - width: 100%; - height: auto; - max-width: 400px; - max-height: 289px; -} diff --git a/template/assets/img/logo.png b/template/assets/img/logo.png deleted file mode 100644 index f8a35ef..0000000 Binary files a/template/assets/img/logo.png and /dev/null differ diff --git a/template/components/Footer.vue b/template/components/Footer.vue deleted file mode 100644 index 7aaf2c2..0000000 --- a/template/components/Footer.vue +++ /dev/null @@ -1,5 +0,0 @@ - diff --git a/template/components/Logo.vue b/template/components/Logo.vue new file mode 100644 index 0000000..50c62a2 --- /dev/null +++ b/template/components/Logo.vue @@ -0,0 +1,31 @@ +{{{{raw}}}} + +{{{{/raw}}}} + + diff --git a/template/components/README.md b/template/components/README.md new file mode 100644 index 0000000..a079f10 --- /dev/null +++ b/template/components/README.md @@ -0,0 +1,7 @@ +# COMPONENTS + +**This directory is not required, you can delete it if you don't want to use it.** + +The components directory contains your Vue.js Components. + +_Nuxt.js doesn't supercharge these components._ diff --git a/template/layouts/README.md b/template/layouts/README.md new file mode 100644 index 0000000..cad1ad5 --- /dev/null +++ b/template/layouts/README.md @@ -0,0 +1,7 @@ +# LAYOUTS + +**This directory is not required, you can delete it if you don't want to use it.** + +This directory contains your Application Layouts. + +More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/views#layouts). diff --git a/template/layouts/default.vue b/template/layouts/default.vue index c9d50bd..cc002a7 100644 --- a/template/layouts/default.vue +++ b/template/layouts/default.vue @@ -1,52 +1,65 @@ +{{{{raw}}}} +{{{{/raw}}}} - - diff --git a/template/layouts/error.vue b/template/layouts/error.vue index 647d6e4..8278ad7 100644 --- a/template/layouts/error.vue +++ b/template/layouts/error.vue @@ -1,16 +1,18 @@ {{{{raw}}}} {{{{/raw}}}} @@ -21,10 +23,31 @@ export default { diff --git a/template/pages/_id.vue b/template/pages/users/_id.vue similarity index 50% rename from template/pages/_id.vue rename to template/pages/users/_id.vue index fe78288..a5245d5 100644 --- a/template/pages/_id.vue +++ b/template/pages/users/_id.vue @@ -1,29 +1,28 @@ {{{{raw}}}} {{{{/raw}}}} diff --git a/template/plugins/README.md b/template/plugins/README.md new file mode 100644 index 0000000..ca1f9d8 --- /dev/null +++ b/template/plugins/README.md @@ -0,0 +1,7 @@ +# PLUGINS + +**This directory is not required, you can delete it if you don't want to use it.** + +This directory contains Javascript plugins that you want to run before mounting the root Vue.js application. + +More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/plugins). diff --git a/template/plugins/axios.js b/template/plugins/axios.js deleted file mode 100644 index c804d21..0000000 --- a/template/plugins/axios.js +++ /dev/null @@ -1,9 +0,0 @@ -import * as axios from 'axios' - -let options = {} -// The server-side needs a full url to works -if (process.server) { - options.baseURL = `http://${process.env.HOST || 'localhost'}:${process.env.PORT || 3000}` -} - -export default axios.create(options) diff --git a/template/static/README.md b/template/static/README.md new file mode 100644 index 0000000..cf00435 --- /dev/null +++ b/template/static/README.md @@ -0,0 +1,11 @@ +# STATIC + +**This directory is not required, you can delete it if you don't want to use it.** + +This directory contains your static files. +Each file inside this directory is mapped to `/`. +Thus you'd want to delete this README.md before deploying to production. + +Example: `/static/robots.txt` is mapped as `/robots.txt`. + +More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/assets#static). diff --git a/template/static/favicon.ico b/template/static/favicon.ico index 382fecb..3632d0c 100644 Binary files a/template/static/favicon.ico and b/template/static/favicon.ico differ diff --git a/template/store/README.md b/template/store/README.md new file mode 100644 index 0000000..1972d27 --- /dev/null +++ b/template/store/README.md @@ -0,0 +1,10 @@ +# STORE + +**This directory is not required, you can delete it if you don't want to use it.** + +This directory contains your Vuex Store files. +Vuex Store option is implemented in the Nuxt.js framework. + +Creating a file in this directory automatically activates the option in the framework. + +More information about the usage of this directory in [the documentation](https://nuxtjs.org/guide/vuex-store).