Skip to content

🙋 A Voting App based on React + Express + Mongodb

Notifications You must be signed in to change notification settings

elevenbeans/we-voting

Repository files navigation

WeVoting

Build Status Coverage Status GitHub release PRs Welcome GitHub license

A voting APP.

View Demo online 看 Demo 请戳这里

中文介绍请点击这里 🇨🇳

Function

  • Authenticated users can:

    • create a poll with any number of possible items
    • keep their polls and come back later to access them
    • see the aggregate results of all polls(implemented using Charts)
    • vote on every polls(one time on each poll)
    • share all polls with their friends.
  • Unauthenticated users just can:

    • see the aggregate results of all polls(implemented using Charts)

Doing list

  • Unit test (Doing)
    • Coverage to 6% -- updated 2017-05-22
    • Coverage to 29% -- updated 2017-05-26
    • Coverage to 50% -- updated 2017-06-04
    • Coverage to 73% -- updated 2017-06-13
  • Code formate (Doing)
  • List page data pagination (done by @maokailu)

Contributing

I am grateful to any one for contributing bugfixes, issues and improvements~

Setup

  • Install node.js Ubuntu/Mac , Windows

  • Clone this project

     git clone https://github.com/elevenbeans/we-voting.git
     cd we-voting
    
  • Install local dependencies

     npm install
    

Startup

Development mode

For *nix (including Mac),

Run ./start.sh

Or export NODE_ENV=dev-HMR && ./start.sh (enable HMR).

For windows,

npm run bundle // compile and bundle js files

npm run start // start node server

npm run watch // watching changes

Don't forget to run Mongodb in your dev environment : )

Pre mode

Run export NODE_ENV=pre && ./start.sh.

Production mode

Run export NODE_ENV=production && ./start.sh.

Build

Run npm run build

Test

Mocha + should

Run npm run test.

Or,

Run npm run cover to see test case coverage.

Techstack overview

Server:

  • Enviroment: Node
  • Framework: Express
  • Tools: Request, compression, body-praser
  • Template engine: Ejs
  • DataBase: Mongodb

Front-end:

  • JS standard: ECMAScript 6
  • Framework: React + ReactDOM + React-Router
  • Module bundler and compiler: Webpack + Babel
  • Open source components: react-d3-components

Pages

  • home page

    • router: /
    • example: https://we-voting-ele.herokuapp.com/
  • list page

    • router: /list(/:name)
    • example: https://we-voting-ele.herokuapp.com/list
  • detail page

    • router: /detail(/:id)
    • example: https://we-voting-ele.herokuapp.com/detail/1494908221812
  • new page

    • router: /new
    • example: https://we-voting-ele.herokuapp.com/new

Directories

|-- client // front-end code
  |-- components // front-end components
    |-- footer.jsx // public footer
    |-- header.jsx // public header
    |-- loading.jsx // loading amination
    |-- spning.jsx // spning amination
  |-- lib // front-end library
    |-- utils.jsx
  |-- detail.jsx // detail page
  |-- home.jsx // home page
  |-- index.jsx // front-end intrance
  |-- list.jsx  // list page
  |-- new.jsx // new page
|-- controller // server-end controller
  |-- routes
    |-- login.js // login routes
    |-- view.js // view routes
  |-- api.js // api controller
  |-- DBhandler.js // DataBase CRUD
|-- dist // compiled front-end code
  |-- vendor
    |-- jquery.min.js
    |-- bootstrap.min.js
    |-- bootstrap.min.css
    |-- react-dom.min.js // react-dom production version
    |-- react.min.js // react production version
  |-- loading.css
  |-- vote.bundle.js // bundled voteApp intrance file
  |-- router.bundle.js // bundled react-router
  |-- detail.chunk.js // splitted JS file in detail page
  |-- home.chunk.js // splitted JS file in home page
  |-- list.chunk.js // splitted JS file in list page
  |-- new.chunk.js // splitted JS file in new page
|-- views // server-end views
  |-- error.ejs
  |-- footer.ejs
  |-- header.ejs
  |-- index.ejs
|-- .gitignore
|-- Procfile // heroku file
|-- README.md
|-- index.js // app intrance file
|-- package.json
|-- serverConfig.js // enviroment configuration
|-- start.sh // start file for mac
|-- webpack.config.js

LICENSE

MIT