Skip to content

Commit 232d05a

Browse files
committed
Migrating from sails to Hapi.js
Now using gulp instead of grunt. Hapi is setup and you can hit the login page, but the back-end api still needs to be reworked a bit. For the most part everything has been moved around to the proper spots, but I still need to finish refactoring and fixing things to work with hapi instead of sails.
1 parent 597de1a commit 232d05a

File tree

155 files changed

+2152
-4228
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+2152
-4228
lines changed

.sailsrc

Lines changed: 0 additions & 9 deletions
This file was deleted.

Gruntfile.js

Lines changed: 0 additions & 81 deletions
This file was deleted.

api/controllers/MainController.js

Lines changed: 0 additions & 9 deletions
This file was deleted.

api/services/db.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

app.js

Lines changed: 48 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,57 @@
1-
/**
2-
* app.js
3-
*
4-
* Use `app.js` to run your app without `sails lift`.
5-
* To start the server, run: `node app.js`.
6-
*
7-
* This is handy in situations where the sails CLI is not relevant or useful.
8-
*
9-
* For example:
10-
* => `node app.js`
11-
* => `forever start app.js`
12-
* => `node debug app.js`
13-
* => `modulus deploy`
14-
* => `heroku scale`
15-
*
16-
*
17-
* The same command-line arguments are supported, e.g.:
18-
* `node app.js --silent --port=80 --prod`
19-
*/
1+
var path = require('path'),
2+
hapi = require('hapi'),
3+
good = require('good'),
4+
server = new hapi.Server(3000),
5+
routes = require('./server/routes'),
6+
db = require('./server/services/db');
207

21-
// Ensure a "sails" can be located:
22-
(function() {
23-
var sails;
24-
try {
25-
sails = require('sails');
26-
} catch (e) {
27-
console.error('To run an app using `node app.js`, you usually need to have a version of `sails` installed in the same directory as your app.');
28-
console.error('To do that, run `npm install sails`');
29-
console.error('');
30-
console.error('Alternatively, if you have sails installed globally (i.e. you did `npm install -g sails`), you can use `sails lift`.');
31-
console.error('When you run `sails lift`, your app will still use a local `./node_modules/sails` dependency if it exists,');
32-
console.error('but if it doesn\'t, the app will run with the global sails instead!');
33-
return;
34-
}
8+
// Setup server
9+
routes.registerRoutes(server);
10+
server.views({
11+
engines: {
12+
html: require('handlebars')
13+
},
14+
path: path.join(__dirname, 'server/views')
15+
});
3516

36-
// Try to get `rc` dependency
37-
var rc;
38-
try {
39-
rc = require('rc');
40-
} catch (e0) {
41-
try {
42-
rc = require('sails/node_modules/rc');
43-
} catch (e1) {
44-
console.error('Could not find dependency: `rc`.');
45-
console.error('Your `.sailsrc` file(s) will be ignored.');
46-
console.error('To resolve this, run:');
47-
console.error('npm install rc --save');
48-
rc = function () { return {}; };
49-
}
50-
}
17+
console.log('Attempting to connect to MongoDB via Mongoose...');
18+
db.connect(function(valid) {
19+
if(valid) {
20+
console.log('Successfully connected to MongoDB via Mongoose!');
5121

52-
var db = require('./api/services/db');
53-
sails.log.info('Attempting to connect to MongoDB via Mongoose...');
54-
db.connect(function(valid) {
55-
if(valid) {
56-
sails.log.info('Successfully connected to MongoDB via Mongoose!');
22+
// Application setup
23+
var argv = require('minimist')(process.argv.slice(2));
5724

58-
// Application setup
59-
var argv = require('minimist')(process.argv.slice(2));
25+
if(argv['force-setup']) {
26+
require('shelljs/global');
27+
console.log('--force-setup flag detected, dropping server-dash database and running setup script.');
28+
exec('mongo server-dash --eval "db.dropDatabase()"');
29+
}
6030

61-
if(argv['force-setup']) {
62-
require('shelljs/global');
63-
sails.log.info('--force-setup flag detected, dropping server-dash database and running setup script.');
64-
exec('mongo server-dash --eval "db.dropDatabase()"');
65-
}
31+
var setup = require('./setup/setup.js');
6632

67-
var setup = require('./setup/setup.js');
33+
setup.userSetup(function() {
34+
setup.widgetSetup(function() {
35+
server.pack.register([good, require('hapi-auth-cookie')], function(err) {
36+
if(err) {
37+
throw err; // plugin failed
38+
}
6839

69-
setup.userSetup(function() {
70-
setup.widgetSetup(function() {
71-
sails.lift(rc('sails'));
40+
server.auth.strategy('session', 'cookie', {
41+
password: 'Th!sAppR0cks!', // cookie secret
42+
cookie: '_serverDashAuth', // cookie name
43+
redirectTo: false,
44+
isSecure: false,
45+
ttl: 1000 * 60 * 60 * 24
46+
});
47+
48+
server.start(function() {
49+
server.log('info', 'Server running at: ', server.info.uri);
50+
});
7251
});
7352
});
74-
} else {
75-
sails.log.error('Error in Mongoose connection: ', error);
76-
}
77-
});
78-
})();
53+
});
54+
} else {
55+
console.error('Error in Mongoose connection.');
56+
}
57+
});

assets/favicon.ico

-920 Bytes
Binary file not shown.

assets/js/dependencies/sails.io.js

Lines changed: 0 additions & 822 deletions
This file was deleted.

assets/js/ember-app/templates/.gitkeep

Whitespace-only changes.

assets/robots.txt

Lines changed: 0 additions & 8 deletions
This file was deleted.

assets/styles/importer.less

Lines changed: 0 additions & 36 deletions
This file was deleted.

assets/styles/mixins.less

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)