-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
executable file
·65 lines (54 loc) · 1.69 KB
/
app.js
File metadata and controls
executable file
·65 lines (54 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
var express = require("express");
var cors = require("cors");
var bodyParser = require("body-parser");
var app = express();
var linaroTerms = [
{
term: "LSK",
defined: "Linaro Stable Kernel: A great starting point for your development"
},
{
term: "DevCloud",
defined: "An ARM-based server cloud using OpenStack to manage resource provisioning."
},
{
term: "96Boards",
defined: "An Open Source hardware specification for developing ARM-based hardware development platforms."
},
{
term: "LDTS",
defined: "Linaro Developer Technical Support - Get expert help on Linaro technologies."
},
{
term: "Linaro Downloads",
defined: "Go to http://www.linaro.org/downloads/ to get the lates builds from Linaro."
},
{
term: "LAVA",
defined: "Linaro Automated Validation Architecture: An Open Source Test Automation Framework(TAF) by Linaro."
}
];
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(function(req, res, next) {
console.log(`${req.method} request for '${req.url}' - ${JSON.stringify(req.body)}`);
next();
});
app.use(express.static("./public"));
app.use(cors());
app.get("/dictionary-api", function(req, res) {
res.json(linaroTerms);
});
app.post("/dictionary-api", function(req, res) {
linaroTerms.push(req.body);
res.json(linaroTerms);
});
app.delete("/dictionary-api/:term", function(req, res) {
linaroTerms = linaroTerms.filter(function(definition) {
return definition.term.toLowerCase() !== req.params.term.toLowerCase();
});
res.json(linaroTerms);
});
app.listen(3000);
console.log("Linaro Dictionary running on port 3000");
module.exports = app;