first commit

This commit is contained in:
s.golasch
2023-08-01 12:47:58 +02:00
commit b1439a55bb
65 changed files with 3085 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
'use strict'
module.exports = {
RECEIVE_NETWORK: 'RECEIVE_NETWORK',
}

View File

@@ -0,0 +1,12 @@
'use strict'
const {RECEIVE_NETWORK} = require('./action_constants')
module.exports = {
receivedNetwork: network => {
return {
type: RECEIVE_NETWORK,
network,
}
}
}

View File

@@ -0,0 +1,21 @@
'use strict'
const {receivedNetwork} = require('./actions')
module.exports = {
// urls that should be called for the remote actions
urls: {
fetch: 'https://layla.amazon.de/api/phoenix',
discover: 'https://layla.amazon.de/api/phoenix/discovery',
},
// called after an remote http call to the network API has been successfully executed
postHooks: {
// called after the network data has been fetched
fetch: (store, data) => {
return new Promise((resolve, reject) => {
store.dispatch(receivedNetwork(JSON.parse(data.networkDetail)))
resolve(data)
})
}
}
}

View File

@@ -0,0 +1,13 @@
'use strict'
const {RECEIVE_NETWORK} = require('./action_constants')
module.exports = (state = {}, action) => {
switch (action.type) {
case RECEIVE_NETWORK:
return Object.assign({}, state, {
network: action.network
})
default:
return state
}
}

View File

@@ -0,0 +1,7 @@
'use strict'
module.exports = {
'/network': (store, params, cb) => {
res.send(store.getState().network.network)
}
}