Added: Postgrest Endpoint for Learnlytics Database; WIP: Swagger for Learnlytics endpoint
This commit is contained in:
@@ -5,43 +5,85 @@
|
||||
|
||||
{
|
||||
# PostgREST service
|
||||
systemd.services.postgrest = {
|
||||
description = "PostgREST - PostgreSQL REST API";
|
||||
after = [
|
||||
"postgresql.service"
|
||||
"network.target"
|
||||
];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
systemd.services = {
|
||||
postgrest = {
|
||||
description = "PostgREST - PostgreSQL REST API";
|
||||
after = [
|
||||
"postgresql.service"
|
||||
"network.target"
|
||||
];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
ExecStart = "${pkgs.postgrest}/bin/postgrest /etc/postgrest/postgrest.conf";
|
||||
User = "postgrest";
|
||||
Restart = "on-failure";
|
||||
RestartSec = 5;
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
ExecStart = "${pkgs.postgrest}/bin/postgrest /etc/postgrest/postgrest.conf";
|
||||
User = "postgrest";
|
||||
Restart = "on-failure";
|
||||
RestartSec = 5;
|
||||
};
|
||||
};
|
||||
|
||||
# PostgREST service for learnlytics database
|
||||
postgrest-learnlytics = {
|
||||
description = "PostgREST - Learnlytics API";
|
||||
after = [
|
||||
"postgresql.service"
|
||||
"network.target"
|
||||
];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
ExecStart = "${pkgs.postgrest}/bin/postgrest /etc/postgrest/postgrest-learnlytics.conf";
|
||||
User = "postgrest";
|
||||
Restart = "on-failure";
|
||||
RestartSec = 5;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Create postgrest user
|
||||
users.users.postgrest = {
|
||||
isSystemUser = true;
|
||||
group = "postgrest";
|
||||
users = {
|
||||
users.postgrest = {
|
||||
isSystemUser = true;
|
||||
group = "postgrest";
|
||||
};
|
||||
|
||||
groups.postgrest = { };
|
||||
};
|
||||
|
||||
users.groups.postgrest = { };
|
||||
|
||||
# PostgREST configuration file
|
||||
environment.etc."postgrest/postgrest.conf".text = ''
|
||||
db-uri = "postgres://postgres:postgres@127.0.0.1:5432/postgres"
|
||||
db-schema = "public"
|
||||
db-anon-role = "web_anon"
|
||||
server-host = "0.0.0.0"
|
||||
server-port = 3000
|
||||
jwt-secret = "no7WwM0xJa/Yzn5o4IZHG4oBNSShl4JRPZOcmhvnqFw="
|
||||
'';
|
||||
environment.etc = {
|
||||
"postgrest/postgrest.conf".text = ''
|
||||
db-uri = "postgres://postgres:1P2h3i4lon@127.0.0.1:5432/postgres"
|
||||
db-schema = "public"
|
||||
db-anon-role = "web_anon"
|
||||
server-host = "0.0.0.0"
|
||||
server-port = 3000
|
||||
server-proxy-uri = "http://192.168.2.200:3000"
|
||||
jwt-secret = "no7WwM0xJa/Yzn5o4IZHG4oBNSShl4JRPZOcmhvnqFw="
|
||||
server-cors-allowed-origins = "*"
|
||||
openapi-server-proxy-uri = "http://192.168.2.200:3000"
|
||||
'';
|
||||
|
||||
# PostgREST configuration for learnlytics database
|
||||
"postgrest/postgrest-learnlytics.conf".text = ''
|
||||
db-uri = "postgres://postgres:1P2h3i4lon@127.0.0.1:5432/learnlytics"
|
||||
db-schema = "public"
|
||||
db-anon-role = "web_anon"
|
||||
server-host = "0.0.0.0"
|
||||
server-port = 3001
|
||||
server-proxy-uri = "http://192.168.2.200:3001"
|
||||
jwt-secret = "dnjudqZC0Fby2DEo3Xt2nY98KlHxxqT7NWvLk5aKmew="
|
||||
server-cors-allowed-origins = "*"
|
||||
'';
|
||||
};
|
||||
|
||||
# Open firewall port for PostgREST
|
||||
networking.firewall.allowedTCPPorts = [ 3000 ];
|
||||
networking.firewall.allowedTCPPorts = [
|
||||
3000
|
||||
3001
|
||||
];
|
||||
|
||||
# Include postgrest in system packages
|
||||
environment.systemPackages = with pkgs; [
|
||||
|
||||
Reference in New Issue
Block a user