we-voting
we-voting copied to clipboard
:raising_hand: A Voting App based on React + Express + Mongodb
WeVoting
A voting APP.
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
it clone https://github.com/elevenbeans/we-voting.git d we-voting -
Install local dependencies
pm 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/
- router:
-
list page
- router:
/list(/:name) - example:
https://we-voting-ele.herokuapp.com/list
- router:
-
detail page
- router:
/detail(/:id) - example:
https://we-voting-ele.herokuapp.com/detail/1494908221812
- router:
-
new page
- router:
/new - example:
https://we-voting-ele.herokuapp.com/new
- router:
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