Skip to content

Commit

Permalink
Rebase into Nuxt
Browse files Browse the repository at this point in the history
  • Loading branch information
OrcaXS committed Dec 8, 2017
1 parent 77f8321 commit 158c256
Show file tree
Hide file tree
Showing 94 changed files with 2,698 additions and 14,549 deletions.
10 changes: 7 additions & 3 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
indent_style = space
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TIMES=2
21 changes: 12 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,23 @@ module.exports = {
'html'
],
// check if imports actually resolve
'settings': {
settings: {
'import/resolver': {
'webpack': {
'config': 'build/webpack.base.conf.js'
}
}
webpack: 'webpack.config.js',
},
},
// add your custom rules here
'rules': {
'no-unused-vars': 'warn',
'no-trailing-spaces': 'warn',
'no-underscore-dangle': 'off',
'no-param-reassign': ['error', {
props: true,
ignorePropertyModificationsFor: [
'acc', // for reduce accumulators
'e', // for e.returnvalue
'state' // for vuex
]
}],
'comma-dangle': ['warn', 'always-multiline'],
'import/prefer-default-export': 'warn',
'semi': ['error', 'always', { 'omitLastInOneLineBlock': true }],
Expand All @@ -36,9 +41,7 @@ module.exports = {
'vue': 'never'
}],
// allow optionalDependencies
'import/no-extraneous-dependencies': ['error', {
'optionalDependencies': ['test/unit/index.js']
}],
'import/no-extraneous-dependencies': 'off',
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
}
Expand Down
30 changes: 23 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,27 @@
.DS_Store
# dependencies
node_modules

# tests
test/unit/coverage
test/e2e/reports

# others
.tags
.tags_swap
node_modules/
dist/
npm-debug.log*

# logs
npm-debug.log
yarn-debug.log*
yarn-error.log*
test/unit/coverage
test/e2e/reports
selenium-debug.log

# Nuxt build
.nuxt

# Nuxt generate
dist

# config
config.example.js

# Heroku
.env
8 changes: 8 additions & 0 deletions .stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/build/
/config/
/dist/
/node_modules/
{{#unit}}
/test/unit/coverage/
{{/unit}}
html
33 changes: 12 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
# animeloop-server-vue
# animeloop-web-nuxt

> An animeloop server front-end project, based on vue.js
> Nuxt.js project
## Build Setup

``` bash
# install dependencies
yarn install
$ npm install # Or yarn install

# serve with hot reload at localhost:8080
npm run dev
# serve with hot reload at localhost:3000
$ npm run dev

# or
yarn start
# build for production and launch server
$ npm run build
$ npm start

# build for production with minification
npm run build

# build for production and view the bundle analyzer report
npm run build --report

# run unit tests
npm run unit

# run e2e tests
npm run e2e

# run all tests
npm test
# generate static project
$ npm run generate
```

For detailed explanation on how things work, checkout the [Nuxt.js docs](https://github.com/nuxt/nuxt.js).
58 changes: 58 additions & 0 deletions api/fetch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import fetch from 'isomorphic-fetch';
import qs from 'qs';

import { apiPrefix } from '../config';

function encodeFormData(data) {
return Object.entries(data).map(item => (
`${item[0]}=${encodeURIComponent(item[1])}`
)).join('&');
}

/* request proptype: {
* url: '',
* data: {},
* method: 'GET',
* }
*/
async function callApi(request) {
const init = {
method: request.method || 'GET',
headers: {},
};
const hasBody = !((init.method === 'GET') || (init.method === 'HEAD'));

// headers and body
if (hasBody) {
init.headers['content-type'] = 'application/x-www-form-urlencoded';
init.body = encodeFormData(request.data);
}

// url
const url = ((!hasBody) && (request.data))
? `${apiPrefix}${request.url}${qs.stringify(request.data, { addQueryPrefix: true })}`
: `${apiPrefix}${request.url}`;

try {
const res = await fetch(url, init);
const json = await res.json();
console.log(url);
return json;
} catch (error) {
throw error;
}
}

const remote = {
getOneRandomLoop: callApi({ url: 'rand/loop/full' }),
getRandomLoopList: count => callApi({ url: `rand/loop/${count}/full` }),
getLoopByID: id => callApi({ url: `loop/${id}/full` }),
getLoopsByEpisode: id => callApi({ url: 'loop', data: { episode: id } }),
getEpisodeByID: id => callApi({ url: `episode/${id}/full` }),
getEpisodesBySeriesID: id => callApi({ url: 'episode', data: { series: id } }),
getTagsByID: id => callApi({ url: 'tag', data: { loop: id } }),
getSeriesByID: id => callApi({ url: `series/${id}` }),
getSeriesByString: string => callApi({ url: 'search/series', data: { value: string } }),
};

export default remote;
8 changes: 8 additions & 0 deletions assets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# ASSETS

This directory contains your un-compiled assets such as LESS, SASS, or JavaScript.

More information about the usage of this directory in the documentation:
https://nuxtjs.org/guide/assets#webpacked

**This directory is not required, you can delete it if you don't want to use it.**
35 changes: 0 additions & 35 deletions build/build.js

This file was deleted.

48 changes: 0 additions & 48 deletions build/check-versions.js

This file was deleted.

9 changes: 0 additions & 9 deletions build/dev-client.js

This file was deleted.

Loading

0 comments on commit 158c256

Please sign in to comment.