├── template
├── static
│ └── favicon.ico
├── assets
│ ├── img
│ │ └── NuxtMicro.png
│ └── css
│ │ └── main.css
├── .gitignore
├── api
│ ├── users.js
│ └── index.js
├── components
│ └── Footer.vue
├── plugins
│ └── axios.js
├── nuxt.index.js
├── README.md
├── server.js
├── micro.config.js
├── nuxt.config.js
├── .eslintrc.js
├── layouts
│ ├── error.vue
│ └── default.vue
├── package.json
└── pages
│ ├── index.vue
│ └── _id.vue
├── meta.js
└── README.md
/template/static/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nuxt-community/micro-template/HEAD/template/static/favicon.ico
--------------------------------------------------------------------------------
/template/assets/img/NuxtMicro.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nuxt-community/micro-template/HEAD/template/assets/img/NuxtMicro.png
--------------------------------------------------------------------------------
/template/.gitignore:
--------------------------------------------------------------------------------
1 | # dependencies
2 | node_modules
3 |
4 | # logs
5 | npm-debug.log
6 |
7 | # Nuxt build
8 | .nuxt
9 |
10 | # Nuxt generate
11 | dist
12 |
--------------------------------------------------------------------------------
/template/api/users.js:
--------------------------------------------------------------------------------
1 | module.exports = new Promise((resolve) => {
2 | resolve([
3 | { name: 'Alexandre' },
4 | { name: 'Sébastien' },
5 | { name: 'Sebastian' }
6 | ]
7 | )
8 | })
--------------------------------------------------------------------------------
/template/components/Footer.vue:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
--------------------------------------------------------------------------------
/template/plugins/axios.js:
--------------------------------------------------------------------------------
1 | import axios from 'axios'
2 |
3 | let options = {}
4 | // The server-side needs a full url to works
5 | if (process.server) {
6 | options.baseURL = `http://${process.env.HOST || 'localhost'}:${process.env.PORT || 3000}`
7 | }
8 |
9 | export default axios.create(options)
10 |
--------------------------------------------------------------------------------
/template/nuxt.index.js:
--------------------------------------------------------------------------------
1 | // Require Nuxt And Builder modules
2 | const { Nuxt, Builder } = require('nuxt')
3 |
4 | // Require nuxt config
5 | const config = require('./nuxt.config.js')
6 |
7 | // Create a new nuxt instance
8 | const nuxt = new Nuxt(config)
9 |
10 | // Enable live build & reloading on dev
11 | if (nuxt.options.dev) {
12 | new Builder(nuxt).build()
13 | }
14 |
15 | module.exports = nuxt
16 |
--------------------------------------------------------------------------------
/template/api/index.js:
--------------------------------------------------------------------------------
1 | const users = require('./users.js')
2 | const { createError } = require('micro')
3 |
4 | exports.getUser = async (id) => {
5 | let allUsers = await users
6 | if(id >= 0 && id < allUsers.length) {
7 | let user = allUsers[id]
8 | return user
9 | }
10 | throw createError(404, 'User not found')
11 | }
12 |
13 | exports.getUsers = async () => {
14 | return await users
15 | }
16 |
--------------------------------------------------------------------------------
/template/README.md:
--------------------------------------------------------------------------------
1 | # nm2
2 |
3 | > Nuxt.js + Δ micro project
4 |
5 | ## Build Setup
6 |
7 | ``` bash
8 | # install dependencies
9 | $ npm install # Or yarn
10 |
11 | # serve with hot reload at localhost:3000
12 | $ npm run dev # Or yarn dev
13 |
14 | # build for production and launch server
15 | $ npm start # Or yarn start
16 |
17 | For detailed explanation on how things work, checkout the [Nuxt.js docs](https://github.com/nuxt/nuxt.js).
18 |
--------------------------------------------------------------------------------
/template/server.js:
--------------------------------------------------------------------------------
1 | const micro = require('micro')
2 |
3 | const host = process.env.HOST || 'localhost'
4 | const port = process.env.PORT || 3000
5 |
6 | // setup the microservice includinng intercepted routing
7 | const serviceConfig = require('./micro.config.js')
8 | const server = micro(serviceConfig)
9 |
10 | // Listen the server
11 | server.listen(port, host)
12 | console.log('Server listening on ' + host + ':' + port) // eslint-disable-line no-console
13 |
--------------------------------------------------------------------------------
/template/micro.config.js:
--------------------------------------------------------------------------------
1 | const dispatch = require('micro-route/dispatch')
2 | const {send} = require('micro')
3 | const {getUser, getUsers} = require('./api/')
4 | const nuxt = require('./nuxt.index.js')
5 |
6 | module.exports = dispatch()
7 | .dispatch('/api/users/:id', ['GET'], async (req, res, {params, query}) => send(res, 200, await getUser(params.id)))
8 | .dispatch('/api/users', ['GET'], async (req, res) => send(res, 200, await getUsers()))
9 | .dispatch('*', ['GET'], (req, res) => nuxt.render(req, res))
10 |
--------------------------------------------------------------------------------
/template/assets/css/main.css:
--------------------------------------------------------------------------------
1 | html, body
2 | {
3 | background-color: #fff;
4 | color: #000;
5 | letter-spacing: 0.5px;
6 | font-family: "Source Sans Pro", Arial, sans-serif;
7 | height: 100vh;
8 | margin: 0;
9 | }
10 |
11 | footer
12 | {
13 | padding: 20px;
14 | text-align: center;
15 | border-top: 1px solid #ddd;
16 | }
17 |
18 | a, a:hover, a:focus, a:visited
19 | {
20 | color: #000;
21 | }
22 |
23 | .logo {
24 | width: 100%;
25 | height: auto;
26 | max-width: 400px;
27 | max-height: 289px;
28 | }
29 |
--------------------------------------------------------------------------------
/template/nuxt.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | /*
3 | ** Headers of the page
4 | */
5 | head: {
6 | title: 'Nuxt Micro Project',
7 | meta: [
8 | { charset: 'utf-8' },
9 | { name: 'viewport', content: 'width=device-width, initial-scale=1' },
10 | { hid: 'description', meta: 'description', content: 'Nuxt.js project' }
11 | ],
12 | link: [
13 | { rel: 'icon', type: 'image/x-icon', href: 'favicon.ico' }
14 | ]
15 | },
16 | /*
17 | ** Global CSS
18 | */
19 | css: ['~assets/css/main.css'],
20 | /*
21 | ** Add axios globally
22 | */
23 | build: {
24 | vendor: ['axios']
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/template/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | parser: 'babel-eslint',
4 | env: {
5 | browser: true,
6 | node: true
7 | },
8 | extends: 'standard',
9 | // required to lint *.vue files
10 | plugins: [
11 | 'html'
12 | ],
13 | // add your custom rules here
14 | rules: {
15 | // allow paren-less arrow functions
16 | 'arrow-parens': 0,
17 | // allow async-await
18 | 'generator-star-spacing': 0,
19 | // allow debugger during development
20 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
21 | // do not allow console.logs etc...
22 | 'no-console': 2
23 | },
24 | globals: {}
25 | }
26 |
--------------------------------------------------------------------------------
/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': 'Nuxt.js + Δ micro project'
18 | },
19 | author: {
20 | 'type': 'string',
21 | 'message': 'Author'
22 | },
23 | },
24 | completeMessage: '{{#inPlace}}To get started:\n\n npm install # Or yarn\n npm run dev # Or yarn dev{{else}}To get started:\n\n cd {{destDirName}}\n npm install # Or yarn\n npm run dev # Or yarn dev{{/inPlace}}'
25 | };
26 |
--------------------------------------------------------------------------------
/template/layouts/error.vue:
--------------------------------------------------------------------------------
1 | {{{{raw}}}}
2 |
3 |
5 |
6 | {{ error.statusCode }}
7 |
8 |
9 | {{ error.message }}
10 |
11 |
5 |
6 | USERS
7 |
8 |
9 |
15 |
5 |
6 | User
7 |
8 |
9 | {{ user.name }}
10 |
11 |
