Skip to content

Commit

Permalink
Clean configs, project files, sails configuration to default
Browse files Browse the repository at this point in the history
  • Loading branch information
Sami Karjalainen committed Jan 27, 2017
1 parent 83d3630 commit 5e65631
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 169 deletions.
3 changes: 0 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,5 @@
"transform-export-extensions",
"add-module-exports",
"transform-decorators-legacy"
],
"ignore": [
"./src/assets/js/*"
]
}
1 change: 0 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
assets/
apidoc/
node_modules/
65 changes: 0 additions & 65 deletions .jshintrc

This file was deleted.

8 changes: 0 additions & 8 deletions Dockerfile

This file was deleted.

1 change: 0 additions & 1 deletion api/models/User.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
//import uuid from 'node-uuid';
import Hashids from 'hashids';
import bcrypt from 'bcrypt-nodejs';

Expand Down
37 changes: 21 additions & 16 deletions config/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,50 +14,55 @@ var users = [{
role: 'admin',
name: 'Admin',
password: 'password',
},
];
}];


function ensureUser(user) {
var password = user.password;
delete user.password;

return new Promise((resolve, reject) => {
User.findOne({ email: user.email })
return User.findOne({ email: user.email })
.then((found) => {
if (!found) {
User.create(user)
return User.create(user)
.then((created) => {
created.newPassword = password;
return created.save();
return created.save(() => reject('Error saving user'));
})
.then(saved => {
.then(() => {
sails.log.info(`User ${user.name} <${user.email}> created`);
resolve();
return resolve();
})
.catch(err => {
.catch((err) => {
sails.log.warn(err);
reject(err);
return reject(err);
});
} else {
resolve();
}
return resolve();
})
.catch(err => {
.catch((err) => {
sails.log.warn(err);
reject(err);
return reject(err);
});
});
}


module.exports.bootstrap = function (cb) {

// It's very important to trigger this callback method when you are finished
// with the bootstrap! (otherwise your server will never lift, since it's waiting on the bootstrap)

var requests = users.map(user => ensureUser(user));
return Promise.all(requests)
.then(() => cb())
.then(() => {
sails.log.info('**************************************************');
sails.log.info('* DEFAULT LOGIN (created @ /config/bootstrap.js) *')
sails.log.info('* ---------------------------------------------- *')
sails.log.info('* Email : [email protected] *')
sails.log.info('* Password : password *')
sails.log.info('**************************************************');
sails.log.debug(sails.config.views);
return cb();
})
.catch(cb);
};
7 changes: 0 additions & 7 deletions config/connections.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@ module.exports.connections = {
// database: 'your_mongo_db_name_here' //optional
// },

localMongoServer: {
adapter: 'sails-mongo',
host: 'localhost',
port: 27017,
database: 'silverbullet',
},

/***************************************************************************
* *
* PostgreSQL is another officially supported relational database. *
Expand Down
16 changes: 5 additions & 11 deletions config/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,14 @@ function reactView(req, res, next) {
var state = (req.session && req.session.state) ? req.session.state : {};
var routes = reactRoutes(true);

match({ routes, location: req.url }, function(error, redirectLocation, renderProps) {
match({ routes, location: req.url }, (error, redirectLocation, renderProps) => {
// couldnt match request url to react path
if (error) {
// 500
return res.error();
} else if (renderProps) {
// 200
console.log(req.session);
var reactHtml = ReactDOMServer.renderToString(reactApp({ req: req, state: state }));
//TODO some smarter way to find if there react route?
iso = new Iso();
iso.add(reactHtml, state);
viewData = {
Expand All @@ -45,16 +44,11 @@ function reactView(req, res, next) {
};
if (!res.view) {
if (!req.options) req.options = {}; // add options to req otherwise addResView fails
addResView(req, res, () => {
res.view('react', viewData);
});
} else {
res.view('react', viewData);
return addResView(req, res, () => res.view('react', viewData));
}
// end of 200
} else {
return next();
return res.view('react', viewData);
}
return next();
});
}

Expand Down
4 changes: 2 additions & 2 deletions config/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports.models = {
* connections (see `config/connections.js`) *
* *
***************************************************************************/
connection: 'localMongoServer',
connection: 'localDiskDb',

/***************************************************************************
* *
Expand All @@ -27,6 +27,6 @@ module.exports.models = {
* See http://sailsjs.org/#!/documentation/concepts/ORM/model-settings.html *
* *
***************************************************************************/
migrate: 'alter',
migrate: 'drop',

};
2 changes: 1 addition & 1 deletion config/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports.session = {
* *
***************************************************************************/

adapter: 'redis',
// adapter: 'redis',

/***************************************************************************
* *
Expand Down
41 changes: 0 additions & 41 deletions docker-compose.yml

This file was deleted.

13 changes: 0 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,9 @@
"babel-preset-es2015": "^6.14.0",
"babel-preset-react": "^6.11.1",
"babel-preset-stage-0": "^6.5.0",
"bcrypt": "^0.8.7",
"bcrypt-nodejs": "0.0.3",
"bootstrap-sass": "^3.3.7",
"connect-redis": "^3.1.0",
"dustjs-linkedin": "^2.7.4",
"ejs": "2.5.2",
"express": "^4.14.0",
"grunt": "1.0.1",
"grunt-contrib-clean": "1.0.0",
Expand All @@ -49,36 +46,27 @@
"iso": "^5.2.0",
"json-loader": "^0.5.4",
"jsonwebtoken": "^7.1.9",
"localStorage": "^1.0.3",
"moment": "^2.15.0",
"msgpack-lite": "^0.1.20",
"node-uuid": "^1.4.7",
"nodemailer": "^2.6.4",
"npm-run-all": "^3.1.0",
"ramda": "^0.22.1",
"rc": "1.1.6",
"react": "^15.3.1",
"react-bootstrap": "^0.30.3",
"react-datepicker": "0.34.0",
"react-dom": "^15.3.1",
"react-dropzone": "^3.6.0",
"react-i18next": "^1.10.1",
"react-redux": "^4.4.5",
"react-router": "^3.0.0",
"react-router-redux": "^4.0.5",
"react-select": "^1.0.0-rc.2",
"react-webcam": "0.0.14",
"redux": "^3.6.0",
"redux-thunk": "^2.1.0",
"reduxsauce": "^0.2.0",
"sails": "~0.12.4",
"sails-disk": "~0.10.10",
"sails-mongo": "^0.12.1",
"sails.io.js": "1.0.1",
"seamless-immutable": "^6.1.1",
"socket.io-client": "^1.4.8",
"superagent": "3.0.0",
"validator": "6.1.0",
"webpack": "^1.13.2"
},
"scripts": {
Expand Down Expand Up @@ -108,7 +96,6 @@
"eslint-plugin-jsx-a11y": "3.0.1",
"eslint-plugin-react": "^6.2.2",
"grunt-contrib-sass": "^1.0.0",
"moment": "^2.15.1",
"nodemon": "^1.10.2"
}
}

0 comments on commit 5e65631

Please sign in to comment.