-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMiddleware.cs
executable file
·67 lines (55 loc) · 2.14 KB
/
Middleware.cs
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
66
67
using CodeMechanic.Types;
using Neo4j.Driver;
namespace nugsnet6;
public static class AirtableConfigurations
{
public static void ConfigureAirtable(this IServiceCollection services)
{
string PAT = Environment.GetEnvironmentVariable("NUGS_PAT");
string base_key = Environment.GetEnvironmentVariable("NUGS_BASE_KEY");
if (string.IsNullOrEmpty(PAT) || string.IsNullOrEmpty(base_key))
return;
// services.AddHttpClient<IAirtableRepo, AirtableRepo>(client =>
// {
// client.BaseAddress = new Uri($"https://api.airtable.com/v0/{PAT}");
// return new AirtableRepo(client, base_key, PAT);
// });
}
}
public static class Neo4jConfigurations
{
public static void ConfigureNeo4j(this IServiceCollection services)
{
bool is_devmode = (
Environment.GetEnvironmentVariable("DEVMODE") ?? string.Empty
).ToBoolean();
string uri =
(
is_devmode
? Environment.GetEnvironmentVariable("LOCAL_NEO4J_URI")
: Environment.GetEnvironmentVariable("NEO4J_URI")
) ?? string.Empty;
string user =
(
is_devmode
? Environment.GetEnvironmentVariable("LOCAL_NEO4J_USER")
: Environment.GetEnvironmentVariable("NEO4J_USER")
) ?? string.Empty;
string password =
(
is_devmode
? Environment.GetEnvironmentVariable("LOCAL_NEO4J_PASSWORD")
: Environment.GetEnvironmentVariable("NEO4J_PASSWORD")
) ?? string.Empty;
Console.WriteLine("neo uri: " + uri);
Console.WriteLine("neo user: " + user);
Console.WriteLine("neo pwd: " + password);
services.AddControllers();
services.ConfigureAirtable();
// Allow empty uri for the sake of launching w/o neo4j support
if (string.IsNullOrEmpty(uri))
return;
services.AddSingleton(GraphDatabase.Driver(uri, AuthTokens.Basic(user, password)));
// services.AddTransient<IAirtableRepo, AirtableRepo>();
}
}