Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dan #2

Open
wants to merge 94 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
467c27c
removing expose fro Dockerfile
May 4, 2016
ec54504
change order of commands in Dockerfile
May 4, 2016
bc46ff6
updating less module in package.json
May 9, 2016
2bf04b0
Update README.md
bmeiri Jun 21, 2016
387d856
Update README.md
bmeiri Jun 21, 2016
f4bea46
adding docker-compose
Aug 13, 2016
c6c36e6
adding codefresh.yml
Sep 20, 2016
465d19d
change node version
Sep 20, 2016
bc67b6a
change node version
Sep 20, 2016
7752270
change node version
Sep 20, 2016
8afaf3e
Update defaults.yml
advance512-demo Oct 5, 2016
df77655
Update defaults.yml
advance512-demo Oct 5, 2016
21478af
Create settings.yml
advance512-demo Oct 5, 2016
7d28cee
Added multiple connection tries
advance512-demo Oct 6, 2016
f7f585c
Update app.js
advance512-demo Oct 6, 2016
cabb8c9
Updating app.js
advance512-demo Oct 6, 2016
53cfaa4
Calling tryConnect()..
advance512-demo Oct 6, 2016
fa7b383
Deleting settings.yml
advance512-demo Oct 6, 2016
56bc5a0
Merge pull request #1 from advance512-demo/master
Superfresh Oct 9, 2016
93fce75
modify yaml
verchol Nov 14, 2016
8dadac2
new yaml
verchol Nov 14, 2016
2d4414d
new yaml
verchol Nov 14, 2016
774673c
new yaml
verchol Nov 14, 2016
4b5687c
remove npm from yaml
verchol Nov 14, 2016
6c677b7
remove npm from yaml
verchol Nov 14, 2016
184429a
run with composition
verchol Nov 14, 2016
23bf354
run with composition
verchol Nov 14, 2016
53c9369
add CD
verchol Nov 14, 2016
96063f7
add staging
verchol Nov 14, 2016
e3a5413
fix codefreshCD
verchol Nov 14, 2016
7700972
add push
verchol Nov 14, 2016
06f96b8
add push
verchol Nov 14, 2016
b49118d
add push
verchol Nov 14, 2016
a35bd2d
fix yaml
verchol Nov 14, 2016
e283c88
fix
verchol Nov 14, 2016
6eec5a3
hotfix
verchol Nov 14, 2016
febacce
Merge branch 'devtlv' into staging
verchol Nov 14, 2016
07f46c3
yaml file
verchol Nov 14, 2016
dbfecd0
add staff
verchol Nov 14, 2016
5416a94
add staff
verchol Nov 14, 2016
eafbac1
add hotfix
verchol Nov 14, 2016
c17e68c
add hotfix
verchol Nov 14, 2016
6363c11
add hotfix
verchol Nov 14, 2016
277d97f
add hotfix1
verchol Nov 14, 2016
cd85546
add hotfix2
verchol Nov 14, 2016
08c742b
add hotfix4
verchol Nov 14, 2016
8d0e394
add hotfix5
verchol Nov 14, 2016
ebc04a7
add codefreshdev
verchol Nov 14, 2016
75948cc
change the title
verchol Nov 14, 2016
24e148c
add production filter to ecs
verchol Nov 14, 2016
fa75451
add integration tests
verchol Nov 14, 2016
84f6587
add integration tests
verchol Nov 14, 2016
94a8fa4
Update codefresh.yml
Superfresh Nov 15, 2016
06297cf
update yaml
Superfresh Nov 15, 2016
6e778e8
my new feature
Nov 15, 2016
f55212f
remove integrations
Superfresh Nov 15, 2016
9ccc19b
Merge branch 'master' of github.com:containers101/demochat into devcon
Nov 15, 2016
9f45699
update
Superfresh Nov 15, 2016
521b19e
Merge branch 'master' of github.com:containers101/demochat
Nov 15, 2016
65285e2
back to default
Nov 15, 2016
9c8a45b
my feature
Nov 15, 2016
e6063f3
fix titles
Superfresh Nov 23, 2016
b203274
Change the header
Superfresh Nov 23, 2016
97e0798
title
Superfresh Nov 23, 2016
a23eb61
remove underscore
Superfresh Nov 23, 2016
6b5edce
Change the title
Superfresh Nov 23, 2016
00c58dd
Merge pull request #2 from containers101/chat-webinar
Superfresh Nov 23, 2016
7454a3a
Test commit
Superfresh Nov 30, 2016
621b5af
Update login.html
Superfresh Nov 30, 2016
2abd988
changed the title
Superfresh Nov 30, 2016
aae52a8
Update login.html
Superfresh Nov 30, 2016
e25b9e9
Update login.html
Superfresh Nov 30, 2016
c353ed9
Update login.html
Superfresh Nov 30, 2016
6bb61d3
new title - don't PUSH
Superfresh Nov 30, 2016
92a4157
Doing it
Superfresh Nov 30, 2016
7e1f5f8
Update README.md
bmeiri Nov 30, 2016
2ebef7b
Update login.html
Superfresh Nov 30, 2016
db30d8e
Update login.html
Superfresh Nov 30, 2016
ecc8164
Update README.md
itai-codefresh Nov 30, 2016
c6da32c
Update login.html
Superfresh Nov 30, 2016
a6e1ff1
Update README.md
itai-codefresh Nov 30, 2016
e9541ac
Update login.html
Superfresh Nov 30, 2016
4dce04b
Eric commit msg
Superfresh Nov 30, 2016
4ed090a
name change on production
Superfresh Nov 30, 2016
02b8d04
Push to master
Superfresh Dec 1, 2016
f5f8c4c
Update login.html
Superfresh Dec 1, 2016
13c4bb1
Daniel title
Superfresh Dec 1, 2016
564a057
Update login.html
Superfresh Dec 1, 2016
d599d14
Release 1.2 - Phil
Superfresh Dec 1, 2016
6c65822
Update login.html
Superfresh Dec 1, 2016
e1941a6
Adding Ben to Codefresh
Superfresh Dec 2, 2016
24c8195
Update login.html
Superfresh Dec 2, 2016
b90eb61
Update login.html
Superfresh Dec 2, 2016
6ed47b3
Update login.html
Superfresh Dec 7, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
FROM node:0.10-slim

RUN npm install -g mocha
RUN npm install -g istanbul
RUN npm install -g gulp

COPY ./package.json /src/package.json
RUN cd /src && npm install
COPY ./ /src
RUN npm install -g mocha
RUN npm install -g istanbul
RUN npm install -g gulp

WORKDIR /src
#ENV DEBUG=*

EXPOSE 8080 5222

CMD ["npm", "start"]
12 changes: 12 additions & 0 deletions Dockerfile_prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:0.10-slim

COPY ./package.json /src/package.json
RUN cd /src && npm install
COPY ./ /src

WORKDIR /src
#ENV DEBUG=*


CMD ["npm", "start"]

4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
![Let's Chat Greylock](http://i.imgur.com/0a3l5VF.png)
#test1
#test2
![Screenshot](http://i.imgur.com/C4uMD67.png)
Test Test
A self-hosted chat app for small teams or big Gal by [Security Compass][seccom].

[![Build Status](https://travis-ci.org/sdelements/lets-chat.svg?branch=master)](https://travis-ci.org/sdelements/lets-chat)
[![Dependency Status](https://david-dm.org/sdelements/lets-chat.svg)](https://david-dm.org/sdelements/lets-chat)
[![devDependency Status](https://david-dm.org/sdelements/lets-chat/dev-status.svg)](https://david-dm.org/sdelements/lets-chat#info=devDependencies)


## Features and Stuff

* BYOS (bring your own server)
Expand Down
167 changes: 94 additions & 73 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,40 @@ process.title = 'letschat';

require('colors');

var _ = require('lodash'),
path = require('path'),
fs = require('fs'),
express = require('express.oi'),
i18n = require('i18n'),
bodyParser = require('body-parser'),
var _ = require('lodash'),
path = require('path'),
fs = require('fs'),
express = require('express.oi'),
i18n = require('i18n'),
bodyParser = require('body-parser'),
cookieParser = require('cookie-parser'),
compression = require('compression'),
helmet = require('helmet'),
http = require('http'),
nunjucks = require('nunjucks'),
mongoose = require('mongoose'),
migroose = require('./migroose'),
compression = require('compression'),
helmet = require('helmet'),
http = require('http'),
nunjucks = require('nunjucks'),
mongoose = require('mongoose'),
migroose = require('./migroose'),
connectMongo = require('connect-mongo'),
all = require('require-tree'),
psjon = require('./package.json'),
settings = require('./app/config'),
auth = require('./app/auth/index'),
core = require('./app/core/index');

var MongoStore = connectMongo(express.session),
httpEnabled = settings.http && settings.http.enable,
all = require('require-tree'),
psjon = require('./package.json'),
settings = require('./app/config'),
auth = require('./app/auth/index'),
core = require('./app/core/index');

var MongoStore = connectMongo(express.session),
httpEnabled = settings.http && settings.http.enable,
httpsEnabled = settings.https && settings.https.enable,
models = all(path.resolve('./app/models')),
middlewares = all(path.resolve('./app/middlewares')),
controllers = all(path.resolve('./app/controllers')),
models = all(path.resolve('./app/models')),
middlewares = all(path.resolve('./app/middlewares')),
controllers = all(path.resolve('./app/controllers')),
app;

//
// express.oi Setup
//
if (httpsEnabled) {
app = express().https({
key: fs.readFileSync(settings.https.key),
app = express().https({
key: fs.readFileSync(settings.https.key),
cert: fs.readFileSync(settings.https.cert)
}).io();
} else {
Expand All @@ -56,17 +56,17 @@ if (settings.env === 'production') {

// Session
var sessionStore = new MongoStore({
url: settings.database.uri,
url: settings.database.uri,
autoReconnect: true
});

// Session
var session = {
key: 'connect.sid',
secret: settings.secrets.cookie,
store: sessionStore,
cookie: { secure: httpsEnabled },
resave: false,
key: 'connect.sid',
secret: settings.secrets.cookie,
store: sessionStore,
cookie: { secure: httpsEnabled },
resave: false,
saveUninitialized: true
};

Expand All @@ -85,32 +85,32 @@ app.use(helmet.ieNoOpen());
app.use(helmet.noSniff());
app.use(helmet.xssFilter());
app.use(helmet.hsts({
maxAge: 31536000,
maxAge: 31536000,
includeSubdomains: true,
force: httpsEnabled,
preload: true
force: httpsEnabled,
preload: true
}));
app.use(helmet.contentSecurityPolicy({
defaultSrc: ['\'none\''],
connectSrc: ['*'],
scriptSrc: ['\'self\'', '\'unsafe-eval\''],
styleSrc: ['\'self\'', 'fonts.googleapis.com', '\'unsafe-inline\''],
fontSrc: ['\'self\'', 'fonts.gstatic.com'],
mediaSrc: ['\'self\''],
objectSrc: ['\'self\''],
imgSrc: ['*']
scriptSrc: ['\'self\'', '\'unsafe-eval\''],
styleSrc: ['\'self\'', 'fonts.googleapis.com', '\'unsafe-inline\''],
fontSrc: ['\'self\'', 'fonts.gstatic.com'],
mediaSrc: ['\'self\''],
objectSrc: ['\'self\''],
imgSrc: ['*']
}));

var bundles = {};
app.use(require('connect-assets')({
paths: [
paths: [
'media/js',
'media/less'
],
helperContext: bundles,
build: settings.env === 'production',
helperContext: bundles,
build: settings.env === 'production',
fingerprinting: settings.env === 'production',
servePath: 'media/dist'
servePath: 'media/dist'
}));

// Public
Expand All @@ -121,24 +121,24 @@ app.use('/media', express.static(__dirname + '/media', {
// Templates
var nun = nunjucks.configure('templates', {
autoescape: true,
express: app,
tags: {
blockStart: '<%',
blockEnd: '%>',
express: app,
tags: {
blockStart: '<%',
blockEnd: '%>',
variableStart: '<$',
variableEnd: '$>',
commentStart: '<#',
commentEnd: '#>'
variableEnd: '$>',
commentStart: '<#',
commentEnd: '#>'
}
});

function wrapBundler(func) {
// This method ensures all assets paths start with "./"
// Making them relative, and not absolute
return function() {
return function () {
return func.apply(func, arguments)
.replace(/href="\//g, 'href="./')
.replace(/src="\//g, 'src="./');
.replace(/href="\//g, 'href="./')
.replace(/src="\//g, 'src="./');
};
}

Expand All @@ -148,7 +148,7 @@ nun.addGlobal('text_search', false);

// i18n
i18n.configure({
directory: __dirname + '/locales',
directory: __dirname + '/locales',
defaultLocale: settings.i18n && settings.i18n.locale || 'en'
});
app.use(i18n.init);
Expand All @@ -160,21 +160,21 @@ app.use(bodyParser.urlencoded({
}));

// IE header
app.use(function(req, res, next) {
app.use(function (req, res, next) {
res.setHeader('X-UA-Compatible', 'IE=Edge,chrome=1');
next();
});

//
// Controllers
//
_.each(controllers, function(controller) {
_.each(controllers, function (controller) {
controller.apply({
app: app,
core: core,
settings: settings,
app: app,
core: core,
settings: settings,
middlewares: middlewares,
models: models,
models: models,
controllers: controllers
});
});
Expand All @@ -187,7 +187,7 @@ mongoose.connection.on('error', function (err) {
throw new Error(err);
});

mongoose.connection.on('disconnected', function() {
mongoose.connection.on('disconnected', function () {
throw new Error('Could not connect to database');
});

Expand All @@ -197,17 +197,16 @@ mongoose.connection.on('disconnected', function() {

function startApp() {
var port = httpsEnabled && settings.https.port ||
httpEnabled && settings.http.port;
httpEnabled && settings.http.port;

var host = httpsEnabled && settings.https.host ||
httpEnabled && settings.http.host || '0.0.0.0';

httpEnabled && settings.http.host || '0.0.0.0';


if (httpsEnabled && httpEnabled) {
// Create an HTTP -> HTTPS redirect server
var redirectServer = express();
redirectServer.get('*', function(req, res) {
redirectServer.get('*', function (req, res) {
var urlPort = port === 80 ? '' : ':' + port;
res.redirect('https://' + req.hostname + urlPort + req.path);
});
Expand Down Expand Up @@ -247,31 +246,44 @@ function checkForMongoTextSearch() {
return;
}

if(version[0] < 2) {
if (version[0] < 2) {
return;
}

if(version[0] === '2' && version[1] < 6) {
if (version[0] === '2' && version[1] < 6) {
return;
}

nun.addGlobal('text_search', true);
});
}

mongoose.connect(settings.database.uri, function(err) {
var connectionTries = 0;

function handleMongoConnectionState(err) {

if (err) {
throw err;
connectionTries++;
if (connectionTries < 3) {
console.log('Error connecting to database (will retry in 2 seconds): ' + err.toString());
setTimeout(tryConnect, 2000);
return;
}
else {
throw err;
}
}

checkForMongoTextSearch();

migroose.needsMigration(function(err, migrationRequired) {
migroose.needsMigration(function (err, migrationRequired) {

if (err) {
console.error(err);
}

else if (migrationRequired) {

console.log('Database migration required'.red);
console.log('Ensure you backup your database first.');
console.log('');
Expand All @@ -281,7 +293,16 @@ mongoose.connect(settings.database.uri, function(err) {

return process.exit();
}


console.log('Starting app.');
startApp();
});
});

}

function tryConnect() {
console.log('Connecting to database...');
mongoose.connect(settings.database.uri, handleMongoConnectionState);
}

tryConnect();
Loading