This repository has been archived by the owner on Jul 31, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add gulp tasks to bootstrap server
- Loading branch information
Showing
6 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"presets": [ | ||
"es2015" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PORT=5000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
'use strict'; | ||
|
||
import dotenv from 'dotenv'; | ||
import gulp from 'gulp'; | ||
import del from 'del'; | ||
import gulpLoadPlugins from 'gulp-load-plugins'; | ||
import browserSync from 'browser-sync'; | ||
|
||
const $ = gulpLoadPlugins(); | ||
const SERVER = 'dist/server'; | ||
browserSync.create(); | ||
dotenv.config({silent: true}); | ||
|
||
/** | ||
* Task jshint | ||
* Use js lint | ||
*/ | ||
gulp.task('jshint', ['jscs'], () => { | ||
return gulp.src([ | ||
'server/**/*.js', | ||
'gulfile.js', | ||
]) | ||
.pipe($.jshint('.jshintrc')) | ||
.pipe($.jshint.reporter('default')) | ||
.pipe($.jshint.reporter('fail')); | ||
}); | ||
|
||
/** | ||
* Task jscs | ||
* Use js cs lint | ||
*/ | ||
gulp.task('jscs', () => { | ||
return gulp.src([ | ||
'server/**/*.js', | ||
'gulfile.js', | ||
]) | ||
.pipe($.jscs('.jscsrc')) | ||
.pipe($.jscs.reporter()) | ||
.pipe($.jscs.reporter('fail')); | ||
}); | ||
|
||
/** | ||
* Task reload | ||
* reload the browser after executing default | ||
*/ | ||
gulp.task('reload', ['default'], () => { | ||
browserSync.reload(); | ||
}); | ||
|
||
/** | ||
* Task serve | ||
* launch an express server | ||
*/ | ||
gulp.task('serve', () => { | ||
const server = $.liveServer.new('server/server.js'); | ||
server.start(); | ||
}); | ||
|
||
/** | ||
* Task clean | ||
* Remove dist directory | ||
*/ | ||
gulp.task('clean', () => { | ||
return del([ | ||
SERVER, | ||
]); | ||
}); | ||
|
||
/** | ||
* Task test | ||
* Build the project and test for it's consistency | ||
*/ | ||
gulp.task('test', ['jscs']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use strict'; | ||
|
||
var express = require('express'); | ||
var router = express.Router(); | ||
|
||
/* GET home page. */ | ||
router.get('/', function(req, res, next) { | ||
res.json({ | ||
message: 'Welcome to Nutrient!' | ||
}); | ||
}); | ||
|
||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
|
||
var express = require('express'); | ||
var dotenv = require('dotenv'); | ||
dotenv.config({silent: true}); | ||
|
||
var app = express(); | ||
var PORT = process.env.PORT || 3000; | ||
var index = require('./routes/index.js'); | ||
|
||
app.use(index); | ||
|
||
app.listen(PORT, () => { | ||
console.log('app listening on port ' + PORT + '!'); | ||
}); |