Skip to content

Commit

Permalink
Merge branch 'release/1.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
vedovelli committed Dec 15, 2016
2 parents 2beb0bb + 7d47017 commit bdb38c2
Show file tree
Hide file tree
Showing 82 changed files with 2,538 additions and 1,104 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ npm-debug.log

.vscode/launch.json
.idea

client/npm-debug.log.1734035463
11 changes: 11 additions & 0 deletions .styleci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
preset: laravel

finder:
exclude:
- tests
- views

not-name:
- index.php
- server.php
- AuthServiceProvider.php
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
language: php

php:
- 5.6
- 7.0
- 7.1

# This triggers builds to run on the new TravisCI infrastructure.
# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/
sudo: false

## Cache composer for faster builds
cache:
directories:
- $HOME/.composer/cache

before_script:
- cd ./webservice
- cp .env.travis .env
- travis_retry composer self-update
- travis_retry composer update --no-interaction --prefer-dist
- php artisan key:gen
- php artisan jwt:secret -f

script:
- vendor/bin/phpunit
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Codecast's Single Page Application Starter Kit

[![Build Status](https://travis-ci.org/codecasts/spa-starter-kit.svg?branch=develop)](https://travis-ci.org/codecasts/spa-starter-kit)

![Cover](http://vedovelli.com.br/spas.png)

> A **highly opinionated** Single Page Application starter kit built on top of Vue.js and Laravel.
Expand All @@ -25,7 +27,7 @@ The live demo can be found in [https://spa.codecasts.rocks/](https://spa.codecas
* Pagination integrated with [Laravel's LengthAwarePaginator](https://laravel.com/docs/5.3/pagination#converting-results-to-json)
* Alerts and Confirmation Alerts provided by [SweetAlert](http://t4t5.github.io/sweetalert/)
2. Server side
* Laravel 5.3
* [Laravel 5.3](https://github.com/laravel/laravel/tree/v5.3.16)
* Authentication with JWT
* [Fractal](http://fractal.thephpleague.com/)
* Web service RESTful with Dingo *(planned)*
Expand Down Expand Up @@ -95,15 +97,15 @@ $ composer test
## Contributing

1. Fork it!
2. Create your feature branch from **develop**: `git checkout -b my-new-feature`
2. Create your feature branch from **develop**: `git checkout -b feature/my-new-feature`
3. Write your code. Comment your code.
4. Commit your changes: `git commit -am 'Add some feature'`
5. Push to the branch: `git push origin my-new-feature`
5. Push to the branch: `git push origin feature/my-new-feature`
6. Submit a pull request to **develop** branch :D

## Credits

[Fábio Vedovelli](https://github.com/vedovelli)
[Fábio Vedovelli](https://github.com/vedovelli) and dedicated [contributors](https://github.com/codecasts/spa-starter-kit/graphs/contributors).

## License

Expand Down
1 change: 1 addition & 0 deletions client/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module.exports = {
},
// add your custom rules here
'rules': {
'import/no-unresolved': [2, { ignore: ['^plugins\/.*', '^utils\/.*'] }],
// don't require .vue extension when importing
'import/extensions': ['error', 'always', {
'js': 'never',
Expand Down
2 changes: 2 additions & 0 deletions client/build/webpack.base.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ module.exports = {
fallback: [path.join(__dirname, '../node_modules')],
alias: {
'src': path.resolve(__dirname, '../src'),
'plugins': path.resolve(__dirname, '../src/plugins'),
'utils': path.resolve(__dirname, '../src/utils'),
'assets': path.resolve(__dirname, '../src/assets'),
'components': path.resolve(__dirname, '../src/components')
}
Expand Down
2 changes: 1 addition & 1 deletion client/config/dev.env.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ var prodEnv = require('./prod.env')
module.exports = merge(prodEnv, {
NODE_ENV: '"development"',
API_URL: '"http://localhost:8000/api"',
VERSION: '"1.0.2"',
VERSION: '"1.0.3"',
})
2 changes: 1 addition & 1 deletion client/config/prod.env.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
NODE_ENV: '"production"',
API_URL: '"https://spa.vedcasts.com.br/api"',
VERSION: '"1.0.2"',
VERSION: '"1.0.3"',
}
1 change: 1 addition & 0 deletions client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="utf-8">
<title>Codecasts.com.br - SPA - Starter Kit</title>
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-default/index.css">
</head>
<body>
<a href="https://github.com/codecasts/spa-starter-kit"><img style="position: absolute; top: 0; left: 0; border: 0; z-index: 2;" src="https://github.com/camo/121cd7cbdc3e4855075ea8b558508b91ac463ac2/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f6c6566745f677265656e5f3030373230302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_left_green_007200.png"></a>
Expand Down
6 changes: 4 additions & 2 deletions client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codecasts-spa-starter-kit",
"version": "1.0.0",
"version": "1.0.3",
"description": "Client for Codecast's SPA Starter Kit",
"author": "Fabio Vedovelli <vedovelli@gmail.com>",
"private": true,
Expand All @@ -15,13 +15,15 @@
"dependencies": {
"axios": "^0.15.2",
"bootstrap-sass": "^3.3.7",
"element-ui": "^1.0.7",
"font-awesome": "^4.7.0",
"jquery": "^3.1.1",
"lodash": "^4.17.2",
"sweetalert": "^1.1.3",
"vue": "^2.0.1",
"vue-router": "^2.0.1",
"vuex": "^2.0.0"
"vuex": "^2.0.0",
"vuex-router-sync": "^3.0.0"
},
"devDependencies": {
"autoprefixer": "^6.4.0",
Expand Down
5 changes: 2 additions & 3 deletions client/src/Root.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import { mapGetters } from 'vuex'
import CcNavBar from './components/root/navbar'
import CcAlerts from './components/general/alerts'
Expand All @@ -9,9 +10,7 @@ export default {
CcAlerts,
},
computed: {
shouldShowNavigation() {
return this.$route.name !== 'login.index'
},
...mapGetters(['shouldShowNavigation']),
},
}
</script>
Expand Down
55 changes: 55 additions & 0 deletions client/src/app/auth/components/forms/singin.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<script>
import { mapActions } from 'vuex'
export default {
/**
* Component's local state
*/
data() {
return {
email: 'happy.developer@vuejsisawesome.com',
password: '123456',
}
},
methods: {
/**
* Map the actions from Vuex to this component.
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator
*/
...mapActions(['attemptLogin', 'setMessage']),
/**
* Handle form's submit event
*/
submit() {
const { email, password } = this // http://wesbos.com/destructuring-objects/
this.attemptLogin({ email, password }) // this is a Vuex action
.then(() => {
this.setMessage({ type: 'error', message: [] }) // this is a Vuex action
this.$router.push({ name: 'dashboard.index' })
})
},
/**
* Reset component's local state
*/
reset() {
this.email = ''
this.password = ''
},
},
}
</script>

<template>
<form class="well" @submit.prevent="submit">
<div class="form-group">
<label for="email" class="control-label">E-mail</label>
<input type="email" class="form-control" id="email" v-model="email">
</div>
<div class="form-group">
<label for="password" class="control-label">Password</label>
<input type="password" class="form-control" id="password" v-model="password">
</div>
<button class="btn btn-primary btn-block" type="submit">Login</button>
</form>
</template>
11 changes: 11 additions & 0 deletions client/src/app/auth/components/forms/singup.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<template>
<div class="well">
<h3>Sing up</h3>
<h4>Comming soon</h4>
</div>
</template>

<script>
export default {
}
</script>
31 changes: 31 additions & 0 deletions client/src/app/auth/components/main.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<template>
<div class="container">
<header class="page-header">
<h3>Codecasts - SPA - Starter Kit</h3>
</header>
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-3">
<ul class="nav nav-pills nav-stacked">
<router-link tag="li" :to="{ name: 'auth.singin' }">
<a>Sing in</a>
</router-link>
<router-link tag="li" :to="{ name: 'auth.singup' }">
<a>Sing up</a>
</router-link>
</ul>
</div>
<div class="col-md-4">
<router-view></router-view>
</div>
</div>
</div>
</template>

<script>
export default {
}
</script>

<style lang="css">
</style>
3 changes: 3 additions & 0 deletions client/src/app/auth/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export
export { default as routes } from './routes'
export { default as vuex } from './vuex'
8 changes: 8 additions & 0 deletions client/src/app/auth/routes/components.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Components are lazy-loaded - See "Grouping Components in the Same Chunk"
* http://router.vuejs.org/en/advanced/lazy-loading.html
*/
/* eslint-disable global-require */
export const Main = r => require.ensure([], () => r(require('../components/main')), 'auth-bundle')
export const Singin = r => require.ensure([], () => r(require('../components/forms/singin')), 'auth-bundle')
export const Singup = r => require.ensure([], () => r(require('../components/forms/singup')), 'auth-bundle')
22 changes: 22 additions & 0 deletions client/src/app/auth/routes/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { Singup, Singin, Main } from './components'

const children = [{
name: 'auth.singin',
path: 'singin',
component: Singin,
meta: { requiresAuth: false },
}, {
name: 'auth.singup',
path: 'singup',
component: Singup,
meta: { requiresAuth: false },
}]

export default [{
children,
name: 'auth',
path: '/auth',
component: Main,
redirect: { name: 'auth.singin' },
meta: { requiresAuth: false },
}]
58 changes: 58 additions & 0 deletions client/src/app/auth/vuex/actions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// plugins and utils are alias. see client/build/webpack.base.conf.js
// import http client
import { http, setToken as httpSetToken } from 'plugins/http'
import { isEmpty } from 'lodash'
import { getData } from 'utils/get'
import * as TYPES from './mutations-types'

export const attemptLogin = ({ dispatch }, { email, password }) => http.post('/auth/token/issue', { email, password })
/**
* functional approach, more readable and generate minus code
* examples:
* PromiseObject.then(response => response.data)
* PromiseObject.then({ data } => data)
*
* We do this many times in many locations.
* We know that .then accepts a function and what arguments it receives
* This is because in JavaScript functions are first class citizens.
* In summary we can pass functions as arguments and also receive functions as results
* (first-class function and higher-order function)
*/
.then(getData) // .then(response => getData(response))
.then(({ token, user }) => {
dispatch('setUser', user)
dispatch('setToken', token)

return user // keep promise chain
})

export const logout = ({ dispatch }) => {
http.post('/auth/token/revoke')
// call actions
return Promise.all([
dispatch('setToken', null),
dispatch('setUser', {}),
])
}

export const setUser = ({ commit }, user) => {
// Commit the mutations
commit(TYPES.SET_USER, user)

Promise.resolve(user) // keep promise chain
}

export const setToken = ({ commit }, payload) => {
// prevent if payload is a object
const token = (isEmpty(payload)) ? null : payload.token || payload

/**
* Set the Axios Authorization header with the token
*/
httpSetToken(token)

// Commit the mutations
commit(TYPES.SET_TOKEN, token)

return Promise.resolve(token) // keep promise chain
}
7 changes: 7 additions & 0 deletions client/src/app/auth/vuex/getters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// http://vuex.vuejs.org/en/getters.html
import { isEmpty } from 'lodash'

// if has token, we assume that user is logged in our system
export const isLogged = ({ token }) => !isEmpty(token)
// get current user data
export const currentUser = ({ user }) => user
10 changes: 10 additions & 0 deletions client/src/app/auth/vuex/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import
import state from './state'
import mutations from './mutations'
import plugin from './plugin'
import * as actions from './actions'
import * as getters from './getters'

const module = { state, mutations, actions, getters }

export default { module, plugin }
3 changes: 3 additions & 0 deletions client/src/app/auth/vuex/mutations-types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// http://vuex.vuejs.org/en/mutations.html#using-constants-for-mutation-types
export const SET_TOKEN = 'Auth//SET_TOKEN'
export const SET_USER = 'Auth//SET_USER'
12 changes: 12 additions & 0 deletions client/src/app/auth/vuex/mutations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// https://vuex.vuejs.org/en/mutations.html
import * as TYPES from './mutations-types'

/* eslint-disable no-param-reassign */
export default {
[TYPES.SET_TOKEN](state, value) {
state.token = value
},
[TYPES.SET_USER](state, value) {
state.user = value
},
}
Loading

0 comments on commit bdb38c2

Please sign in to comment.