Open xgqfrms-GitHub opened 7 years ago
{
"name": "node-express4-restful-api",
"version": "4.15.2",
"description": "RESTful-API-Node-Express4, xgqfrms",
"main": "index.js",
"scripts": {
"start": "node server.js",
"run": "node server.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/xgqfrms/node-express4-restful-api.git"
},
"keywords": [
"RESTful",
"API",
"Node",
"Express4",
"MongoDB",
"Mongoose"
],
"author": "xgqfrms, webgeeker",
"license": "MIT",
"bugs": {
"url": "https://github.com/xgqfrms/node-express4-restful-api/issues"
},
"homepage": "https://github.com/xgqfrms/node-express4-restful-api#readme",
"dependencies": {
"body-parser": "^1.17.1",
"express": "^4.15.2",
"mongoose": "^4.9.8",
"morgan": "^1.8.1"
}
}
// configure our application and create routes
const express = require('express'),
const app = express();
const bodyParser = require('body-parser');
const port = process.env.PORT || 8080;
app.use(
bodyParser.urlencoded(
{
extended: true
}
)
);
app.use(
bodyParser.json()
);
let router = express.Router();
// http://localhost:8080/api
router.get('/', function(req, res) {
res.json({ message: 'hooray! welcome to our api!' });
});
router.get('/:id', function(req, res) {
res.json({ message: 'hooray! welcome to our api id!' });
});
app.use('/api', router);
app.listen(port);
console.log('Magic happens on port ' + port);
node js es6 import
https://stackoverflow.com/questions/37132031/nodejs-plans-to-support-import-export-es6-es2015-modules
https://medium.com/the-node-js-collection/an-update-on-es6-modules-in-node-js-42c958b890c
https://segmentfault.com/a/1190000006864073
https://github.com/nodejs/help/issues/53
https://github.com/nodejs/node/wiki/ES6-Module-Detection-in-Node http://stackoverflow.com/questions/37132031/nodejs-plans-to-support-import-export-es6-es2015-modules http://stackoverflow.com/questions/31354559/using-node-js-require-vs-es6-import-export
https://nodejs.org/en/docs/es6/
https://codequs.com/p/Byvv408t/using-es6-import-export-in-node-js-babel-js/