Estou tendo o seguinte problema ao ligar o node:
C:\Users\Usuario\payfast>node index.js
consign v0.1.2 Initialized in C:\Users\Usuario\payfast
+ .\controllers\pagamento.js
C:\Users\Usuario\payfast\index.js:3
app.listen(3000, function(){
^
TypeError: Cannot read property 'listen' of undefined
at Object.<anonymous> (C:\Users\Usuario\payfast\index.js:3:4)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
C:\Users\Usuario\payfast>
Meu código esta assim:
Custom-express
var express = require('express');
var consign = require('consign');
var bodyParser = require('body-parser');
module.exports = function() {
var app = express();
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
consign()
.include('controllers')
.into(app);
}
index.js
var app = require('./config/custom-express')();
app.listen(3000, function(){
console.log("Servidor rodando!");
});
pagamento.js
module.exports = function(app){
app.get('/pagamentos', function(req, res){
console.log('Recebida requisicao de teste na porta 3000.')
res.send('OK.');
});
app.post("/pagamentos/pagamento",function(req, res) {
var pagamento = req.body;
console.log(pagamento);
res.send('ok');
});
}