Вопрос

Currenty I'm using grunt with karma and jasmine to run my tests etc. for my Angular app.

I want to connect this app to a mongo database and was wondering what the best way to do this is. Should I keep using grunt and just connect to a database and use it all the way, or should I use an Express server as my main server connected to the database and run the tests with grunt?

Initially I want to publish this project to heroku, and I know you can do this by just adding a static server.js (wich I do not currently have) like this.

var express = require('express');
var port = process.env.PORT || 3000;
var app = express();
app.use(express.static(__dirname + ‘/public’));
app.listen(port);

and modify the gruntfile.js with this:

tasks
grunt.registerTask('heroku',
    ['compass:dist', 'autoprefixer', 'imagemin']);

What is the best way to do this?

Это было полезно?

Решение

I see, I feel you have slight misconception of what grunt is. Grunt is a task runner. It will run other commands when for each task. Say for example if you can compile css or minifiy js or combine images before starting server you can do it with grunt. But that does not mean grunt can do all those by itself. It will be using other libraries for those.

If you are using grunt to do testing you internally using jasmine or karma js or something else. Same when you say grunt serve you use express internally start server. So grunt does not connect to mongodb. It is express which connects to mongodb. You can write grunt tasks which will start mongodb and start express server but grunt can not do either by its own.

Should you use grunt? Yes of course.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top