-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
28 lines (24 loc) · 912 Bytes
/
Copy pathindex.js
File metadata and controls
28 lines (24 loc) · 912 Bytes
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
const server = require("server");
const middleware = require("./middleware");
const { get, post, put, del } = require("server/router");
const { json, send, status } = require("server/reply");
const got = require("got");
const analyticScriptResponseJSON = require("./analyticScript");
const LOGINJSON = require("./LOGIN");
const analyticScriptResponse = ctx => json(analyticScriptResponseJSON);
const LOGIN = ctx => json(LOGINJSON);
const getBootstrapContext = async ctx => {
try {
const response = await got(
"https://marketplace.appdirect.com/api/session/v1/bootstrap-context"
);
return status(200).send(response.body);
} catch (error) {
console.log(error.response.body);
}
};
server({ port: 3001 }, middleware, [
get("/api/analyticScript", analyticScriptResponse),
get("/api/analyticScript/LOGIN", LOGIN),
get("/api/session/v1/bootstrap-context", getBootstrapContext)
]);