Skip to content

Commit

Permalink
Merge pull request #28 from nci-ats/dev
Browse files Browse the repository at this point in the history
Initial Node.js Express setup
  • Loading branch information
brianfunk authored Feb 16, 2017
2 parents 8ee6886 + a222a8d commit 85c46b1
Show file tree
Hide file tree
Showing 8 changed files with 751 additions and 5 deletions.
34 changes: 34 additions & 0 deletions .gitignore
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
42 changes: 42 additions & 0 deletions .npmignore
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
103 changes: 103 additions & 0 deletions index.js
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;

//*******************************************************************
Loading

0 comments on commit 85c46b1

Please sign in to comment.