Skip to content

Commit

Permalink
API initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Freeman committed Aug 15, 2018
0 parents commit 4c34f02
Show file tree
Hide file tree
Showing 7 changed files with 399 additions and 0 deletions.
12 changes: 12 additions & 0 deletions api/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true;

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
11 changes: 11 additions & 0 deletions api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
/node_modules

# misc
.DS_Store

npm-debug.log*
yarn-debug.log*
yarn-error.log*
14 changes: 14 additions & 0 deletions api/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/index.js"
}
]
}
27 changes: 27 additions & 0 deletions api/frameworks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[
"React",
"Angular",
"Vue",
"Aurelia",
"Polymer",
"jQuery",
"Vanilla JavaScript",
"Backbone",
"Preact",
"Ext JS",
"Elm",
"cujoJS",
"Dojo",
"Meteor",
"AngularJS",
"Knockout",
"CanJS",
"Kendo UI",
"Mithril",
"Ember",
"Marko",
"Spine",
"Matreshka.js",
"Hyperapp",
"Stencil"
]
19 changes: 19 additions & 0 deletions api/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const express = require('express');
const frameworks = require('./frameworks');

const app = express();
const port = process.env.PORT || 5001;

app.get('/random', async (req, res) => {
const randomFramework = Math.floor(Math.random() * Math.floor(frameworks.length));

res.json({
framework: frameworks[randomFramework]
});
});

app.listen(port, err => {
if (err) { console.log(err); }

console.log(`API is now available at http://localhost:${port}`)
});
10 changes: 10 additions & 0 deletions api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "api",
"version": "1.0.0",
"main": "index.js",
"license": "GPL 2",
"private": true,
"dependencies": {
"express": "^4.16.3"
}
}
Loading

0 comments on commit 4c34f02

Please sign in to comment.