xgqfrms-GitHub / node-express4-restful-api

RESTful-API-Node-Express4
https://github.com/xgqfrms/node-express4-restful-api
MIT License
1 stars 1 forks source link

node js es6 import #2

Open xgqfrms-GitHub opened 7 years ago

xgqfrms-GitHub commented 7 years ago

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/

xgqfrms-GitHub commented 7 years ago

https://expressjs.com/en/4x/api.html

xgqfrms-GitHub commented 7 years ago

https://scotch.io/tutorials/build-a-restful-api-using-node-and-express-4

xgqfrms-GitHub commented 7 years ago

http://blog.herobs.cn/es6-in-depth-classes/ http://blog.herobs.cn/es6-in-depth-subclassing/

http://www.ruanyifeng.com/blog/2017/05/css-variables.html

xgqfrms-GitHub commented 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"
    }
}
xgqfrms-GitHub commented 7 years ago
// 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);
xgqfrms commented 4 years ago

module.exports & exports

Node.js

https://www.cnblogs.com/xgqfrms/p/13582032.html