flat image, webpack watch, full coffee node, "static" -> "public_html"

This commit is contained in:
Jörn-Michael Miehe 2018-11-29 14:14:53 +01:00
parent 4656aaa23c
commit 8d05e71359
13 changed files with 84 additions and 116 deletions

View file

@ -1,6 +1,7 @@
node_modules
npm-debug.log
**/*.xcf
**/*.bundle.js
Dockerfile
.dockerignore

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
**/*.bundle.js

View file

@ -11,7 +11,6 @@ RUN yarn
# copy code
COPY . .
RUN yarn build
# this is how we start
CMD ["yarn", "start"]

View file

@ -25,6 +25,10 @@ services:
# dbpass: juchie5OhH6eiQuujaoquievezoe9iXe
fftcg:
build: .
command: "yarn debug"
restart: "no"
volumes:
- "${PWD}/src:/app/src"
- "${PWD}/static:/app/static"
ports:
- "8001:8080"

View file

@ -1,39 +0,0 @@
# libraries
http = require 'http'
socketio = require 'socket.io'
express = require 'express'
gulp = global.gulp = require 'gulp'
helmet = require 'helmet'
# gulp the sources
require './gulpfile'
gulp.start 'default'
# socket.io framework
app = express()
web = http.Server app
io = socketio web
# Listen server
web.listen 8080, ->
console.log 'Node.js listening on port 8080'
app.use helmet()
# Static content
app.use ( express.static __dirname + '/../static' )
# Server logic
io.on 'connection', (socket) ->
console.log 'a user connected'
console.log socket.id
socket.on 'disconnect', ->
# console.log 'user disconnected'
return
socket.on 'login', ->
console.log 'message:', msg.uname, msg.password
return
return

View file

@ -1,31 +1,35 @@
{
"name": "node-fftcg",
"version": "0.0.2",
"version": "0.0.3",
"description": "FFTCG online using Socket.IO and CraftyJS on Node.js on Docker",
"author": "JMM <jmm@yavook.de>",
"main": "server.js",
"main": "server.coffee",
"private": true,
"license": "UNLICENSED",
"scripts": {
"build": "webpack",
"start": "node server.js",
"watch": "yarn start & webpack --watch",
"watch": "webpack --watch",
"start": "webpack && coffee server.coffee",
"debug": "webpack --watch & coffee server.coffee",
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"@babel/core": "^7.1.6",
"@babel/preset-env": "^7.1.6",
"coffee-loader": "^0.9.0",
"css-loader": "^1.0.1",
"postcss-loader": "^3.0.0",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"transform-loader": "^0.2.4",
"autoprefixer": "^9.3.1",
"brfs": "^2.0.1",
"css-loader": "^1.0.1",
"postcss-loader": "^3.0.0",
"node-sass": "^4.10.0",
"precss": "^3.1.2",
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"webpack": "^4.25.1",
"webpack-cli": "^3.1.2",
@ -36,11 +40,11 @@
},
"dependencies": {
"bcrypt": "*",
"bcrypt": "^3.0.2",
"coffeescript": "^2.3.2",
"express": "^4.16.4",
"helmet": "*",
"mysql": "*",
"helmet": "^3.15.0",
"mysql": "^2.16.0",
"socket.io": "^2.2.0",
"socket.io-client": "^2.2.0"
}

View file

Before

Width:  |  Height:  |  Size: 610 KiB

After

Width:  |  Height:  |  Size: 610 KiB

View file

Before

Width:  |  Height:  |  Size: 615 KiB

After

Width:  |  Height:  |  Size: 615 KiB

60
server.coffee Normal file
View file

@ -0,0 +1,60 @@
# libraries
bcrypt = require('bcrypt')
express = require('express')
helmet = require('helmet')
http = require('http')
mysql = require('mysql')
path = require('path')
socketio = require('socket.io')
# socket.io framework
app = express()
web = http.Server(app)
io = socketio(web)
# Listen server
web.listen 8080, ->
console.log 'Node.js listening on port 8080'
return
app.use helmet()
# Static content
app.use express.static path.resolve(__dirname, 'public_html')
con = mysql.createConnection
host: 'tcgsql'
user: 'fftcg'
database: 'fftcg'
password: 'juchie5OhH6eiQuujaoquievezoe9iXe'
con.connect (err) ->
if err
throw err
console.log 'Connected to TCGSQL!'
return
# Server logic
io.on 'connection', (socket) ->
console.log 'a user connected'
socket.on 'disconnect', ->
# console.log('user disconnected');
return
socket.on 'login', (msg) ->
console.log 'message:', msg.uname, msg.password
saltRounds = 13
bcrypt.hash msg.password, saltRounds, (err, hash) ->
con.query 'INSERT INTO `users` (nick, pwd_hash) VALUES (\'' + msg.uname + '\', \'' + hash + '\');', (err, result) ->
if err
throw err
console.log 'Result: ' + result
return
return
return
return

View file

@ -1,57 +0,0 @@
// libraries
var
http = require('http'),
socketio = require('socket.io'),
mysql = require('mysql'),
bcrypt = require('bcrypt'),
express = require('express'),
helmet = require('helmet');
// socket.io framework
let app = express();
let web = http.Server(app);
let io = socketio(web);
// Listen server
web.listen(8080, function () {
console.log('Node.js listening on port 8080');
});
app.use(helmet());
// Static content
app.use(express.static(__dirname + '/static'));
var con = mysql.createConnection({
host: "tcgsql",
user: "fftcg",
database: "fftcg",
password: "juchie5OhH6eiQuujaoquievezoe9iXe",
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected to TCGSQL!");
});
// Server logic
io.on('connection', function (socket) {
console.log('a user connected');
socket.on('disconnect', function(){
// console.log('user disconnected');
});
socket.on('login', function(msg){
console.log('message:', msg.uname, msg.password);
const saltRounds = 13;
bcrypt.hash(msg.password, saltRounds, function(err, hash) {
con.query('INSERT INTO `users` (nick, pwd_hash) VALUES (\'' + msg.uname + '\', \'' + hash + '\');', function (err, result) {
if (err) throw err;
console.log("Result: " + result);
});
});
});
});

View file

@ -12,16 +12,11 @@ module.exports = {
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'static')
path: path.resolve(__dirname, 'public_html')
},
module: {
rules: [
{
loader: "transform-loader?brfs",
enforce: "post"
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']