Skip to content

Commit

Permalink
Merge pull request #2 from CodeForCharlotte/master
Browse files Browse the repository at this point in the history
converted server to typescript (#8)
  • Loading branch information
chimon2000 authored Aug 31, 2017
2 parents 0463f73 + 5eae992 commit 305c653
Show file tree
Hide file tree
Showing 24 changed files with 5,386 additions and 819 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# The Lunch Project


## Server Configuration Setup
docker pull mysql
docker run --name db-mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=UNCCrugby_49 -d mysql
docker pull postgres
docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres

#installation to do db migrations
npm install -g sequelize-cli
npm install -g mysql2
TODO

#command to update database with latest migrations.
sequelize db:migrate
TODO

#command to create databae migrations
sequelize migration:create
TODO

## Run client & server
`cross-env DB_HOST="<HOST>" DB_USERNAME="<YOUR_DB_USERNAME>" DB_PASSWORD="<DB_PASSWORD>" DB_NAME="<DB_NAME>" node fuse`
40 changes: 34 additions & 6 deletions fuse.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
const { FuseBox, WebIndexPlugin, BabelPlugin } = require('fuse-box')
const { FuseBox, WebIndexPlugin, BabelPlugin, EnvPlugin } = require('fuse-box')
const path = require('path')
const express = require('express')

const fuse = FuseBox.init({
const client = FuseBox.init({
homeDir: 'client',
modulesFolder: 'client/node_modules',
plugins: [
WebIndexPlugin({
template: './client/index.html',
path: '/static/'
})
],
homeDir: 'client',
output: 'dist/static/$name.js',
alias: {
react: 'preact-compat',
'react-dom': 'preact-compat'
}
})
fuse.bundle('app').instructions(`>src/index.tsx`).watch()
fuse.dev({ root: false }, server => {
client
.bundle('client')
.instructions(`>src/index.tsx`)
.watch('client/**')
client.dev({ root: false }, server => {
const dist = path.resolve('./dist')
const app = server.httpServer.app
app.use('/static/', express.static(path.join(dist, 'static')))
Expand All @@ -27,4 +30,29 @@ fuse.dev({ root: false }, server => {
res.sendFile(path.join(dist, 'static/index.html'))
})
})
fuse.run()
client.run()

const server = FuseBox.init({
homeDir: 'server',
modulesFolder: 'server/node_modules',
output: 'dist/server/$name.js',
plugins: [
EnvPlugin({
DB_PASSWORD: process.env.DB_PASSWORD,
DB_USERNAME: process.env.DB_USERNAME,
DB_HOST: process.env.DB_HOST,
NODE_ENV: 'development'
})
]
})

server.dev({ port: 4455, httpServer: false })

server
.bundle('server')
.watch('server/**') // watch only server related code.. bugs up atm
.instructions(' > [index.ts]')
// launch and restart express
.completed(proc => proc.start())

server.run()
Loading

0 comments on commit 305c653

Please sign in to comment.