Giter Club home page Giter Club logo

create-nuxt-express-app's Introduction

create-nuxt-express-app

Before Setup

$ cp .env.example .env

Start Mongo

$ docker-compose up -d mongo

Build Setup

# install dependencies
$ yarn install

# serve with hot reload at localhost:3000
$ yarn run dev

Docker Compose Setup

$ docker-compose up -d --build

Note

* Pages
  |_ index.vue
  |_ users
     \_ _id
         \_index.vue <-- /users/:id

* Router
  * $route.params.id
  * validate(data) { return /^\d+$/.test(data.params.id)} <-- validate property in export default{}
  * this.$router.push()
  * nuxt-child

* Link
  * nuxt-link

* Layouts
  * <nuxt />
  * users.vue
  * layout: 'users' <-- layout property in export default{}
  * error.vue <-- overwrite nuxt error page

* Assets
  * assets
    \_ styles
    |  \_ main.css
    |_ images
  * css:[ '~/assets/styles/main.css' ] <-- nuxt.config.js

* Header <-- nuxt.config.js
  * link: [
      { rel: 'stylesheet', href: ''}
    ]
  * script: [
      { src: '' }
    ]

* Handling Data
  * asyncData(context, callback) { return {} } <-- property in export default {}
  * asyncData(context) { return new Promise((resolve, reject)=> resolve({loadedSomethink: []}))
      .then(data => data)
      .catch(err => context.error(err))
    } <-- property in export default {}
  * fetch(context) { return {} } <-- property in export default {}
    * context.store.commit('SET_SOMETHINK', data.loadedSomethink) <-- in then(data => {})

* Store
  * nuxtServerInit(vuexContext, context) {} <-- in actions
    * vuexContext.commit('SET_SOMETHINK', [])

* Client & Server Connecting
  * !process.client can use context.req <-- in nuxtServerInit

* Config
  * nuxt.config.js -> https://nuxtjs.org/guide/configuration
  * head: { title: 'title'} <-- property in export default {}
  * loadingIndicator: { name: 'circle', color: 'hexcode'} <-- in nuxt.config.js
    \_ mode: 'spa'
  * env: {
      baseUrl: process.env.BASE_URL || 'http://localhost:3000' <-- use process.env.baseUrl in client
    }
  * rootDir: '/my-app/'
  * router: {
      base: '/my-app/' or extendRoutes(routes, resolve) { path: '*', component: resolve(__dirname, 'pages/index.vue') }
    }
  * transition: { name: 'page' or 'fade', mode: 'out-in' }
  * serverMiddleware: [ bodyParser.json(), '~/api ]
  * generate: { routes: function() {
      return axios.get('url').then(res => {
        const routes = []
        for (const key in res.data) {
          routes.push(`/paths/${key}`)
        }
        return routes
      })
    }}

* Pluins
  |_ plugins
     \_ coreComponent.js
  * plugins: ["~plugins/coreComponent.js"] <-- in nuxt.config.js

* Modules
  * modules: [
      '@nuxtjs/axios
    ],
    axios: {
      baseURL: process.env.BASE_URL || 'http://localhost:3000'
    } <-- use in nuxtServerInit := context.app.$axios.get('/path')
      <-- use in asyncData(context) { return this.$axios.$get('/path')}

* Middleware
  |_ middleware
     \_ auth.js
  * middleware: ['auth'] <-- property in export default {}

Module should to learning more

  • @nuxtjs/axios
  • vue-socket.io
  • js-cookie

Testing

https://vue-test-utils.vuejs.org/en/

Why test?
- Check application works correctly
- Provide documentation
- Easier debugging
- Less bugs

create-nuxt-express-app's People

Contributors

yuttasakcom avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.