aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMarvin Borner2019-03-05 13:57:17 +0100
committerMarvin Borner2019-03-05 13:57:17 +0100
commitd961b7a75bf3f0d25339214e1a9535533a25fd36 (patch)
tree8bec8d9c57108b3cbfc8fd612fcce805632cac00 /src
parent32b83c0fca73a83d51f6c6dbe7378a3cdc75703b (diff)
Refactored code structure
Diffstat (limited to 'src')
-rw-r--r--src/index.js53
-rw-r--r--src/routes.js19
-rw-r--r--src/server.js20
3 files changed, 0 insertions, 92 deletions
diff --git a/src/index.js b/src/index.js
deleted file mode 100644
index b27be5d..0000000
--- a/src/index.js
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * index.js
- * Copyright (c) 2019, Texx
- * License: MIT
- * See https://github.com/texxme/Texx/blob/master/LICENSE
- */
-
-import { ExpressPeerServer } from 'peer';
-import express from 'express';
-import path from 'path';
-import logger from 'morgan';
-import bodyParser from 'body-parser';
-import routes from './routes';
-
-const app = express();
-app.disable('x-powered-by');
-
-const server = app.listen(8080, '0.0.0.0');
-const peerServer = ExpressPeerServer(server, { debug: true });
-
-peerServer.on('connection', id => console.log(`New connection: ${id}`));
-
-app.use('/api', peerServer);
-
-// View engine setup
-app.set('views', path.join(__dirname, '../views'));
-app.set('view engine', 'pug');
-
-app.use(logger('dev', {
- skip: () => app.get('env') === 'test',
-}));
-app.use(bodyParser.json());
-app.use(bodyParser.urlencoded({ extended: false }));
-app.use(express.static(path.join(__dirname, '../dist')));
-
-// Routes
-app.use('/', routes);
-
-// Catch 404 and forward to error handler
-app.use((req, res, next) => {
- const err = new Error('Not Found');
- err.status = 404;
- next(err);
-});
-
-// Error handler
-app.use((err, req, res, next) => { // eslint-disable-line no-unused-vars
- res
- .status(err.status || 500)
- .render('error', {
- message: err.message,
- });
-});
diff --git a/src/routes.js b/src/routes.js
deleted file mode 100644
index 65ac32d..0000000
--- a/src/routes.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * routes.js
- * Copyright (c) 2019, Texx
- * License: MIT
- * See https://github.com/texxme/Texx/blob/master/LICENSE
- */
-
-import { Router } from 'express';
-
-const routes = Router();
-
-/**
- * GET home page
- */
-routes.get('/', (req, res) => {
- res.render('index');
-});
-
-export default routes;
diff --git a/src/server.js b/src/server.js
deleted file mode 100644
index 61eb331..0000000
--- a/src/server.js
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * server.js
- * Copyright (c) 2019, Texx
- * License: MIT
- * See https://github.com/texxme/Texx/blob/master/LICENSE
- */
-
-/**
- * This script should only be used on a deployment server.
- * For debugging purposes please use 'npm run dev'
- */
-const PeerServer = require('peer').PeerServer;
-
-const server = PeerServer({
- debug: true,
- port: 4242,
- path: '/api',
-});
-
-server.on('connection', id => console.log(`New connection: ${id}`));