mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 03:00:58 +08:00
26 lines
638 B
TypeScript
26 lines
638 B
TypeScript
import * as bodyParser from 'body-parser';
|
|
import * as express from 'express';
|
|
|
|
const app = express();
|
|
|
|
app.set('port', process.env.PORT || 5000);
|
|
|
|
app.use(bodyParser.urlencoded({extended: true}));
|
|
app.use(bodyParser.json());
|
|
|
|
app.use(function(req, res, next) {
|
|
res.header('Access-Control-Allow-Origin', '*');
|
|
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE');
|
|
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization');
|
|
|
|
next();
|
|
});
|
|
|
|
app.post('/test', (req, res) => {
|
|
res.send(req.body);
|
|
});
|
|
|
|
app.listen(app.get('port'), () => {
|
|
console.log('Node app is running on port', app.get('port'));
|
|
});
|