From 60aea54f6f1289923effbaa4627b15b0504b7232 Mon Sep 17 00:00:00 2001 From: Alex Kern Date: Sun, 20 Sep 2020 17:53:16 -0700 Subject: [PATCH] begin migration to ts --- docker-compose.yaml => docker-compose.yml | 0 {src/static => public}/favicon.ico | Bin {src/static => public}/fonts/LobsterTwo.woff2 | Bin .../fonts/QuicksandBold.woff2 | Bin .../fonts/QuicksandLight.woff2 | Bin .../fonts/QuicksandNormal.woff2 | Bin {src/static => public}/fonts/fonts.css | 0 {src/static => public}/images/down.png | Bin {src/static => public}/images/fb.png | Bin {src/static => public}/images/pizza.png | Bin {src/static => public}/images/up.png | Bin {src/static => public}/images/wordmark.png | Bin {src/static => public}/robots.txt | 0 src/actions/DownloadActions.js | 7 ---- src/actions/SupportActions.js | 7 ---- src/actions/UploadActions.js | 7 ---- src/alt.js | 3 -- src/{middleware/bootstrap.js => bootstrap.ts} | 0 src/{client.js => client.ts} | 0 src/components/{App.js => App.tsx} | 0 .../{Bootstrap.js => Bootstrap.tsx} | 0 .../{ChromeNotice.js => ChromeNotice.tsx} | 0 .../{DownloadButton.js => DownloadButton.tsx} | 0 .../{DownloadPage.js => DownloadPage.tsx} | 0 src/components/{DropZone.js => DropZone.tsx} | 0 .../{ErrorPage.js => ErrorPage.tsx} | 0 .../{ProgressBar.js => ProgressBar.tsx} | 0 src/components/{Spinner.js => Spinner.tsx} | 0 .../{Tempalink.js => Tempalink.tsx} | 0 .../{UploadPage.js => UploadPage.tsx} | 0 src/components/{Uploader.js => Uploader.tsx} | 0 .../components}/WebRTCProvider.tsx | 0 src/{db.js => db.ts} | 0 src/{index.js => index.ts} | 0 src/middleware/error.js | 17 ---------- src/middleware/javascript.js | 17 ---------- src/middleware/react.js | 30 ------------------ src/middleware/static.js | 6 ---- {pages => src/pages}/download/[...slug].tsx | 0 {pages => src/pages}/index.tsx | 0 src/routes.js | 16 ---------- src/{server.js => server.ts} | 0 42 files changed, 110 deletions(-) rename docker-compose.yaml => docker-compose.yml (100%) rename {src/static => public}/favicon.ico (100%) rename {src/static => public}/fonts/LobsterTwo.woff2 (100%) rename {src/static => public}/fonts/QuicksandBold.woff2 (100%) rename {src/static => public}/fonts/QuicksandLight.woff2 (100%) rename {src/static => public}/fonts/QuicksandNormal.woff2 (100%) rename {src/static => public}/fonts/fonts.css (100%) rename {src/static => public}/images/down.png (100%) rename {src/static => public}/images/fb.png (100%) rename {src/static => public}/images/pizza.png (100%) rename {src/static => public}/images/up.png (100%) rename {src/static => public}/images/wordmark.png (100%) rename {src/static => public}/robots.txt (100%) delete mode 100644 src/actions/DownloadActions.js delete mode 100644 src/actions/SupportActions.js delete mode 100644 src/actions/UploadActions.js delete mode 100644 src/alt.js rename src/{middleware/bootstrap.js => bootstrap.ts} (100%) rename src/{client.js => client.ts} (100%) rename src/components/{App.js => App.tsx} (100%) rename src/components/{Bootstrap.js => Bootstrap.tsx} (100%) rename src/components/{ChromeNotice.js => ChromeNotice.tsx} (100%) rename src/components/{DownloadButton.js => DownloadButton.tsx} (100%) rename src/components/{DownloadPage.js => DownloadPage.tsx} (100%) rename src/components/{DropZone.js => DropZone.tsx} (100%) rename src/components/{ErrorPage.js => ErrorPage.tsx} (100%) rename src/components/{ProgressBar.js => ProgressBar.tsx} (100%) rename src/components/{Spinner.js => Spinner.tsx} (100%) rename src/components/{Tempalink.js => Tempalink.tsx} (100%) rename src/components/{UploadPage.js => UploadPage.tsx} (100%) rename src/components/{Uploader.js => Uploader.tsx} (100%) rename {components => src/components}/WebRTCProvider.tsx (100%) rename src/{db.js => db.ts} (100%) rename src/{index.js => index.ts} (100%) delete mode 100644 src/middleware/error.js delete mode 100644 src/middleware/javascript.js delete mode 100644 src/middleware/react.js delete mode 100644 src/middleware/static.js rename {pages => src/pages}/download/[...slug].tsx (100%) rename {pages => src/pages}/index.tsx (100%) delete mode 100644 src/routes.js rename src/{server.js => server.ts} (100%) diff --git a/docker-compose.yaml b/docker-compose.yml similarity index 100% rename from docker-compose.yaml rename to docker-compose.yml diff --git a/src/static/favicon.ico b/public/favicon.ico similarity index 100% rename from src/static/favicon.ico rename to public/favicon.ico diff --git a/src/static/fonts/LobsterTwo.woff2 b/public/fonts/LobsterTwo.woff2 similarity index 100% rename from src/static/fonts/LobsterTwo.woff2 rename to public/fonts/LobsterTwo.woff2 diff --git a/src/static/fonts/QuicksandBold.woff2 b/public/fonts/QuicksandBold.woff2 similarity index 100% rename from src/static/fonts/QuicksandBold.woff2 rename to public/fonts/QuicksandBold.woff2 diff --git a/src/static/fonts/QuicksandLight.woff2 b/public/fonts/QuicksandLight.woff2 similarity index 100% rename from src/static/fonts/QuicksandLight.woff2 rename to public/fonts/QuicksandLight.woff2 diff --git a/src/static/fonts/QuicksandNormal.woff2 b/public/fonts/QuicksandNormal.woff2 similarity index 100% rename from src/static/fonts/QuicksandNormal.woff2 rename to public/fonts/QuicksandNormal.woff2 diff --git a/src/static/fonts/fonts.css b/public/fonts/fonts.css similarity index 100% rename from src/static/fonts/fonts.css rename to public/fonts/fonts.css diff --git a/src/static/images/down.png b/public/images/down.png similarity index 100% rename from src/static/images/down.png rename to public/images/down.png diff --git a/src/static/images/fb.png b/public/images/fb.png similarity index 100% rename from src/static/images/fb.png rename to public/images/fb.png diff --git a/src/static/images/pizza.png b/public/images/pizza.png similarity index 100% rename from src/static/images/pizza.png rename to public/images/pizza.png diff --git a/src/static/images/up.png b/public/images/up.png similarity index 100% rename from src/static/images/up.png rename to public/images/up.png diff --git a/src/static/images/wordmark.png b/public/images/wordmark.png similarity index 100% rename from src/static/images/wordmark.png rename to public/images/wordmark.png diff --git a/src/static/robots.txt b/public/robots.txt similarity index 100% rename from src/static/robots.txt rename to public/robots.txt diff --git a/src/actions/DownloadActions.js b/src/actions/DownloadActions.js deleted file mode 100644 index 6d0fe5e..0000000 --- a/src/actions/DownloadActions.js +++ /dev/null @@ -1,7 +0,0 @@ -import alt from '../alt' - -export default alt.createActions(class DownloadActions { - constructor() { - this.generateActions('requestDownload') - } - }) diff --git a/src/actions/SupportActions.js b/src/actions/SupportActions.js deleted file mode 100644 index 9c4e1bd..0000000 --- a/src/actions/SupportActions.js +++ /dev/null @@ -1,7 +0,0 @@ -import alt from '../alt' - -export default alt.createActions(class SupportActions { - constructor() { - this.generateActions('isChrome', 'noSupport') - } - }) diff --git a/src/actions/UploadActions.js b/src/actions/UploadActions.js deleted file mode 100644 index 96a7bb8..0000000 --- a/src/actions/UploadActions.js +++ /dev/null @@ -1,7 +0,0 @@ -import alt from '../alt' - -export default alt.createActions(class UploadActions { - constructor() { - this.generateActions('uploadFile') - } - }) diff --git a/src/alt.js b/src/alt.js deleted file mode 100644 index 714e2eb..0000000 --- a/src/alt.js +++ /dev/null @@ -1,3 +0,0 @@ -import Alt from 'alt' - -export default new Alt() diff --git a/src/middleware/bootstrap.js b/src/bootstrap.ts similarity index 100% rename from src/middleware/bootstrap.js rename to src/bootstrap.ts diff --git a/src/client.js b/src/client.ts similarity index 100% rename from src/client.js rename to src/client.ts diff --git a/src/components/App.js b/src/components/App.tsx similarity index 100% rename from src/components/App.js rename to src/components/App.tsx diff --git a/src/components/Bootstrap.js b/src/components/Bootstrap.tsx similarity index 100% rename from src/components/Bootstrap.js rename to src/components/Bootstrap.tsx diff --git a/src/components/ChromeNotice.js b/src/components/ChromeNotice.tsx similarity index 100% rename from src/components/ChromeNotice.js rename to src/components/ChromeNotice.tsx diff --git a/src/components/DownloadButton.js b/src/components/DownloadButton.tsx similarity index 100% rename from src/components/DownloadButton.js rename to src/components/DownloadButton.tsx diff --git a/src/components/DownloadPage.js b/src/components/DownloadPage.tsx similarity index 100% rename from src/components/DownloadPage.js rename to src/components/DownloadPage.tsx diff --git a/src/components/DropZone.js b/src/components/DropZone.tsx similarity index 100% rename from src/components/DropZone.js rename to src/components/DropZone.tsx diff --git a/src/components/ErrorPage.js b/src/components/ErrorPage.tsx similarity index 100% rename from src/components/ErrorPage.js rename to src/components/ErrorPage.tsx diff --git a/src/components/ProgressBar.js b/src/components/ProgressBar.tsx similarity index 100% rename from src/components/ProgressBar.js rename to src/components/ProgressBar.tsx diff --git a/src/components/Spinner.js b/src/components/Spinner.tsx similarity index 100% rename from src/components/Spinner.js rename to src/components/Spinner.tsx diff --git a/src/components/Tempalink.js b/src/components/Tempalink.tsx similarity index 100% rename from src/components/Tempalink.js rename to src/components/Tempalink.tsx diff --git a/src/components/UploadPage.js b/src/components/UploadPage.tsx similarity index 100% rename from src/components/UploadPage.js rename to src/components/UploadPage.tsx diff --git a/src/components/Uploader.js b/src/components/Uploader.tsx similarity index 100% rename from src/components/Uploader.js rename to src/components/Uploader.tsx diff --git a/components/WebRTCProvider.tsx b/src/components/WebRTCProvider.tsx similarity index 100% rename from components/WebRTCProvider.tsx rename to src/components/WebRTCProvider.tsx diff --git a/src/db.js b/src/db.ts similarity index 100% rename from src/db.js rename to src/db.ts diff --git a/src/index.js b/src/index.ts similarity index 100% rename from src/index.js rename to src/index.ts diff --git a/src/middleware/error.js b/src/middleware/error.js deleted file mode 100644 index e519176..0000000 --- a/src/middleware/error.js +++ /dev/null @@ -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() -} diff --git a/src/middleware/javascript.js b/src/middleware/javascript.js deleted file mode 100644 index 4b0139e..0000000 --- a/src/middleware/javascript.js +++ /dev/null @@ -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)) -} diff --git a/src/middleware/react.js b/src/middleware/react.js deleted file mode 100644 index 230ecce..0000000 --- a/src/middleware/react.js +++ /dev/null @@ -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() - alt.flush() - - res.setHeader('Content-Type', 'text/html') - if (isNotFound(state)) { - res.status(404) - } - res.write('\n') - res.end(html) - }) -} diff --git a/src/middleware/static.js b/src/middleware/static.js deleted file mode 100644 index 15fefdb..0000000 --- a/src/middleware/static.js +++ /dev/null @@ -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) diff --git a/pages/download/[...slug].tsx b/src/pages/download/[...slug].tsx similarity index 100% rename from pages/download/[...slug].tsx rename to src/pages/download/[...slug].tsx diff --git a/pages/index.tsx b/src/pages/index.tsx similarity index 100% rename from pages/index.tsx rename to src/pages/index.tsx diff --git a/src/routes.js b/src/routes.js deleted file mode 100644 index d2fa89a..0000000 --- a/src/routes.js +++ /dev/null @@ -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 ( - - - - - - - -) diff --git a/src/server.js b/src/server.ts similarity index 100% rename from src/server.js rename to src/server.ts