This file contains hidden or 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
import sirv from 'sirv'; | |
import polka from 'polka'; | |
import compression from 'compression'; | |
import { createProxyMiddleware } from 'http-proxy-middleware'; | |
import * as sapper from '@sapper/server'; | |
const { PORT, NODE_ENV } = process.env; | |
const dev = NODE_ENV === 'development'; | |
const server = polka(); |
This file contains hidden or 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
export default file => { | |
const fileReader = new FileReader(); | |
return new Promise((resolve, reject) => { | |
fileReader.onerror = () => { | |
fileReader.abort(); | |
reject(new Error('Problem parsing file')); | |
}; | |
fileReader.onload = () => { |
This file contains hidden or 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
import fileSaver from 'utils/fileSaver'; | |
import fileReader from 'utils/fileReader'; | |
import { downloadFileRequest } from './api'; | |
import * as types from './actionTypes'; | |
export const downloadFile = id => async dispatch => { | |
try { | |
dispatch({ | |
type: types.DOWNLOAD_FILE_REQUEST, | |
}); |
This file contains hidden or 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
import FileSaver from 'file-saver'; | |
export default (fileData, fileName) => FileSaver.saveAs(fileData, fileName); |
This file contains hidden or 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
import fileSaver from 'utils/fileSaver'; | |
import { downloadFileRequest } from './api'; | |
import * as types from './actionTypes'; | |
export const downloadFile = id => async dispatch => { | |
try { | |
dispatch({ | |
type: types.DOWNLOAD_FILE_REQUEST, | |
}); |
This file contains hidden or 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
import request from 'utils/request'; | |
export const downloadFileRequest = id => | |
request.get(`/files/${id}`, { | |
responseType: 'blob', | |
timeout: 30000, | |
}); |
This file contains hidden or 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
import { uploadFileRequest } from './api'; | |
import * as types from './actionTypes'; | |
export const uploadFile = data => async dispatch => { | |
try { | |
dispatch({ | |
type: types.UPLOAD_FILE_REQUEST, | |
}); | |
await uploadFileRequest(data); |
This file contains hidden or 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
import axios from 'axios'; | |
export default axios.create({ | |
baseURL: 'https://myDomain.com/api/', | |
timeout: 10000, | |
}); |
This file contains hidden or 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
import request from 'utils/request'; | |
export const uploadFileRequest = ({ file }) => { | |
const data = new FormData(); | |
data.append('file', file, file.name); | |
return request.post(`/files`, data, { | |
headers: { | |
'Content-Type': `multipart/form-data; boundary=${data._boundary}`, | |
}, |
This file contains hidden or 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
import React from 'react'; | |
const renderItemsText = items => ( | |
items.length > 0 ? <p>Print sth since we have some items in our list</p> : null | |
); | |
export default ({ items }) => ( | |
<div> | |
{renderItemsText(items)} | |
</div> |
NewerOlder