Migrate all the things
* Migrates from Mongo to Postgres. * Migrates from JSPM to Webpack. * Migrates from React to Vuejs. * Migrates from Bootstrap to Bulma. Also: * Fixes rendering of meta data in the document head tag.
This commit is contained in:
parent
09706778d9
commit
7bb0497ff4
76 changed files with 6741 additions and 1760 deletions
14
public/src/store/api.js
Normal file
14
public/src/store/api.js
Normal file
|
@ -0,0 +1,14 @@
|
|||
import request from 'superagent';
|
||||
import 'superagent-bluebird-promise';
|
||||
|
||||
export function fetchItem(service, type, id) {
|
||||
return request.get(`/${service}/${type}/${id}.json`);
|
||||
}
|
||||
|
||||
export function fetchRecents() {
|
||||
return request.get('/recent');
|
||||
}
|
||||
|
||||
export function musicSearch(url) {
|
||||
return request.post('/search').send({ url });
|
||||
}
|
37
public/src/store/index.js
Normal file
37
public/src/store/index.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
import Vue from 'vue';
|
||||
import Vuex from 'vuex';
|
||||
import { fetchItem, fetchRecents } from './api';
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
const store = new Vuex.Store({
|
||||
debug: true,
|
||||
state: {
|
||||
recents: [],
|
||||
item: {},
|
||||
services: [],
|
||||
},
|
||||
|
||||
actions: {
|
||||
// ensure data for rendering given list type
|
||||
FETCH_RECENTS: ({ commit }) => fetchRecents()
|
||||
.then(res => commit('SET_RECENTS', { recents: res.body.recents })),
|
||||
|
||||
FETCH_ITEM: ({ commit, state }, { service, type, id }) => fetchItem(service, type, id)
|
||||
.then(item => {
|
||||
return commit('SET_ITEM', { item })
|
||||
}),
|
||||
},
|
||||
|
||||
mutations: {
|
||||
SET_RECENTS: (state, { recents }) => {
|
||||
state.recents = recents; // eslint-disable-line no-param-reassign
|
||||
},
|
||||
|
||||
SET_ITEM: (state, { item }) => {
|
||||
state.item = item.body;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export default store;
|
Loading…
Add table
Add a link
Reference in a new issue