begin migration to ts
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
Before Width: | Height: | Size: 2.5 KiB After Width: | Height: | Size: 2.5 KiB |
|
Before Width: | Height: | Size: 281 KiB After Width: | Height: | Size: 281 KiB |
|
Before Width: | Height: | Size: 151 KiB After Width: | Height: | Size: 151 KiB |
|
Before Width: | Height: | Size: 2.4 KiB After Width: | Height: | Size: 2.4 KiB |
|
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
@ -1,7 +0,0 @@
|
||||
import alt from '../alt'
|
||||
|
||||
export default alt.createActions(class DownloadActions {
|
||||
constructor() {
|
||||
this.generateActions('requestDownload')
|
||||
}
|
||||
})
|
||||
@ -1,7 +0,0 @@
|
||||
import alt from '../alt'
|
||||
|
||||
export default alt.createActions(class SupportActions {
|
||||
constructor() {
|
||||
this.generateActions('isChrome', 'noSupport')
|
||||
}
|
||||
})
|
||||
@ -1,7 +0,0 @@
|
||||
import alt from '../alt'
|
||||
|
||||
export default alt.createActions(class UploadActions {
|
||||
constructor() {
|
||||
this.generateActions('uploadFile')
|
||||
}
|
||||
})
|
||||
@ -1,3 +0,0 @@
|
||||
import Alt from 'alt'
|
||||
|
||||
export default new Alt()
|
||||
@ -1,17 +0,0 @@
|
||||
module.exports = function (err, req, res, next) {
|
||||
const status = err.status || 500
|
||||
const message = err.message || ''
|
||||
const stack = process.env.NODE_ENV === 'production' ? null : err.stack || null
|
||||
|
||||
req.url = '/error'
|
||||
res.status(status)
|
||||
res.locals.data = {
|
||||
ErrorStore: {
|
||||
status,
|
||||
message,
|
||||
stack,
|
||||
},
|
||||
}
|
||||
|
||||
next()
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
const path = require('path')
|
||||
|
||||
const BUNDLE_PATH = path.resolve(__dirname, '../../dist/bundle.js')
|
||||
if (process.env.NODE_ENV === 'production') {
|
||||
module.exports = function (req, res) {
|
||||
res.sendFile(BUNDLE_PATH)
|
||||
}
|
||||
} else {
|
||||
const webpackMiddleware = require('webpack-dev-middleware')
|
||||
const webpack = require('webpack')
|
||||
const config = require('../../webpack.config.js')
|
||||
|
||||
config.output.filename = '/app.js'
|
||||
config.output.path = '/'
|
||||
|
||||
module.exports = webpackMiddleware(webpack(config))
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
const React = require('react')
|
||||
const ReactRouter = require('react-router')
|
||||
const alt = require('../alt')
|
||||
const routes = require('../routes')
|
||||
|
||||
function isNotFound(state) {
|
||||
for (const r of state.routes) {
|
||||
if (r.isNotFound) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
module.exports = function (req, res) {
|
||||
alt.bootstrap(JSON.stringify(res.locals.data || {}))
|
||||
|
||||
ReactRouter.run(routes, req.url, (Handler, state) => {
|
||||
const html = React.renderToString(<Handler data={alt.takeSnapshot()} />)
|
||||
alt.flush()
|
||||
|
||||
res.setHeader('Content-Type', 'text/html')
|
||||
if (isNotFound(state)) {
|
||||
res.status(404)
|
||||
}
|
||||
res.write('<!DOCTYPE html>\n')
|
||||
res.end(html)
|
||||
})
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
const path = require('path')
|
||||
const express = require('express')
|
||||
|
||||
const STATIC_PATH = path.resolve(__dirname, '../static')
|
||||
|
||||
module.exports = express.static(STATIC_PATH)
|
||||
@ -1,16 +0,0 @@
|
||||
import React from 'react'
|
||||
import { Route, DefaultRoute, NotFoundRoute, RouteHandler } from 'react-router'
|
||||
import App from './components/App'
|
||||
import DownloadPage from './components/DownloadPage'
|
||||
import UploadPage from './components/UploadPage'
|
||||
import ErrorPage from './components/ErrorPage'
|
||||
|
||||
export default (
|
||||
<Route handler={App}>
|
||||
<DefaultRoute handler={UploadPage} />
|
||||
<Route name="download" path="/:a/:b/:c/:d" handler={DownloadPage} />
|
||||
<Route name="download-short" path="/download/:a" handler={DownloadPage} />
|
||||
<Route name="error" path="error" handler={ErrorPage} />
|
||||
<NotFoundRoute handler={ErrorPage} />
|
||||
</Route>
|
||||
)
|
||||