Skip to content

Commit

Permalink
Merge pull request AdoptOpenJDK#11 from Joe-Brady/api-changes
Browse files Browse the repository at this point in the history
Serve README as webroot, add eslint
  • Loading branch information
Joe Brady authored May 9, 2017
2 parents 0116ab8 + 9fd8405 commit 48c3de5
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 4 deletions.
10 changes: 10 additions & 0 deletions .eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
env:
browser: true
node: true
es6: true
rules:
no-console: 0
no-inner-declarations: 0
globals:

extends: eslint:recommended
2 changes: 0 additions & 2 deletions app/routes/v1.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// curl -H 'accept-version: 1.0.0' api.adoptopenjdk.net/nightly/x64_linux/latest
// curl -H 'accept-version: 1.0.0' api.adoptopenjdk.net/releases/latest?pretty=false

const express = require('express');
const app = express();
const processing = require('./processing-v1');

module.exports = function(req, res) {
Expand Down
57 changes: 57 additions & 0 deletions markdown-layouts/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
body {
padding: 40px 0;
}

h1, h2, h3, h4 {
margin-top: 40px;
}

p {
margin: 15px 0;
}

li {
margin: 10px 0;
}

pre {
border: none;
border-bottom: 3px solid #ccc;
border-radius: 5px;
}

.container {
max-width: 900px;
width: 85%;
padding-left: 0;
padding-right: 0;
}

table {
display: block;
width: 100%;
overflow: auto;
}

table th {
font-weight: 600;
}

table th,table td {
padding: 6px 13px;
border: 1px solid #cecece;
}

table tr {
background-color: white;
border-top: 1px solid #c6cbd1;
}

table tr:nth-child(2n) {
background-color: #f7f7f7;
}

code {
color: #000000;
background-color: #eaeaea;
}
Binary file added markdown-layouts/favicon.ico
Binary file not shown.
22 changes: 22 additions & 0 deletions markdown-layouts/layout.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
doctype html
html
head
meta(charset="utf-8")
meta(http-equiv="X-UA-Compatible", content="IE=edge")
meta(name="viewport", content="width=device-width, initial-scale=1")
link(rel="stylesheet", href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css")
link(rel="stylesheet", href="//highlightjs.org/static/styles/github.css")
link(rel="stylesheet", href="css/style.css")
body

.container
.starter-template

!= markdownFile.parseContent()

footer
hr
| <strong>Last modfied:</strong> #{markdownFile.modified} <br/>

script(src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js")
script(src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js")
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"description": "",
"main": "index.js",
"scripts": {
"start": "nodemon server.js"
"start": "nodemon server.js",
"lint": "eslint *.js app/routes/*.js",
"test": "npm run lint"
},
"author": "",
"license": "ISC",
Expand All @@ -13,9 +15,12 @@
"express": "^4.15.2",
"express-rate-limit": "^2.6.0",
"express-routes-versioning": "^1.0.0",
"markdown-serve": "^0.4.0",
"pug": "^2.0.0-rc.1",
"request": "^2.81.0"
},
"devDependencies": {
"eslint": "^3.19.0",
"nodemon": "^1.11.0"
}
}
19 changes: 18 additions & 1 deletion server.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
const express = require('express');
const bodyParser = require('body-parser');
const RateLimit = require('express-rate-limit');
const mds = require('markdown-serve');
const path = require('path');
const app = express();
const port = 3000;

Expand All @@ -11,11 +13,26 @@ var limiter = new RateLimit({
message: "You have exceeded your api usage, you are allowed 100 requests per hour"
});

// apply to all requests
// apply to all requests
app.use(limiter);
app.use(bodyParser.urlencoded({ extended: true }));

require('./app/routes')(app, {});
app.listen(port, () => {
console.log('We are live on ' + port);
});


// markdown serving
app.set('views', path.resolve(__dirname, './markdown-layouts'));
app.set('view engine', 'pug');
app.use(express.static(path.resolve(__dirname, './markdown-layouts')));

app.get('/', function(req, res){
res.redirect('./README');
});

app.use('/', mds.middleware({
rootDirectory: path.resolve(__dirname, ''),
view: 'layout'
}));

0 comments on commit 48c3de5

Please sign in to comment.