-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
40 lines (34 loc) · 1.13 KB
/
index.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
import "dotenv/config";
import { createRpcDataSource } from "@forestadmin-experimental/datasource-rpc";
import { createAgent } from "@forestadmin/agent";
import type { Schema } from "./typings";
(async () => {
const agent = createAgent<Schema>({
authSecret: process.env.GATEWAY_FOREST_AUTH_SECRET as string,
envSecret: process.env.GATEWAY_FOREST_ENV_SECRET as string,
isProduction: process.env.NODE_ENV === "production",
schemaPath: `${__dirname}/.forestadmin-schema.json`,
typingsPath: `${__dirname}/typings.d.ts`,
typingsMaxDepth: 5,
});
agent
.addDataSource(
createRpcDataSource({
uri: process.env.RPC_1_URL as string,
authSecret: process.env.RPC_1_AUTH_SECRET as string,
}),
)
.addDataSource(
createRpcDataSource({
uri: process.env.RPC_2_URL as string,
authSecret: process.env.RPC_2_AUTH_SECRET as string,
}),
);
agent.customizeCollection("companies", (companyBuilder) => {
companyBuilder.addManyToOneRelation("owner", "users", {
foreignKey: "user_id",
});
});
agent.mountOnStandaloneServer(9876);
await agent.start();
})();