Code Monkey home page Code Monkey logo

vue-fullstack's Introduction

Logo

Vue fullstack template

MIT Licence vue version

This project's goal is to help people create a reactive, realtime and user friendly backend system.:smirk:

Vue version

This template only support vue2, because it use ElementUI as the default ui library and ElementUI just support vue2.

Requirement

  • Mongodb This project requires mongodb as the database. You can follow it's tutorial to install it if you haven't installed it already. In consideration of the recent mongodb attack event, it's highly recommend to enable auth and disable public login for your mongodb.
  • Basic vue.js skills

About mock and i18n

If you chose to use mock server or not use i18n at project initialization, you need to take a look at this description, else you can skip this step.
As vue-cli does't support to run a task after initialization, you need to run npm run remove:i18n(This script doesn't change the page view which contains change locale in client/src/components/Header.vue and client/src/view/auth/Login.vue, you can remove that code manually.) and npm run remove:mock manually.

Usage

This is a project template for vue-cli. It is recommended to use npm 3+ for a more efficient dependency tree.

# cli version must be greater than 2.8.0
$ npm install -g vue-cli
$ vue init erguotou520/vue-fullstack my-project ## (important hint: don't use a dot in your project name, otherwise it will cause issues with mongodb)
$ cd my-project
$ npm install
# If you chose to use mock server, you need to run remove:mock to change the file structure, otherwise just skip this step
$ npm run remove:mock
# If you chose not to use vue-i18n, you need to run remove:i18n to replace the files with default locale text, otherwise just skip this step
$ npm run remove:i18n
# If you chose to use real backend server, run this script to start an express server
$ npm run server
# If you chose to use mock server, run this script to start a mock server
$ npm run mock
# Open another terminal and cd into my-project
# This runs a frontend dev server
$ npm run client

What's Included

  • vue
  • vue-router
  • vuex
  • vue-i18n
  • vue-resource
  • element-ui
  • express
  • mongoose
  • socket.io
  • mock server

Demo app

* Here is a demo and the demo repo is here
* This is another one

Now the demo apps are generated by ci automatically and pushed to vf-backend|vf-mock branches.

Do not change the password please.

username: admin
password: admin

App structure

├─client               # frontend source folder
│  ├─build             # frontend dev scripts
│  ├─src               # frontend src
│  │  ├─assets
│  │  │  ├─css
│  │  │  ├─fonts
│  │  │  └─images
│  │  ├─components     # vue components
│  │  ├─http           # vue-resource configuration
│  │  ├─locale         # vue-i18n configuration
│  │  ├─router         # vue-router configuration
│  │  ├─socket         # socket.io configuration
│  │  ├─storage        # web storage api
│  │  ├─store          # vuex store
│  │  │  └─modules
│  │  └─view           # app pages
│  │     └─auth
│  └─static            # static folder
├─mock                 # mock server
│  ├─ajax              # ajax mock configs
│  ├─socket            # socket.io mock configs
└─server               # backend server folder
    ├─api              # backend api list
    │  ├─thing
    │  └─user
    ├─auth             # user auth logical
    │  └─local
    ├─components       # server components
    │  └─errors
    ├─config           # server configs, contains express socket.io, etc.
    └─views            # server served pages

Configuration

Most of the configuration is concentrated in the config.js file and most of them have explicit comments. You need to take a look at it first.

Here are some important/frequently-used configurations:

  • frontend.port port that frontend server listens at
  • backend.port port that backend server listen at
  • backend.secrets.session secret for session, important when you deploy your app, make sure it's complex enough
  • backend.mongo.uri change this if your mongodb uri is not matched
  • backend.serverFrontend whether to server the frontend code. If set to true the express server serves the frontend code. Otherwise you may need a http server like nginx to serve frontend code and there is a nginx configuration at nginx.example.conf (default true)

Environment variables

When you deploy your app to you cloud server it's easy to configure youre app with environment variables. Following are supported:

  • APP_port or PORT: set to backend.port
  • APP_HOST or APP_IP or HOST or IP: set to backend.ip
  • MONGODB_URI or MONGOHQ_URI: set to backend.mongo.uri
  • SECRET: set to backend.secrets.session

Notice

The generated app is just a template to build your app system fast. Maybe it can't meet your needs, so you need to do some changes at this issue.

License

Under MIT license

Reference resources

At the end

I am very glad to receive your suggestions and pull request.

vue-fullstack's People

Contributors

cwmp avatar dnl-re avatar erguotou520 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-fullstack's Issues

Issue when doing vue init

Hi

I am trying to use your template by running the vue init command, but I run in to problem when getting to vue-i18n: Need vue-i18n? Yes
vue-cli · Parse error on line 11:
...tive="showConfig">{{$t('header.settings'
-----------------------^
Expecting 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'INVALID'

Sorting is only client side

Nice project so far! I've been working on a project with Element UI and running into the same problem you have here... Although the server side pagination works, the sorting only happens client side. So the sort only uses the current page of data. Most people would expect the sorting to account for all the data, not just the current page. Unfortunately Element UI doesn't seem to provide an easy way to manage this. Maybe there is some way to implement it using a combination of the 'header-click' event and the column 'render-header' function? I might resort to ditching the el-table component altogether because of this.

running npm run client and getting messages

WARNING Compiled with 1 warnings 5:46:10 AM
warning in ./client/src/stored.js
8:23-44 "export 'STORE_KEY_CONFIG_LANG' was not found in './constants'

[HPM] Error occurred while trying to proxy request /socket.io/?EIO=3&transport=polling&t=Lw4xeFx
[HPM] Client disconnected
[HPM] Upgrading to WebSocket
[HPM] Client disconnected

Mac, Sierra, Node 6.11.0

running npm run server fails

[dima@zendoPC tmp]$ vue init erguotou520/vue-fullstack testApp

? Project name testapp
? Project description A vue-fullstack project
? Author Dima <[email protected]>
? Use real backend server or mock server Backend
? Port that backend server listen at development environment 9000
? Port that frontend server listen at development environment 9001
? MongoDB uri, '-dev' will be appended in development, default is local uri 
? Need vue-i18n? Yes

   vue-cli · Generated "testApp".

   To get started:
   
     cd testApp
     npm install
     npm run server
     npm run client

[dima@zendoPC tmp]$ cd testApp/
[dima@zendoPC testApp]$ npm i
npm WARN deprecated [email protected]: This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No repository field.
npm WARN [email protected] scripts['server'] should probably be scripts['start'].
npm WARN [email protected] No license field.
npm WARN The package express is included as both a dev and production dependency.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 1066 packages in 22.453s
[dima@zendoPC testApp]$ npm run server

> [email protected] server /home/dima/tmp/testApp
> nodemon --watch server server/app.js

[nodemon] 1.12.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: /home/dima/tmp/testApp/server/**/*
[nodemon] starting `node server/app.js`
(node:25247) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `connect()` or `createConnection()`. See http://mongoosejs.com/docs/connections.html#use-mongo-client
Express server listening on 9000, in development mode
events.js:182
      throw er; // Unhandled 'error' event
      ^

TypeError: The "digest" argument is required and m`ust not be undefined
    at pbkdf2 (crypto.js:635:11)
    at Object.exports.pbkdf2Sync (crypto.js:628:10)
    at model.encryptPassword (/home/dima/tmp/testApp/server/api/user/user.model.js:139:19)
    at model.<anonymous> (/home/dima/tmp/testApp/server/api/user/user.model.js:27:32)
    at VirtualType.applySetters (/home/dima/tmp/testApp/node_modules/mongoose/lib/virtualtype.js:94:25)
    at model.Document.set (/home/dima/tmp/testApp/node_modules/mongoose/lib/document.js:666:12)
    at model._handleIndex (/home/dima/tmp/testApp/node_modules/mongoose/lib/document.js:597:14)
    at model.Document.set (/home/dima/tmp/testApp/node_modules/mongoose/lib/document.js:557:24)
    at model.Document (/home/dima/tmp/testApp/node_modules/mongoose/lib/document.js:76:12)
    at model.Model (/home/dima/tmp/testApp/node_modules/mongoose/lib/model.js:48:12)
    at new model (/home/dima/tmp/testApp/node_modules/mongoose/lib/model.js:3707:13)
    at /home/dima/tmp/testApp/node_modules/mongoose/lib/model.js:1951:51
    at /home/dima/tmp/testApp/node_modules/mongoose/node_modules/async/internal/parallel.js:27:9
    at eachOfArrayLike (/home/dima/tmp/testApp/node_modules/mongoose/node_modules/async/eachOf.js:57:9)
    at exports.default (/home/dima/tmp/testApp/node_modules/mongoose/node_modules/async/eachOf.js:9:5)
    at _parallel (/home/dima/tmp/testApp/node_modules/mongoose/node_modules/async/internal/parallel.js:26:5)
[nodemon] app crashed - waiting for file changes before starting...
^C[dima@zendoPC testApp]$ node -v
v8.2.1
[dima@zendoPC testApp]$ npm -v
5.3.0

新手,打扰问一下

client/build/webpack.base.conf.js 里面的两个 fallback 中的 node_modules 路径

是这样

fallback: [path.join(__dirname, '../node_modules')]

还是

fallback: [path.join(__dirname, '../../node_modules')]

Clean install, npm run dev fails

I just installed the cli
run mongo, then executed npm run dev (or npm run server, it's the same)

the client gives me this:

[nodemon] starting `node server/app.js`
(node:14160) DeprecationWarning: `open()` is deprecated in mongoose >= 4.11.0, use `openUri()` instead, or set the `useMongoClient` option if using `conn
ect()` or `createConnection()`. See http://mongoosejs.com/docs/connections.html#use-mongo-client
Express server listening on 9000, in development mode
events.js:182
      throw er; // Unhandled 'error' event
      ^

TypeError: The "digest" argument is required and must not be undefined
    at pbkdf2 (crypto.js:635:11)
    at Object.exports.pbkdf2Sync (crypto.js:628:10)
    at model.encryptPassword (C:\Users\pietro.caruso\Documents\projects\my-vue-project\server\api\user\user.model.js:139:19)
    at model.<anonymous> (C:\Users\pietro.caruso\Documents\projects\my-vue-project\server\api\user\user.model.js:27:32)
    at VirtualType.applySetters (C:\Users\pietro.caruso\Documents\projects\my-vue-project\node_modules\mongoose\lib\virtualtype.js:94:25)
    at model.Document.set (C:\Users\pietro.caruso\Documents\projects\my-vue-project\node_modules\mongoose\lib\document.js:660:12)
    at model._handleIndex (C:\Users\pietro.caruso\Documents\projects\my-vue-project\node_modules\mongoose\lib\document.js:591:14)
    at model.Document.set (C:\Users\pietro.caruso\Documents\projects\my-vue-project\node_modules\mongoose\lib\document.js:551:24)
    at model.Document (C:\Users\pietro.caruso\Documents\projects\my-vue-project\node_modules\mongoose\lib\document.js:71:12)
    at model.Model (C:\Users\pietro.caruso\Documents\projects\my-vue-project\node_modules\mongoose\lib\model.js:46:12)
    at new model (C:\Users\pietro.caruso\Documents\projects\my-vue-project\node_modules\mongoose\lib\model.js:3666:13)
    at C:\Users\pietro.caruso\Documents\projects\my-vue-project\node_modules\mongoose\lib\model.js:1936:51
    at C:\Users\pietro.caruso\Documents\projects\my-vue-project\node_modules\mongoose\node_modules\async\internal\parallel.js:27:9
    at eachOfArrayLike (C:\Users\pietro.caruso\Documents\projects\my-vue-project\node_modules\mongoose\node_modules\async\eachOf.js:57:9)
    at exports.default (C:\Users\pietro.caruso\Documents\projects\my-vue-project\node_modules\mongoose\node_modules\async\eachOf.js:9:5)
    at _parallel (C:\Users\pietro.caruso\Documents\projects\my-vue-project\node_modules\mongoose\node_modules\async\internal\parallel.js:26:5)
[nodemon] app crashed - waiting for file changes before starting...

got error at install

$ vue init erguotou520/vue-fullstack vue-fullstack-demo
? Port that backend server listen at development environment 9000
? Port that frontend server listen at development environment 9001
? MongoDB uri, '-dev' will append to the uri in development localhost
? Need vue-i18n? Yes
   vue-cli · Parse error on line 11:
...tive="showConfig">{{$t('header.settings'
-----------------------^
Expecting 'ID', 'STRING', 'NUMBER', 'BOOLEAN', 'UNDEFINED', 'NULL', 'DATA', got 'INVALID'

npm install fails

Hi

Following instructions from README, but npm install fails.
I have tried both choosing 'yes' and 'no' regarding the 'Need i18n' question. Both time it fails.

  1. vue init erguotou520/vue-fullstack myProject
  2. cd myProject
  3. npm install

It also complains about the crypto version selected is no longer supported.

For security, I have replaced my user as 'Me' and my project to myProject..

..Me$ npm install
npm WARN deprecated [email protected]: This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.
npm WARN [email protected] No repository field.
npm WARN [email protected] scripts['server'] should probably be scripts['start'].
npm WARN [email protected] No license field.
npm WARN The package express is included as both a dev and production dependency.

npm ERR! path /Users/Me/dev/myProject/node_modules/js-beautify/js/bin/css-beautify.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod '/Users/Me/dev/myProject/node_modules/js-beautify/js/bin/css-beautify.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

It all seems blank with no errors

Both client and servers are running but the page displays nothing but blank.

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>venomjs</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="renderer" content="webkit">
    <link href="/static/favicon.ico" rel="shortcut icon" type="image/x-icon" />
  </head>
  <body>
    <app></app>
    <!-- built files will be auto injected -->
  <script type="text/javascript" src="/app.js"></script></body>
</html>

Demo Page Login fails

Demo Page Login fails when using credentials: admin/admin:

message.error
login.authFail

vue.runtime.common.js:435 TypeError: Cannot set property 'isRootInsert' of undefined

vue.runtime.common.js:435 TypeError: Cannot set property 'isRootInsert' of undefined
at createElm (vue.runtime.common.js:4057)
at createChildren (vue.runtime.common.js:4166)
at createElm (vue.runtime.common.js:4091)
at createChildren (vue.runtime.common.js:4166)
at createElm (vue.runtime.common.js:4091)
at VueComponent.patch [as patch] (vue.runtime.common.js:4509)
at VueComponent.Vue._update (vue.runtime.common.js:2483)
at VueComponent. (vue.runtime.common.js:2457)
at Watcher.get (vue.runtime.common.js:1661)
at new Watcher (vue.runtime.common.js:1653)

It also fails with i18n and mock server option

> node build/dev-server.js

module.js:472
    throw err;
    ^

Error: Cannot find module '/Users/rajanchandi/WebstormProjects/venomjs/build/dev-server.js'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:427:7)
    at startup (bootstrap_node.js:151:9)
    at bootstrap_node.js:542:3

npm ERR! Darwin 16.4.0
npm ERR! argv "/usr/local/Cellar/node/7.10.0/bin/node" "/usr/local/bin/npm" "run" "client"
npm ERR! node v7.10.0
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] client: `node build/dev-server.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] client script 'node build/dev-server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the venomjs package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node build/dev-server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs venomjs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls venomjs
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/rajanchandi/.npm/_logs/2017-05-23T10_28_45_840Z-debug.log

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.