This repository has been archived by the owner on Jan 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 131
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Format source to comply with JavaScript Standard Style
Starter kit supposedly based coding standards on the "JavaScript Standard Style" (https://standardjs.com), but there were several rules in the `.eslintrc.json` configuration that rather defeated the purpose; if you're going to follow a style guide, *especially* for a tool used as a basis for other people's, often beginners', projects, having standard-compliant formatting is a practical necessity.
- Loading branch information
Showing
29 changed files
with
429 additions
and
440 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,3 +40,4 @@ jspm_packages | |
|
||
# Optional REPL history | ||
.node_repl_history | ||
yarn.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
import { | ||
loginAPI, | ||
setLocalToken, | ||
resetLocalToken | ||
loginAPI, | ||
setLocalToken, | ||
resetLocalToken | ||
} from 'api/AuthSvc' | ||
import {resultOK} from 'api/utils' | ||
import { resultOK } from 'api/utils' | ||
|
||
export const LOGIN_AUTH_SUCCESS = 'LOGIN_AUTH_SUCCESS' | ||
export const LOGIN_AUTH_FAIL = 'LOGIN_AUTH_FAIL' | ||
|
||
export const LOGOUT_AUTH_SUCCESS = 'LOGOUT_AUTH_SUCCESS' | ||
|
||
export function LOGIN_AUTH (data) { | ||
return async() => { | ||
let result = await loginAPI(data) | ||
if (!resultOK(result)) { | ||
return {type: LOGIN_AUTH_FAIL, error: result.data} | ||
} | ||
setLocalToken(result.token) | ||
return {type: LOGIN_AUTH_SUCCESS, result: result.data} | ||
} | ||
return async () => { | ||
let result = await loginAPI(data) | ||
if (!resultOK(result)) { | ||
return { type: LOGIN_AUTH_FAIL, error: result.data } | ||
} | ||
setLocalToken(result.token) | ||
return { type: LOGIN_AUTH_SUCCESS, result: result.data } | ||
} | ||
} | ||
|
||
export function LOGOUT_AUTH () { | ||
resetLocalToken() | ||
return {type: LOGOUT_AUTH_SUCCESS} | ||
resetLocalToken() | ||
return { type: LOGOUT_AUTH_SUCCESS } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import {getStatisticsAPI} from 'api/StatisticsSvc' | ||
import {resultOK} from 'api/utils' | ||
import { getStatisticsAPI } from 'api/StatisticsSvc' | ||
import { resultOK } from 'api/utils' | ||
|
||
// define action types | ||
export const GET_STATISTICS_SUCCESS = 'GET_STATISTICS_SUCCESS' | ||
export const GET_STATISTICS_FAIL = 'GET_STATISTICS_FAIL' | ||
|
||
export const GET_STATISTICS = async() => { | ||
let result = await getStatisticsAPI() | ||
if (!resultOK(result)) { | ||
return {type: GET_STATISTICS_FAIL, error: result.data} | ||
} | ||
return {type: GET_STATISTICS_SUCCESS, result: result.data} | ||
export const GET_STATISTICS = async () => { | ||
let result = await getStatisticsAPI() | ||
if (!resultOK(result)) { | ||
return { type: GET_STATISTICS_FAIL, error: result.data } | ||
} | ||
return { type: GET_STATISTICS_SUCCESS, result: result.data } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import {resultOK} from 'api/utils' | ||
import {getInboxAPI} from 'api/InboxSvc' | ||
import { resultOK } from 'api/utils' | ||
import { getInboxAPI } from 'api/InboxSvc' | ||
|
||
// define action types | ||
export const GET_INBOX_SUCCESS = 'GET_INBOX_SUCCESS' | ||
export const GET_INBOX_FAIL = 'GET_INBOX_FAIL' | ||
|
||
export const GET_INBOX = async() => { | ||
let result = await getInboxAPI() | ||
if (!resultOK(result)) { | ||
return {type: GET_INBOX_FAIL, error: result.data} | ||
} | ||
return {type: GET_INBOX_SUCCESS, result: result.data} | ||
export const GET_INBOX = async () => { | ||
let result = await getInboxAPI() | ||
if (!resultOK(result)) { | ||
return { type: GET_INBOX_FAIL, error: result.data } | ||
} | ||
return { type: GET_INBOX_SUCCESS, result: result.data } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
import {post} from './utils' | ||
import { post } from './utils' | ||
import * as store from 'store2' | ||
|
||
export function getLocalToken () { | ||
return store.get('auth_token') | ||
return store.get('auth_token') | ||
} | ||
|
||
export function resetLocalToken () { | ||
store.remove('auth_token') | ||
store.remove('auth_token') | ||
} | ||
export function setLocalToken (token) { | ||
store.set('auth_token', token) | ||
store.set('auth_token', token) | ||
} | ||
|
||
export function isLoggedIn () { | ||
return getLocalToken() !== null | ||
return getLocalToken() !== null | ||
} | ||
|
||
export async function loginAPI (data) { | ||
if (process.env.BUILD_DEMO) { | ||
return { | ||
ok: true, | ||
token: 'Just_for_demo' | ||
} | ||
} | ||
return post('/auth', data) | ||
if (process.env.BUILD_DEMO) { | ||
return { | ||
ok: true, | ||
token: 'Just_for_demo' | ||
} | ||
} | ||
return post('/auth', data) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import {get} from './utils' | ||
|
||
export async function getInboxAPI () { | ||
return get('https://jsonplaceholder.typicode.com/users') | ||
return get('https://jsonplaceholder.typicode.com/users') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import {get} from './utils' | ||
|
||
export async function getStatisticsAPI () { | ||
return get('https://jsonplaceholder.typicode.com/posts?userId=1') | ||
return get('https://jsonplaceholder.typicode.com/posts?userId=1') | ||
} |
Oops, something went wrong.