-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.ts
56 lines (47 loc) · 1.58 KB
/
app.ts
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
import "./env";
import * as express from "express";
import * as ParseDashboard from "parse-dashboard";
import { ParseServer } from "parse-server";
import * as path from "path";
const app = express();
const STAGE = process.env.STAGE;
const cloud = ((global as any).__TESTING__ || process.env.TS) ?
path.resolve(__dirname, "cloud.ts") :
path.resolve(__dirname, "cloud.js");
const api = new ParseServer({
appId: process.env.APP_ID,
cloud, // Absolute path to your Cloud Code
databaseURI: process.env.DATABASE_URI, // Connection string for your MongoDB database
fileKey: process.env.FILE_KEY,
javascriptKey: process.env.JS_KEY,
masterKey: process.env.MASTER_KEY, // Keep this key secret!
serverURL: process.env.SERVER_URL, // Don't forget to change to https if needed
});
const dashboard = new ParseDashboard({
allowInsecureHTTP: true,
apps: [{
appId: process.env.APP_ID,
appName: `Parse serverless (${process.env.NODE_ENV})`,
fileKey: process.env.FILE_KEY,
javascriptKey: process.env.JS_KEY,
masterKey: process.env.MASTER_KEY,
production: process.env.NODE_ENV === "production" || process.env.NODE_ENV === "staging",
serverURL: process.env.SERVER_URL,
}],
useEncryptedPasswords: false,
users: [{
pass: process.env.DASHBOARD_PASS,
user: process.env.DASHBOARD_USERNAME,
}],
}, {
allowInsecureHTTP: true,
cookieSessionSecret: "parse-serverless",
});
app.use("/parse", api);
// Workaround for having dashboards on Lambda
if (STAGE) {
app.use(`/${STAGE}/dashboard`, dashboard);
} else {
app.use("/dashboard", dashboard);
}
export default app;