-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from nci-ats/dev
Initial Node.js Express setup
- Loading branch information
Showing
8 changed files
with
751 additions
and
5 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,34 @@ | ||
# DotEnv | ||
.env | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history |
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,42 @@ | ||
# Tests | ||
test | ||
tests | ||
testing | ||
|
||
# Services | ||
.codeclimate.yml | ||
.travis.yml | ||
codecov.yml | ||
.gitignore | ||
|
||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
node_modules | ||
jspm_packages | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history |
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,103 @@ | ||
/* | ||
___ ___ ___ _ _ _ ___ ___ | ||
| __/ __| ___| _ \___ _ _ _ __ (_) |_ /_\ | _ \_ _| | ||
| _|\__ \ / -_) _/ -_) '_| ' \| | _| / _ \| _/| | | ||
|_| |___/ \___|_| \___|_| |_|_|_|_|\__| /_/ \_\_| |___| | ||
*/ | ||
|
||
//******************************************************************* | ||
|
||
'use strict'; | ||
|
||
//******************************************************************* | ||
// required modules | ||
|
||
require('dotenv').config(); | ||
|
||
var express = require('express'); | ||
var helmet = require('helmet'); | ||
var cors = require('cors'); | ||
|
||
var path = require('path'); | ||
var fsr = require('file-stream-rotator'); | ||
var mkdirp = require('mkdirp'); | ||
var morgan = require('morgan'); | ||
|
||
//******************************************************************* | ||
// environment variables | ||
|
||
var PORT = process.env.PORT; | ||
|
||
//******************************************************************* | ||
|
||
var app = express(); | ||
|
||
app.use(cors()); | ||
app.use(helmet()); | ||
|
||
// ********************************************************** | ||
// log | ||
|
||
var logDirectory = path.join(__dirname,'/log'); | ||
|
||
mkdirp(logDirectory); | ||
|
||
var accessLogStream = fsr.getStream({ | ||
filename: logDirectory + '/fs-epermit-api-%DATE%.log', | ||
frequency: 'daily', | ||
verbose: false | ||
}); | ||
|
||
app.use(morgan('combined', {stream: accessLogStream})); | ||
|
||
//******************************************************************* | ||
//Public | ||
app.use(express.static('public')); | ||
|
||
//******************************************************************* | ||
//generic routes | ||
|
||
app.get('/permit', function(req,res){ | ||
var output = { | ||
"success" : true, | ||
"api": "FS ePermit API" | ||
}; | ||
res.json(output); | ||
}); | ||
|
||
app.post('/permit', function(req,res){ | ||
var output = { | ||
"success" : true, | ||
"api": "FS ePermit API" | ||
}; | ||
res.json(output); | ||
}); | ||
|
||
app.put('/permit', function(req,res){ | ||
var output = { | ||
"success" : true, | ||
"api": "FS ePermit API" | ||
}; | ||
res.json(output); | ||
}); | ||
|
||
//******************************************************************* | ||
// listen | ||
|
||
var server = app.listen(PORT, function () { | ||
|
||
var host = server.address().address; | ||
var port = server.address().port; | ||
|
||
console.log('\n listening at http://%s:%s', host, port); | ||
|
||
}); | ||
|
||
//******************************************************************* | ||
// exports | ||
|
||
module.exports = app; | ||
|
||
//******************************************************************* |
Oops, something went wrong.