atproto pastebin service: https://plonk.li

update env vars

+60 -9
+51
flake.nix
··· 48 48 }); 49 49 50 50 formatter = forAllSystems (system: nixpkgsFor."${system}".alejandra); 51 + 52 + nixosModules.default = { 53 + config, 54 + pkgs, 55 + lib, 56 + ... 57 + }: 58 + with lib; { 59 + options = { 60 + services.plonk = { 61 + enable = mkOption { 62 + type = types.bool; 63 + default = false; 64 + description = "Enable plonk"; 65 + }; 66 + port = mkOption { 67 + type = types.int; 68 + default = 3000; 69 + description = "Port to run plonk on"; 70 + }; 71 + cookie_secret = mkOption { 72 + type = types.string; 73 + default = "00000000000000000000000000000000"; 74 + description = "Cookie secret"; 75 + }; 76 + }; 77 + }; 78 + 79 + config = mkIf config.services.plonk.enable { 80 + nixpkgs.overlays = [self.overlays.default]; 81 + systemd.services.plonk = { 82 + description = "plonk service"; 83 + wantedBy = ["multi-user.target"]; 84 + 85 + serviceConfig = { 86 + ListenStream = "0.0.0.0:${toString config.services.plonk.port}"; 87 + ExecStart = "${pkgs.plonk}/bin/plonk"; 88 + Restart = "always"; 89 + }; 90 + 91 + environment = { 92 + PLONK_PORT = "${toString config.services.plonk.port}"; 93 + PLONK_NODE_ENV = "production"; 94 + PLONK_HOST = "localhost"; 95 + PLONK_PUBLIC_URL = "plonk.li"; 96 + PLONK_DB_PATH = "plonk.db"; 97 + PLONK_COOKIE_SECRET = config.services.plonk.cookie_secret; 98 + }; 99 + }; 100 + }; 101 + }; 51 102 }; 52 103 }
+6 -6
src/lib.ts
··· 4 4 dotenv.config(); 5 5 6 6 export const env = cleanEnv(process.env, { 7 - NODE_ENV: str({ 7 + PLONK_NODE_ENV: str({ 8 8 devDefault: testOnly("test"), 9 9 choices: ["development", "production", "test"], 10 10 }), 11 - HOST: host({ devDefault: testOnly("localhost") }), 12 - PORT: port({ devDefault: testOnly(3000) }), 13 - PUBLIC_URL: str({}), 14 - DB_PATH: str({ devDefault: ":memory:" }), 15 - COOKIE_SECRET: str({ devDefault: "00000000000000000000000000000001" }), 11 + PLONK_HOST: host({ devDefault: testOnly("localhost") }), 12 + PLONK_PORT: port({ devDefault: testOnly(3000) }), 13 + PLONK_PUBLIC_URL: str({}), 14 + PLONK_DB_PATH: str({ devDefault: ":memory:" }), 15 + PLONK_COOKIE_SECRET: str({ devDefault: "00000000000000000000000000000000" }), 16 16 });
+3 -3
src/routes.ts
··· 26 26 ) { 27 27 const session = await getIronSession<Session>(req, res, { 28 28 cookieName: "plonk-id", 29 - password: env.COOKIE_SECRET, 29 + password: env.PLONK_COOKIE_SECRET, 30 30 }); 31 31 if (!session.did) return null; 32 32 try { ··· 59 59 const { session } = await ctx.oauthClient.callback(params); 60 60 const clientSession = await getIronSession<Session>(req, res, { 61 61 cookieName: "plonk-id", 62 - password: env.COOKIE_SECRET, 62 + password: env.PLONK_COOKIE_SECRET, 63 63 }); 64 64 //assert(!clientSession.did, "session already exists"); 65 65 clientSession.did = session.did; ··· 99 99 router.get("/logout", async (req, res) => { 100 100 const session = await getIronSession<Session>(req, res, { 101 101 cookieName: "plonk-id", 102 - password: env.COOKIE_SECRET, 102 + password: env.PLONK_COOKIE_SECRET, 103 103 }); 104 104 session.destroy(); 105 105 return res.redirect("/");