| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- /**
- * Main application file
- */
- 'use strict';
- var express = require('express');
- var app = express();
- var mongoose = require('mongoose');
- mongoose.connect('mongodb://localhost/eba');
- require('./routes')(app);
- app.get('/', function (req, res) {
- res.send('Hello World!')
- })
- function allowCrossDomain(req, res, next) {
- res.header('Access-Control-Allow-Origin', '*');
- res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
- res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With');
-
- // intercept OPTIONS method
- if ('OPTIONS' === req.method) {
- res.send(200);
- }
- else {
- next();
- }
- }
- app.use(allowCrossDomain);
- try {
- app.listen(3000, function () {
- console.log('Example app listening on port 3000!')
- })
- } catch (error) {
- console.error(error);
- }
|