Navigation Menu

Skip to content
This repository has been archived by the owner on Apr 30, 2020. It is now read-only.

Commit

Permalink
setup
Browse files Browse the repository at this point in the history
  • Loading branch information
lunik committed Jul 4, 2017
0 parents commit 371fd71
Show file tree
Hide file tree
Showing 9 changed files with 4,160 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintrc
@@ -0,0 +1 @@
{"extends": ["standard"]}
7 changes: 7 additions & 0 deletions .gitignore
@@ -0,0 +1,7 @@
# Created by .ignore support plugin (hsz.mobi)

.idea/

node_modules/

.DS_Store
3,976 changes: 3,976 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions package.json
@@ -0,0 +1,48 @@
{
"name": "tcloud",
"version": "0.0.1",
"description": "Filesharing and torrent downloading",
"main": "index.js",
"scripts": {
"build": "webpack",
"start": "node build/server.js",
"dev": "npm run build && npm start"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Lunik/tcloud.git"
},
"author": "Guillaume Lunik",
"license": "ISC",
"bugs": {
"url": "https://github.com/Lunik/tcloud/issues"
},
"homepage": "https://github.com/Lunik/tcloud#readme",
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-loader": "^7.1.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"eslint": "^4.1.1",
"eslint-config-standard": "^10.2.1",
"eslint-config-standard-jsx": "^4.0.1",
"eslint-plugin-import": "^2.3.0",
"eslint-plugin-node": "^5.0.0",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-react": "^7.0.1",
"eslint-plugin-standard": "^3.0.1",
"html-webpack-plugin": "^2.29.0",
"uglifyjs-webpack-plugin": "^0.4.6",
"webpack": "^3.0.0",
"webpack-node-externals": "^1.6.0"
},
"dependencies": {
"body-parser": "^1.17.2",
"compression": "^1.6.2",
"cookie-parser": "^1.4.3",
"delogger": "^0.9.5",
"express": "^4.15.3",
"react": "^15.6.1",
"react-dom": "^15.6.1"
}
}
3 changes: 3 additions & 0 deletions src/public/index.js
@@ -0,0 +1,3 @@
/**
* Created by lunik on 04/07/2017.
*/
17 changes: 17 additions & 0 deletions src/public/static/index.js
@@ -0,0 +1,17 @@

import React from 'react'

export default class Index extends React.Component {
render () {
return (
<html lang="fr">
<head>
<meta charset="UTF-8" />
<title>Tcloud</title>
</head>
<body>
<script type="text/javascript" src="app.js"></script></body>
</html>
)
}
}
9 changes: 9 additions & 0 deletions src/server/index.js
@@ -0,0 +1,9 @@
/**
* Created by lunik on 04/07/2017.
*/

import Server from './server'

var server = new Server()

server.listen(8080)
34 changes: 34 additions & 0 deletions src/server/server.js
@@ -0,0 +1,34 @@
/**
* Created by lunik on 04/07/2017.
*/

import Express from 'express'
import Delogger from 'delogger'
import compression from 'compression'
import cookieParser from 'cookie-parser'
import bodyParser from 'body-parser'
import React from 'react'
import {renderToString} from 'react-dom/server'

import StaticHtml from '../public/static'

export default class Server {
constructor () {
this.app = Express()
this.app.use(compression())
this.app.use(cookieParser())
this.app.use(bodyParser.json())
this.app.use(bodyParser.urlencoded({
extended: true
}))
this.app.get('/', function (req, res) {
res.end(renderToString(<StaticHtml />))
})

this.log = new Delogger('Server')
}
listen (port, host) {
host = host || '0.0.0.0'
this.app.listen(port, host, () => this.log.info(`Server listening on ${host}:${port}`))
}
}
65 changes: 65 additions & 0 deletions webpack.config.js
@@ -0,0 +1,65 @@
/**
* Created by lunik on 04/07/2017.
*/
const webpack = require('webpack')
var nodeExternals = require('webpack-node-externals')
const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')

const BUILD_DIR = __dirname + '/build'
module.exports = [
{
entry: './src/server/index.js',
output: {
path: BUILD_DIR,
filename: 'server.js'
},
module: {
loaders: [{
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015']
}
}]
},
target: 'node',
externals: [nodeExternals()],
plugins: [
new UglifyJsPlugin({
compress: {
warnings: false
},
output: {
comments: false
}
})
]
},
{
entry: './src/public/index.js',
output: {
path: BUILD_DIR,
filename: 'app.js'
},
module: {
loaders: [{
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015']
}
}]
},
plugins: [
new UglifyJsPlugin({
compress: {
warnings: false
},
output: {
comments: false
}
})
]
}
]

0 comments on commit 371fd71

Please sign in to comment.