Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
mjhea0 committed Nov 4, 2016
0 parents commit f5fc549
Show file tree
Hide file tree
Showing 2,524 changed files with 675,981 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
.DS_Store
43 changes: 43 additions & 0 deletions .jshintrc
@@ -0,0 +1,43 @@
{
"globals": {
"esnext": true,
"jasmine": false,
"spyOn": false,
"it": false,
"console": false,
"describe": false,
"expect": false,
"beforeEach": false,
"afterEach": false,
"waits": false,
"waitsFor": false,
"runs": false,
"$": false,
"confirm": false
},
"esnext": true,
"node" : true,
"browser" : true,
"boss" : false,
"curly": false,
"debug": false,
"devel": false,
"eqeqeq": true,
"evil": true,
"forin": false,
"immed": true,
"laxbreak": false,
"newcap": true,
"noarg": true,
"noempty": false,
"nonew": false,
"nomen": false,
"onevar": true,
"plusplus": false,
"regexp": false,
"undef": true,
"sub": true,
"strict": false,
"white": true,
"unused": false
}
35 changes: 35 additions & 0 deletions dist/App.js
@@ -0,0 +1,35 @@
"use strict";
const express = require('express');
const logger = require('morgan');
const bodyParser = require('body-parser');
// Creates and configures an ExpressJS web server.
class App {
//Run configuration methods on the Express instance.
constructor() {
this.express = express();
this.middleware();
this.routes();
}
// Configure Express middleware.
middleware() {
this.express.use(logger('dev'));
this.express.use(bodyParser.json());
this.express.use(bodyParser.urlencoded({ extended: false }));
}
// Configure API endpoints.
routes() {
/* This is just to get up and running, and to make sure what we've got is
* working so far. This function will change when we start to add more
* API endpoints */
let router = express.Router();
// placeholder route handler
router.get('/', (req, res, next) => {
res.json({
message: 'Hello World!'
});
});
this.express.use('/', router);
}
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = new App().express;
42 changes: 42 additions & 0 deletions dist/index.js
@@ -0,0 +1,42 @@
"use strict";
const http = require('http');
const debug = require('debug');
const App_1 = require('./App');
debug('ts-express:server');
const port = normalizePort(process.env.PORT || 3000);
App_1.default.set('port', port);
const server = http.createServer(App_1.default);
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
function normalizePort(val) {
let port = (typeof val === 'string') ? parseInt(val, 10) : val;
if (isNaN(port))
return val;
else if (port >= 0)
return port;
else
return false;
}
function onError(error) {
if (error.syscall !== 'listen')
throw error;
let bind = (typeof port === 'string') ? 'Pipe ' + port : 'Port ' + port;
switch (error.code) {
case 'EACCES':
console.error(`${bind} requires elevated privileges`);
process.exit(1);
break;
case 'EADDRINUSE':
console.error(`${bind} is already in use`);
process.exit(1);
break;
default:
throw error;
}
}
function onListening() {
let addr = server.address();
let bind = (typeof addr === 'string') ? `pipe ${addr}` : `port ${addr.port}`;
debug(`Listening on ${bind}`);
}
27 changes: 27 additions & 0 deletions dist/src/App.js
@@ -0,0 +1,27 @@
"use strict";
const express = require("express");
const logger = require("morgan");
const bodyParser = require("body-parser");
class App {
constructor() {
this.express = express();
this.middleware();
this.routes();
}
middleware() {
this.express.use(logger('dev'));
this.express.use(bodyParser.json());
this.express.use(bodyParser.urlencoded({ extended: false }));
}
routes() {
let router = express.Router();
router.get('/', (req, res, next) => {
res.json({
message: 'Hello World!'
});
});
this.express.use('/', router);
}
}
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = new App().express;
42 changes: 42 additions & 0 deletions dist/src/index.js
@@ -0,0 +1,42 @@
"use strict";
const http = require("http");
const debug = require("debug");
const App_1 = require("./App");
debug('ts-express:server');
const port = normalizePort(process.env.PORT || 3000);
App_1.default.set('port', port);
const server = http.createServer(App_1.default);
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
function normalizePort(val) {
let port = (typeof val === 'string') ? parseInt(val, 10) : val;
if (isNaN(port))
return val;
else if (port >= 0)
return port;
else
return false;
}
function onError(error) {
if (error.syscall !== 'listen')
throw error;
let bind = (typeof port === 'string') ? 'Pipe ' + port : 'Port ' + port;
switch (error.code) {
case 'EACCES':
console.error(`${bind} requires elevated privileges`);
process.exit(1);
break;
case 'EADDRINUSE':
console.error(`${bind} is already in use`);
process.exit(1);
break;
default:
throw error;
}
}
function onListening() {
let addr = server.address();
let bind = (typeof addr === 'string') ? `pipe ${addr}` : `port ${addr.port}`;
debug(`Listening on ${bind}`);
}
65 changes: 65 additions & 0 deletions dist/test/helloWorld.test.js
@@ -0,0 +1,65 @@
"use strict";
const chai = require("chai");
const chaiHttp = require("chai-http");
const App_1 = require("../src/App");
chai.use(chaiHttp);
const expect = chai.expect;
describe('baseRoute', () => {
it('should be json', () => {
chai.request(App_1.default).get('/')
.then(res => {
return expect(res).to.be('json');
});
});
it('should have a message prop', () => {
chai.request(App_1.default).get('/')
.then(res => {
return expect(res).to.have.property('message');
});
});
});
describe('GET api/v1/heroes', () => {
it('responds with JSON array', () => {
return chai.request(App_1.default).get('/api/v1/heroes')
.then(res => {
expect(res.status).to.equal(200);
expect(res).to.be.json;
expect(res.body).to.be.an('array');
expect(res.body).to.have.length(5);
});
});
it('should include Wolverine', () => {
return chai.request(App_1.default).get('/api/v1/heroes')
.then(res => {
let Wolverine = res.body.find(hero => hero.name === 'Wolverine');
expect(Wolverine).to.exist;
expect(Wolverine).to.have.all.keys([
'id',
'name',
'aliases',
'occupation',
'gender',
'height',
'hair',
'eyes',
'powers'
]);
});
});
});
describe('GET api/v1/heroes/:id', () => {
it('responds with single JSON object', () => {
return chai.request(App_1.default).get('/api/v1/heroes/1')
.then(res => {
expect(res.status).to.equal(200);
expect(res).to.be.json;
expect(res.body).to.be.an('object');
});
});
it('should return Luke Cage', () => {
return chai.request(App_1.default).get('/api/v1/heroes/1')
.then(res => {
expect(res.body.hero.name).to.equal('Luke Cage');
});
});
});
17 changes: 17 additions & 0 deletions gulpfile.js
@@ -0,0 +1,17 @@
const gulp = require('gulp');
const ts = require('gulp-typescript');

// pull in the project TypeScript config
const tsProject = ts.createProject('tsconfig.json');

gulp.task('scripts', () => {
const tsResult = tsProject.src()
.pipe(tsProject());
return tsResult.js.pipe(gulp.dest('dist'));
});

gulp.task('watch', ['scripts'], () => {
gulp.watch('src/**/*.ts', ['scripts']);
});

gulp.task('default', ['watch']);
1 change: 1 addition & 0 deletions node_modules/.bin/_mocha

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/dateformat

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/gulp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/mime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/mkdirp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/mocha

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/semver

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/strip-indent

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/ts-node

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/tsc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/tsserver

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/user-home

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/which

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions node_modules/@types/body-parser/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f5fc549

Please sign in to comment.