Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/node_modules/*
**/docs/*
**/vendor/*
**/*.min.js
**/coverage/*
**/build/*
25 changes: 25 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"env": {
"browser": true,
"node": true,
"commonjs": true,
"jest": true,
"es6": true
},
"globals": {
"fail":true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2018
},
"rules": {
"no-console": "off",
"indent": [ "error", 2 ],
"quotes": ["error", "single", { "allowTemplateLiterals": true }],
"comma-dangle": ["error", "always-multiline"],
"semi": [ "error", "always" ],
"no-unused-vars": [1, {"vars": "local", "args": "none"}]
}
}
109 changes: 109 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@

# Created by https://www.gitignore.io/api/vim,osx,linux,node
db
temp
.env
*.env
package-lock.json
aws.yml

**/docs/*
!**/docs/config/
!**/docs/swagger.json

# ignore the webstorm ide dir
.idea/

### Vim ###
# swap
[._]*.s[a-w][a-z]
[._]s[a-w][a-z]
# session
Session.vim
# temporary
.netrwhist
*~
# auto-generated tag files
tags


### OSX ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk


### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*


### Node ###
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# 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
8 changes: 8 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
language: node_js
node_js:
- "stable"

script:
- npm run lint
- npm test

43 changes: 42 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,42 @@
# lab00
# LAB - 00

## POL Server

### Author: Morgan Shaw

### Links and Resources
* [submission PR] https://github.com/morgan-401-advanced-javascript/lab00/pull/1
* [travis]https://travis-ci.com/morgan-401-advanced-javascript/lab00
* [front-end](http://xyz.com) https://lab00morgan401.herokuapp.com

#### Documentation
* [jsdoc] Unable to get jsdocs to work

### Modules
#### `modulename.js`
##### Exported Values and Methods

###### `foo(thing) -> string`
Usage Notes or examples

###### `bar(array) -> array`
Usage Notes or examples

### Setup
#### `.env` requirements
* `PORT` - 3000

#### Running the app
* `npm start`
* Endpoint: `/foo/bar/`
* Returns a JSON object with abc in it.
* Endpoint: `/bing/zing/`
* Returns a JSON object with xyz in it.

#### Tests
* How do you run tests?
* What assertions were made?
* What assertions need to be / should be made?

#### UML
Link to an image of the UML for your application and response to events
15 changes: 15 additions & 0 deletions __test__/pol.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

let pol = require('../pol.js');

describe('proof of life', () => {

it('lives by default', () => {
expect(pol.isAlive()).toBeTruthy();
});

it('dies with a param', () => {
expect(pol.isAlive('x')).toBeFalsy();
});

});
10 changes: 10 additions & 0 deletions docs/config/jsdoc.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"source": {
"include" : ["./"],
"exclude" : ["./node_modules"]
},
"opts": {
"destination": "./docs/",
"recurse": true
}
}
34 changes: 34 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
'use strict';

/**
* Simple Server
* @module index
*/


const express = require('express');

const pol = require('./pol.js');

const app = express();

app.use('/docs', express.static('./docs'));

/**
* / Request Handler (All Routes)
* @param req
* @param res
*/

app.get('/', requestHandler);

function requestHandler(req,res) {
res.setHeader('Content-Type', 'text/html');
res.statusCode = 200;
let isItAlive = pol.isAlive(req.query.dead).toString();
res.write( isItAlive );
res.end();
}

app.listen(process.env.PORT, () => console.log('server up') );

23 changes: 23 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "401-js-proof-of-life",
"version": "1.0.0",
"description": "Proof of Life",
"main": "index.js",
"scripts": {
"start": "node index.js",
"lint": "eslint '**/*.js'",
"test": "jest --verbose --coverage",
"test-watch": "jest --watchAll --verbose --coverage",
"jsdoc": "jsdoc -c ./docs/config/jsdoc.config.json"
},
"author": "John Cokos",
"license": "MIT",
"devDependencies": {
"eslint": "^6.1.0",
"eslint-plugin-react": "^7.14.3",
"jest": "^24.8.0"
},
"dependencies": {
"express": "^4.17.1"
}
}
18 changes: 18 additions & 0 deletions pol.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

/**
* Proof Of Life
* @module pol
*/

/**
* Proof of life - will return a boolean value
* @param dead
* @returns {boolean}
* @function isAlive
*/
const isAlive = function(dead = false) {
return !(dead);
};

module.exports = {isAlive};