-
Notifications
You must be signed in to change notification settings - Fork 5
Home
VueFire Hackathon Starter is a basic template single page app which provides with minimalistic things to get up a descent and good looking app up and running with features like User module, authentication etc.
This project is based upon webpack-simple
template for Vue.js which in turn is based on vue-loader
that allows writing single file components i.e. HTML, CSS and JavaScript of one component all in a single file. So every *.vue
file you find in the project is an independent Vue.js component.
This starter kit is based on a very common product scenario as follows:
- Any visitor can login in the app using Twitter/Facebook accounts, hence called as user.
- Every user can then create items. An item can be anything such as invoice, notes etc - as long it is storable in firebase. For demo purposes, the starter kit allows user to create notes. Every item has a
title
andnotes
field. These items get stored underitems
key in Firebase and are linked to the created user under theusers
key byuid
. - The concept of item is very basic. It can be shrinked or expanded to any level as per requirements of the product.
- Every user can visit his profile page where he can see his created items. Profile pages can be viewed by anyone, even if not logged in.
-
index.html
- Only HTML file served. Starting point. -
assets
- Images and vendor stylesheets. -
src
- Contains all the source code. All the common shared services, components etc are directly present insidesrc
. Whereas route specific components are present in their corresponding folders. - main.js - Contains bootstrapping and routing configuration and hooks.
-
build-gh-pages
- Builds the project ongh-pages
branches if github is used for deployment.
This is the main component that renders in index.html
first of all. It contains the common header, footer and the routing placeholder element where every route inserts its corresponding component. Most of the common styles can be found here.
This is the component for the home page. Not much to tell here.
Component for the User route, this is the template for user profile page. It can be reached by clicking the avatar in the header after logging in the app. The profile page shows the items created by the user.
This is the component for seeing an Item in read mode.
This is the component for editing an Item.
A shared component to show any item as a small tile in the app. Used in user profile page.
These make up the notification system in the app. NotificationStore.js
is a singleton service that keeps track of the notifications.
Generic modal component used throughout the app for login, help etc.
Service to handle authentication. Use to login, logout or get user details.
Basic service to fetch any item from Firebase.
A new Firebase project has to be created before using this starter kit for actual purposes. Otherwise it keeps using the demo backend. There are primarily 2 things to ensure in your Firebase project:
-
Authentication: Do switch on the Twitter and Facebook authentication for your project. This will require to create app on Twitter and Facebook for your product and then add the app credentials into Firebase console. Read more here.
-
Security rules: Before going public, make sure you have right security rules to provide right access levels on the database. Example rules:
{
"rules": {
".read": true, // Anybody can read anything
"items": {
"$itemId": {
".write": "auth != null && !data.exists() || auth.uid == data.child('createdBy').val()"
}
},
"users": {
"$userId": {
".write": "auth != null && auth.uid == $userId"
}
}
}
}
Webpack is used to build this project. To build the project, run npm run build
. This does 3 things:
- Generates
dist/build.js
which is all the JavaScript along with the templates. - Generates
dist/style.css
which is all the custom CSS in the components. This is done by theExtractTextPlugin
- Hooks up the generates JS and CSS file in
index.html
. Webpack is also configured to cache bust both these resources using a hash as query param on every build. Caveat: Right now bothbuild.js
andstyle.css
are cache busted with the a single hash. Therefore, even if just file changes, both will be fetched over network for the users.
Important: Webpack does the above mentioned modifications of index.html
in the file itself, without making a copy. Therefore its recommended to run your production build on a separate branch so that your original index.html
remains untouched.