-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
56 lines (44 loc) · 1.31 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
var application_root = __dirname,
express = require('express'),
path = require('path'),
mongoose = require('mongoose');
var app = express.createServer();
mongoose.connect('mongodb://localhost/transmilleno');
app.configure(function(){
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(application_root, 'public')));
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
app.set('views', path.join(application_root, 'views'));
app.set('view engine', 'jade');
});
app.get('/', function(req, res){
var definition = "<h1>información para rutas transmilenio</h1>";
res.send(definition);
});
//-------------
// Estaciones
//-------------
var Estacion = mongoose.model('Estacion', new mongoose.Schema({
nombre: String
}));
//Listar Estaciones ej Marly
app.get('/api/estaciones', function(req, res){
return Estacion.find(function(err, estaciones){
return res.send(estaciones);
});
});
//-------------
// Rutas
//-------------
var Ruta = mongoose.model('Ruta', new mongoose.Schema({
nombre: String
}));
//Listar Rutas ej. B14
app.get('/api/rutas', function(req, res){
return Ruta.find(function(err, rutas){
return res.send(rutas);
});
});
app.listen(3000);