forked from team-piranha/NoteTakerExtension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
50 lines (38 loc) · 1.32 KB
/
server.js
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
var path = require("path");
var express = require("express");
var db = require("./database/db.js");
var bodyParser = require("body-parser");
var handle = require("./server/requestHandler.js");
var app = express();
app.use(bodyParser.json());
app.use(express.static(path.join(__dirname, "/public")));
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header(
"Access-Control-Allow-Headers",
"Origin, X-Requested-With, Content-Type, Accept"
);
res.header(
"Access-Control-Allow-Methods",
"OPTIONS, DELETE, POST, GET, UPDATE"
);
next();
});
//WEB APP ENDPOINTS//
app.get("/", function(req, res) {
res.send("Hello, humans!");
});
app.get('/api/watson/concepts', handle.watsonConcepts);
app.get('/api/watson/categories', handle.watsonCategories);
app.get('/api/watson/read', handle.watsonTextToSpeech);
app.get('/api/watson/translate', handle.watsonTranslate);
app.get("/api/users/:id", handle.usersGet);
app.post("/api/users/", handle.userPost);
app.delete("/api/users/urls", handle.urlRemove);
app.post("/api/users/notes/", handle.userAddNotes);
app.delete("/api/users/notes", handle.noteRemove);
app.post("/api/users/annotations/", handle.userAddAnnotations);
var port = process.env.PORT || 3003;
app.listen(port, () => {
console.log(`server listening at ${port}`);
});