Update with es6
This commit is contained in:
parent
13dd4b6376
commit
743bb900bb
26
server.js
26
server.js
@ -1,15 +1,13 @@
|
||||
'use strict';
|
||||
|
||||
var express = require('express');
|
||||
var mongo = require('mongodb');
|
||||
var mongoose = require('mongoose');
|
||||
|
||||
var cors = require('cors');
|
||||
|
||||
var app = express();
|
||||
const express = require('express'),
|
||||
mongo = require('mongodb'),
|
||||
mongoose = require('mongoose'),
|
||||
cors = require('cors'),
|
||||
app = express();
|
||||
|
||||
// Basic Configuration
|
||||
var port = process.env.PORT || 3000;
|
||||
const port = process.env.PORT || 3000;
|
||||
|
||||
/** this project needs a db !! **/
|
||||
// mongoose.connect(process.env.MONGOLAB_URI);
|
||||
@ -19,19 +17,19 @@ app.use(cors());
|
||||
/** this project needs to parse POST bodies **/
|
||||
// you should mount the body-parser here
|
||||
|
||||
app.use('/public', express.static(process.cwd() + '/public'));
|
||||
app.use('/public', express.static(`${process.cwd()}/public`));
|
||||
|
||||
app.get('/', function(req, res){
|
||||
res.sendFile(process.cwd() + '/views/index.html');
|
||||
app.get('/', (req, res) => {
|
||||
res.sendFile(`${process.cwd()}/views/index.html`);
|
||||
});
|
||||
|
||||
|
||||
// your first API endpoint...
|
||||
app.get("/api/hello", function (req, res) {
|
||||
app.get("/api/hello", (req, res) => {
|
||||
res.json({greeting: 'hello API'});
|
||||
});
|
||||
|
||||
|
||||
app.listen(port, function () {
|
||||
app.listen(port, () => {
|
||||
console.log('Node.js listening ...');
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user