Showing
1 changed file
with
20 additions
and
0 deletions
app.js
0 → 100644
| 1 | +const express = require('express'); | ||
| 2 | +const app = express(); | ||
| 3 | +const bodyParser=require('body-parser'); | ||
| 4 | +const morgan=require('morgan'); | ||
| 5 | +const cors = require('cors'); | ||
| 6 | + | ||
| 7 | +app.use( cors( ) ); | ||
| 8 | +app.use(morgan('[:date[iso]] :method :status :url :response-time(ms) :user-agent')); | ||
| 9 | +app.use(bodyParser.urlencoded({ extended: true })); | ||
| 10 | +app.use(bodyParser.json()); | ||
| 11 | +app.use((req, res, next)=>{ | ||
| 12 | + res.header("Access-Control-Allow-Origin","*"); | ||
| 13 | + res.header("Access-Control-Allow-Headers","Origin, X-Requested-With, Content-Type, Accept"); | ||
| 14 | + next(); | ||
| 15 | + }); | ||
| 16 | +app.use( '/api', require('./api') ); | ||
| 17 | + | ||
| 18 | +app.listen(3000, ( ) => { | ||
| 19 | + console.log('Server On!'); | ||
| 20 | +}); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment