This post i will try explain about one web cralwer made for me in NodeJS + Mongo + AngularJS. The post focus doesn't be one tutorial, the focus is share my little knowledge about MEAN (MongoDB, Express, Angular e NodeJS).
The posts will separete in tree steps:
1 - Initial Config
2 - Web crawler logic
3 - Keywords AngularJS CRUD
1- Initial Config
#Requeriments:
NodeJS
Node Express
MongoDB
Bower
#Node dependencies: In file package.json
"dependencies": { "express": "~4.0.0", "serve-favicon": "~2.1.3", "morgan": "~1.0.0", "cookie-parser": "~1.0.1", "body-parser": "~1.0.0", "debug": "~0.7.4", "jade": "~1.3.0", "mongodb": "*", "monk": "*", "cheerio": "*" }
#Bower resources config:
In file bower.json:
{ "name": "promocrawler", "version": "1.0.0", "dependencies": { "bootstrap": "latest", "font-awesome": "latest", "animate.css": "latest", "angular": "latest", "angular-route": "latest" } }
#Configuration in App.js:
Mongo config:
var mongo = require('mongodb'); var monk = require('monk'); var db = monk(process.env.MONK_URL); var port = process.env.PORT || 8080; // Make our db accessible to our router app.use(function(req,res,next){ req.db = db; next(); }); Define routers: require('./routes/keyword.js')(app); require('./routes/crawler.js'); Port definition: app.listen(port); console.log("App listening on port " + port);
Source code
Nenhum comentário:
Postar um comentário