diff options
-rw-r--r-- | app.js (renamed from src/index.js) | 13 | ||||
-rw-r--r-- | package-lock.json | 5 | ||||
-rw-r--r-- | package.json | 2 | ||||
-rw-r--r-- | server.js (renamed from src/server.js) | 0 | ||||
-rw-r--r-- | src/routes.js | 19 |
5 files changed, 9 insertions, 30 deletions
@@ -1,29 +1,32 @@ /* - * index.js + * app.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 express, { Router } 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 routes = Router(); const server = app.listen(8080, '0.0.0.0'); const peerServer = ExpressPeerServer(server, { debug: true }); peerServer.on('connection', id => console.log(`New connection: ${id}`)); +routes.get('/', (req, res) => { + res.render('index'); +}); app.use('/api', peerServer); // View engine setup -app.set('views', path.join(__dirname, '../views')); +app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'pug'); app.use(logger('dev', { @@ -31,7 +34,7 @@ app.use(logger('dev', { })); app.use(bodyParser.json()); app.use(bodyParser.urlencoded({ extended: false })); -app.use(express.static(path.join(__dirname, '../dist'))); +app.use(express.static(path.join(__dirname, 'dist'))); // Routes app.use('/', routes); diff --git a/package-lock.json b/package-lock.json index f6cc5e5..f6f5829 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3765,11 +3765,6 @@ "object-assign": "^4.0.1" } }, - "file-type": { - "version": "10.8.0", - "resolved": "https://registry.npmjs.org/file-type/-/file-type-10.8.0.tgz", - "integrity": "sha512-287YScp3cpRWzhM+/E+A85O4FJi4dHus0eA6eBUzkRc08d/JAwqeczU/nwLstRuzzq/S7TqvQg9mhv7xVsdINQ==" - }, "filename-regex": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz", diff --git a/package.json b/package.json index 64f25d8..c4350bc 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "npm": ">=3.10.0" }, "scripts": { - "dev": "npm run watch & nodemon src/index.js --exec \"node -r dotenv/config -r babel-register\"", + "dev": "npm run watch & nodemon app.js --exec \"node -r dotenv/config -r babel-register\"", "watch": "npm run debug && onchange public/styles/* -- npm run css & onchange public/scripts/* -- npm run debug", "css": "node-sass public/styles/main.sass dist/app.css && cp public/images/* dist/", "debug": "rm -r dist/* && npm run css && browserify public/scripts/main.js -o dist/app.js", diff --git a/src/server.js b/server.js index 61eb331..61eb331 100644 --- a/src/server.js +++ b/server.js 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; |