diff --git a/.gitignore b/.gitignore index 9084ebf..6cd5633 100644 --- a/.gitignore +++ b/.gitignore @@ -5,10 +5,9 @@ build # Client /client/node_modules /client/.svelte-kit -/client/src/lib/services +/client/vite.config.ts.timestamp-*.mjs /client/static/openapi # Server /server/client -/server/tmp -/server/internal/services \ No newline at end of file +/server/tmp \ No newline at end of file diff --git a/client/src/lib/services/user/v1/auth_pb.ts b/client/src/lib/services/user/v1/auth_pb.ts new file mode 100644 index 0000000..1a56c4c --- /dev/null +++ b/client/src/lib/services/user/v1/auth_pb.ts @@ -0,0 +1,145 @@ +// @generated by protoc-gen-es v2.2.3 with parameter "target=ts" +// @generated from file user/v1/auth.proto (package user.v1, syntax proto3) +/* eslint-disable */ + +import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv1"; +import { fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv1"; +import type { Message } from "@bufbuild/protobuf"; + +/** + * Describes the file user/v1/auth.proto. + */ +export const file_user_v1_auth: GenFile = /*@__PURE__*/ + fileDesc("ChJ1c2VyL3YxL2F1dGgucHJvdG8SB3VzZXIudjEiMgoMTG9naW5SZXF1ZXN0EhAKCHVzZXJuYW1lGAEgASgJEhAKCHBhc3N3b3JkGAIgASgJIh4KDUxvZ2luUmVzcG9uc2USDQoFdG9rZW4YASABKAkiMwoNU2lnblVwUmVxdWVzdBIQCgh1c2VybmFtZRgBIAEoCRIQCghwYXNzd29yZBgCIAEoCSIQCg5TaWduVXBSZXNwb25zZSIPCg1Mb2dvdXRSZXF1ZXN0IhAKDkxvZ291dFJlc3BvbnNlMsEBCgtBdXRoU2VydmljZRI4CgVMb2dpbhIVLnVzZXIudjEuTG9naW5SZXF1ZXN0GhYudXNlci52MS5Mb2dpblJlc3BvbnNlIgASOwoGU2lnblVwEhYudXNlci52MS5TaWduVXBSZXF1ZXN0GhcudXNlci52MS5TaWduVXBSZXNwb25zZSIAEjsKBkxvZ291dBIWLnVzZXIudjEuTG9nb3V0UmVxdWVzdBoXLnVzZXIudjEuTG9nb3V0UmVzcG9uc2UiAEKdAQoLY29tLnVzZXIudjFCCUF1dGhQcm90b1ABWkZnaXRodWIuY29tL3Nwb3RkZW1vNC90cmV2c3RhY2svc2VydmVyL2ludGVybmFsL3NlcnZpY2VzL3VzZXIvdjE7dXNlcnYxogIDVVhYqgIHVXNlci5WMcoCB1VzZXJcVjHiAhNVc2VyXFYxXEdQQk1ldGFkYXRh6gIIVXNlcjo6VjFiBnByb3RvMw"); + +/** + * @generated from message user.v1.LoginRequest + */ +export type LoginRequest = Message<"user.v1.LoginRequest"> & { + /** + * @generated from field: string username = 1; + */ + username: string; + + /** + * @generated from field: string password = 2; + */ + password: string; +}; + +/** + * Describes the message user.v1.LoginRequest. + * Use `create(LoginRequestSchema)` to create a new message. + */ +export const LoginRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_user_v1_auth, 0); + +/** + * @generated from message user.v1.LoginResponse + */ +export type LoginResponse = Message<"user.v1.LoginResponse"> & { + /** + * @generated from field: string token = 1; + */ + token: string; +}; + +/** + * Describes the message user.v1.LoginResponse. + * Use `create(LoginResponseSchema)` to create a new message. + */ +export const LoginResponseSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_user_v1_auth, 1); + +/** + * @generated from message user.v1.SignUpRequest + */ +export type SignUpRequest = Message<"user.v1.SignUpRequest"> & { + /** + * @generated from field: string username = 1; + */ + username: string; + + /** + * @generated from field: string password = 2; + */ + password: string; +}; + +/** + * Describes the message user.v1.SignUpRequest. + * Use `create(SignUpRequestSchema)` to create a new message. + */ +export const SignUpRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_user_v1_auth, 2); + +/** + * @generated from message user.v1.SignUpResponse + */ +export type SignUpResponse = Message<"user.v1.SignUpResponse"> & { +}; + +/** + * Describes the message user.v1.SignUpResponse. + * Use `create(SignUpResponseSchema)` to create a new message. + */ +export const SignUpResponseSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_user_v1_auth, 3); + +/** + * @generated from message user.v1.LogoutRequest + */ +export type LogoutRequest = Message<"user.v1.LogoutRequest"> & { +}; + +/** + * Describes the message user.v1.LogoutRequest. + * Use `create(LogoutRequestSchema)` to create a new message. + */ +export const LogoutRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_user_v1_auth, 4); + +/** + * @generated from message user.v1.LogoutResponse + */ +export type LogoutResponse = Message<"user.v1.LogoutResponse"> & { +}; + +/** + * Describes the message user.v1.LogoutResponse. + * Use `create(LogoutResponseSchema)` to create a new message. + */ +export const LogoutResponseSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_user_v1_auth, 5); + +/** + * @generated from service user.v1.AuthService + */ +export const AuthService: GenService<{ + /** + * @generated from rpc user.v1.AuthService.Login + */ + login: { + methodKind: "unary"; + input: typeof LoginRequestSchema; + output: typeof LoginResponseSchema; + }, + /** + * @generated from rpc user.v1.AuthService.SignUp + */ + signUp: { + methodKind: "unary"; + input: typeof SignUpRequestSchema; + output: typeof SignUpResponseSchema; + }, + /** + * @generated from rpc user.v1.AuthService.Logout + */ + logout: { + methodKind: "unary"; + input: typeof LogoutRequestSchema; + output: typeof LogoutResponseSchema; + }, +}> = /*@__PURE__*/ + serviceDesc(file_user_v1_auth, 0); + diff --git a/client/src/lib/services/user/v1/user_pb.ts b/client/src/lib/services/user/v1/user_pb.ts new file mode 100644 index 0000000..8a79ef6 --- /dev/null +++ b/client/src/lib/services/user/v1/user_pb.ts @@ -0,0 +1,116 @@ +// @generated by protoc-gen-es v2.2.3 with parameter "target=ts" +// @generated from file user/v1/user.proto (package user.v1, syntax proto3) +/* eslint-disable */ + +import type { GenFile, GenMessage, GenService } from "@bufbuild/protobuf/codegenv1"; +import { fileDesc, messageDesc, serviceDesc } from "@bufbuild/protobuf/codegenv1"; +import type { Message } from "@bufbuild/protobuf"; + +/** + * Describes the file user/v1/user.proto. + */ +export const file_user_v1_user: GenFile = /*@__PURE__*/ + fileDesc("ChJ1c2VyL3YxL3VzZXIucHJvdG8SB3VzZXIudjEiXQoVQ2hhbmdlUGFzc3dvcmRSZXF1ZXN0EhQKDG9sZF9wYXNzd29yZBgBIAEoCRIUCgxuZXdfcGFzc3dvcmQYAiABKAkSGAoQY29uZmlybV9wYXNzd29yZBgDIAEoCSIYChZDaGFuZ2VQYXNzd29yZFJlc3BvbnNlIjsKDUFQSUtleVJlcXVlc3QSEAoIcGFzc3dvcmQYASABKAkSGAoQY29uZmlybV9wYXNzd29yZBgCIAEoCSIdCg5BUElLZXlSZXNwb25zZRILCgNrZXkYASABKAkynwEKC1VzZXJTZXJ2aWNlElMKDkNoYW5nZVBhc3N3b3JkEh4udXNlci52MS5DaGFuZ2VQYXNzd29yZFJlcXVlc3QaHy51c2VyLnYxLkNoYW5nZVBhc3N3b3JkUmVzcG9uc2UiABI7CgZBUElLZXkSFi51c2VyLnYxLkFQSUtleVJlcXVlc3QaFy51c2VyLnYxLkFQSUtleVJlc3BvbnNlIgBCnQEKC2NvbS51c2VyLnYxQglVc2VyUHJvdG9QAVpGZ2l0aHViLmNvbS9zcG90ZGVtbzQvdHJldnN0YWNrL3NlcnZlci9pbnRlcm5hbC9zZXJ2aWNlcy91c2VyL3YxO3VzZXJ2MaICA1VYWKoCB1VzZXIuVjHKAgdVc2VyXFYx4gITVXNlclxWMVxHUEJNZXRhZGF0YeoCCFVzZXI6OlYxYgZwcm90bzM"); + +/** + * @generated from message user.v1.ChangePasswordRequest + */ +export type ChangePasswordRequest = Message<"user.v1.ChangePasswordRequest"> & { + /** + * @generated from field: string old_password = 1; + */ + oldPassword: string; + + /** + * @generated from field: string new_password = 2; + */ + newPassword: string; + + /** + * @generated from field: string confirm_password = 3; + */ + confirmPassword: string; +}; + +/** + * Describes the message user.v1.ChangePasswordRequest. + * Use `create(ChangePasswordRequestSchema)` to create a new message. + */ +export const ChangePasswordRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_user_v1_user, 0); + +/** + * @generated from message user.v1.ChangePasswordResponse + */ +export type ChangePasswordResponse = Message<"user.v1.ChangePasswordResponse"> & { +}; + +/** + * Describes the message user.v1.ChangePasswordResponse. + * Use `create(ChangePasswordResponseSchema)` to create a new message. + */ +export const ChangePasswordResponseSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_user_v1_user, 1); + +/** + * @generated from message user.v1.APIKeyRequest + */ +export type APIKeyRequest = Message<"user.v1.APIKeyRequest"> & { + /** + * @generated from field: string password = 1; + */ + password: string; + + /** + * @generated from field: string confirm_password = 2; + */ + confirmPassword: string; +}; + +/** + * Describes the message user.v1.APIKeyRequest. + * Use `create(APIKeyRequestSchema)` to create a new message. + */ +export const APIKeyRequestSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_user_v1_user, 2); + +/** + * @generated from message user.v1.APIKeyResponse + */ +export type APIKeyResponse = Message<"user.v1.APIKeyResponse"> & { + /** + * @generated from field: string key = 1; + */ + key: string; +}; + +/** + * Describes the message user.v1.APIKeyResponse. + * Use `create(APIKeyResponseSchema)` to create a new message. + */ +export const APIKeyResponseSchema: GenMessage = /*@__PURE__*/ + messageDesc(file_user_v1_user, 3); + +/** + * @generated from service user.v1.UserService + */ +export const UserService: GenService<{ + /** + * @generated from rpc user.v1.UserService.ChangePassword + */ + changePassword: { + methodKind: "unary"; + input: typeof ChangePasswordRequestSchema; + output: typeof ChangePasswordResponseSchema; + }, + /** + * @generated from rpc user.v1.UserService.APIKey + */ + aPIKey: { + methodKind: "unary"; + input: typeof APIKeyRequestSchema; + output: typeof APIKeyResponseSchema; + }, +}> = /*@__PURE__*/ + serviceDesc(file_user_v1_user, 0); + diff --git a/flake.lock b/flake.lock index 4af3133..eabc3b4 100644 --- a/flake.lock +++ b/flake.lock @@ -18,6 +18,26 @@ "type": "github" } }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1741513245, @@ -37,6 +57,7 @@ "root": { "inputs": { "flake-utils": "flake-utils", + "gitignore": "gitignore", "nixpkgs": "nixpkgs" } }, diff --git a/flake.nix b/flake.nix index f3a69d5..e002ace 100644 --- a/flake.nix +++ b/flake.nix @@ -4,15 +4,21 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; + gitignore = { + url = "github:hercules-ci/gitignore.nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; - outputs = { self, nixpkgs, flake-utils }: + outputs = { self, nixpkgs, flake-utils, gitignore }: flake-utils.lib.eachDefaultSystem (system: + let pkgs = import nixpkgs { inherit system; config.allowUnfree = true; }; + protoc-gen-connect-openapi = pkgs.buildGoModule rec { name = "protoc-gen-connect-openapi"; src = pkgs.fetchFromGitHub { @@ -24,6 +30,13 @@ vendorHash = "sha256-CIiG/XhV8xxjYY0sZcSvIFcJ1Wh8LyDDwqem2cSSwBA="; nativeCheckInputs = with pkgs; [ less ]; }; + + client = pkgs.buildNpmPackage { + name = "client"; + src = gitignore.lib.gitignoreSource ./client; + npmDepsHash = "sha256-hOmZZrCSuHyRQhG6M7Yu5uRLTdCYOL/giT4zUm9iTRE="; + }; + in { devShells.default = pkgs.mkShell { @@ -106,9 +119,11 @@ ]; }; - packages.default = pkgs.stdenv.mkDerivation { + packages.default = pkgs.buildGoModule { pname = "trevstack"; version = "1.0"; + src = gitignore.lib.gitignoreSource ./server; + vendorHash = ""; buildInputs = with pkgs; [ # Go backend @@ -127,24 +142,8 @@ nodejs_22 ]; - buildPhase = '' - gitroot=$(git rev-parse --show-toplevel) - - cd "''${gitroot}" - buf lint - buf generate - - cd "''${gitroot}/client" - npm run build - cp -r build ../server/client - - cd "''${gitroot}/server" - go build -o ../build/trevstack . - ''; - - installPhase = '' - mkdir -p $out/bin - cp build/trevstack $out/bin + configurePhase = '' + cp -r ${client} client ''; }; }