Skip to content

go api #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Jul 1, 2023
Merged

go api #85

merged 19 commits into from
Jul 1, 2023

Conversation

chronark
Copy link
Collaborator

  • wip
  • feat: feature parity with old api
  • test: api tests

@vercel
Copy link

vercel bot commented Jun 29, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unkey ❌ Failed (Inspect) Jul 1, 2023 7:31pm

@gitguardian
Copy link

gitguardian bot commented Jun 29, 2023

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id Secret Commit Filename
7164998 Stripe Keys 7730c53 apps/api/tmp_reset.ts View secret
7164998 Stripe Keys 9bdc6e3 apps/api/tmp_reset.ts View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

chronark added 4 commits June 30, 2023 15:02
fix(key_verify.go): add caching of key in verifyKey function
fix(keys_list.go): fix typo in ownerId field name, change ownereId to ownerId
chronark added 2 commits June 30, 2023 21:33
fix(fly.toml): change min_machines_running value to 0
fix(package.json): remove package.json file
fix(memory.go): change Get method signature to include refresh parameter
fix(memory.go): change Set method signature to include ttl parameter
fix(memory_test.go): remove Ttl field from cache.Config in tests
fix(logger.go): change logger level to DebugLevel
fix(ratelimit.go): add check to ensure remaining does not exceed max
fix(api_get_test.go): remove Ttl field from cache.Config in test
fix(key_create_test.go): remove Ttl field from cache.Config in test
fix(key_delete_test.go): remove Ttl field from cache.Config in test

fix(server/key_verify.go): import go.uber.org/zap package
fix(server/key_verify.go): change variable name authHash to hash
fix(server/key_verify.go): change variable name cached to key
fix(server/key_verify.go): add error handling for key not found in cache
fix(server/key_verify.go): add error handling for key not found in database
fix(server/key_verify.go): remove key from cache if expired
fix(server/key_verify.go): add error handling for deleting key from database
fix(server/key_verify.go): set key in cache after retrieving from database
fix(server/key_verify.go): remove unnecessary cache set
fix(server/key_verify_test.go): remove Ttl field from cache config
fix(server/key_verify_test.go): remove Ttl field from cache config
fix(server/key_verify_test.go): remove Ttl field from cache config
fix(server/key_verify_test.go): remove Ttl field from cache config
fix(server/keys_list_test.go):
The debug log statement for cache.get was removed as it is no longer needed for debugging purposes.
chore(deploy-api.yaml): remove working-directory from flyctl deploy command
chore(.env.example): remove unused environment variables
chore(Taskfile.yml): add generate task for buf
chore(buf.gen.yaml): add buf.gen.yaml file for buf generation
chore(buf.yaml): add buf.yaml file for buf configuration
chore(main.go): remove unused imports and variables, add database and cache middleware
chore(docker-compose.yml): add docker-compose.yml file for API service
chore(fly.preview.toml): add fly.preview.toml file for fly.io configuration
chore(fly.toml): update fly.toml file with new app name and timestamp
chore(memory.go): remove tracing dependency, update Set and Get methods
chore(memory_test.go): remove tracing dependency, update test cases

feat(api): add tracing middleware to cache package
fix(database): fix receiver name in CreateApi and GetApi methods
feat(database): add interface for database package
fix(database): fix receiver name in CreateKey method
fix(database): fix receiver name in DeleteKey method
fix(database): fix receiver name in GetKeyByHash method
fix(database): fix receiver name in GetKeyById method
fix(database): fix receiver name in CountKeys method
fix(database): fix receiver name in ListKeysByApiId method

feat(database): add tracing middleware for database operations

feat(database): add tracing middleware for CreateApi operation

feat(database): add tracing middleware for GetApi operation

feat(database): add tracing middleware for CreateKey operation

feat(database): add tracing middleware for DeleteKey operation

feat(database): add tracing middleware for GetKeyByHash operation

feat(database): add tracing middleware for GetKeyById operation

feat(database): add tracing middleware for CountKeys operation

feat(database): add tracing middleware for ListKeysByApiId operation

feat(database): add tracing middleware for CreateWorkspace operation

feat(database): add tracing middleware for GetWorkspace operation

refactor(database): rename Database struct to database

refactor(database): rename New function to NewDatabase

feat(server): add support for generating unique keys with prefix and byte length
feat(keys): implement function to generate new key with prefix and byte length
fix(server): handle error when generating new key in key_create.go

fix(server.ts): change port variable case from lowercase port to uppercase PORT
feat(server.ts): add support for process.env.PORT environment variable
refactor(key_create_test.go): remove unused Tracer dependency
refactor(key_create_test.go): remove unused Tracer dependency
refactor(key_delete_test.go): remove unused Tracer dependency
refactor(key_verify.go): remove unused net/http and time dependencies
refactor(key_verify.go): add logging for key verification
refactor(key_verify_test.go): remove unused Tracer dependency
refactor(key_verify_test.go): remove unused Tracer dependency
refactor(keys_list_test.go): remove unused Tracer dependency
refactor(keys_list_test.go): remove unused Tracer dependency
refactor(server.go): remove unnecessary type declarations
refactor(server.go): add comment explaining Fly-Region header
refactor(server.go): remove unnecessary comment
refactor(server.go): remove unnecessary comment
refactor(server.go): remove unnecessary comment
ref
…entity

fix(database): add support for converting name field in key entity to model
fix(database): add name field to key model
fix(database): add name field to key insert query
fix(database): add name field to key update query
fix(database): add name field to key upsert query
fix(database): add name field to key select queries
fix(entities): add name field to key entity

fix(server.go): add route for creating root keys internally
feat(server.go): implement createRootKey handler for creating root keys
fix(key_create.go): remove unused import "crypto/subtle"
feat(key_create.go): add validation for "apiId" field in CreateKeyRequest
feat(key_create.go): add "name" field to CreateKeyRequest
feat(key_create.go): retrieve authKey using authHash
feat(key_create.go): validate authKey type and workspaceId
feat(key_create.go): retrieve api using req.ApiId
feat(key_create.go): validate api workspaceId matches authKey workspaceId
feat(key_create.go): generate new key using keys.NewKey
feat(key_create.go): create newKey entity with relevant fields
feat(key_create.go): store newKey in database
feat(root_key_create.go): implement createRootKey handler for creating root keys
feat(root_key_create.go): validate request body and authorization token
feat(root_key_create.go):

fix(env.ts): add UNKEY_API_URL environment variable with default value
feat(api/index.ts): add unkeyScoped and unkeyRoot functions to interact with Unkey API
fix(key.ts): update createRootKey and createInternalRootKey mutations to use new Unkey API functions
fix(server.ts): change port variable case from lowercase port to uppercase PORT
fix(CreateKey.tsx): update snippet to use process.env.NEXT_PUBLIC_UNKEY_API_URL environment variable
fix(page.tsx): update keys variable to only include non-expired keys and delete expired keys
fix(CreateKeyButton.tsx): update snippet to use process.env.NEXT_PUBLIC_UNKEY_API_URL environment variable
fix(page.tsx): update keys variable to only include non-expired keys and delete expired keys
delete(base58.ts): remove unused base58 encoding function
delete(base64.ts): remove unused base64 encoding function

chore(keys.ts): add 'name' field to the keys schema
chore(keys.ts): remove unnecessary comment about expires field
feat(index.ts): add 'name' field to the create method in the Unkey class
feat(index.ts): add '_internal' property to the Unkey class for creating root keys
fix(main.go): add support for PlanetscaleBoost environment variable
fix(database/planetscale.go): change logger variable name to logger
fix(database/planetscale.go): add support for PlanetscaleBoost environment variable
fix(server/api_get_test.go): add logger to database.New function call
fix(server/key_create_test.go): add logger to database.New function call
fix(server/key_delete_test.go): add logger to database.New function call
fix(server/key_verify_test.go): add logger to database.New function call
fix(server/keys_list_test.go): add logger to database.New function call
fix(server/root_key_create_test.go): add logger to database.New function call
fix(testutil/setup.go): add logger to database.New function call
chore(api): remove buf.gen.yaml, buf.yaml, fly.preview.toml, key.pb.go, and key.proto files
fix(api): update app name in fly.toml from "unkey-global-api" to "unkey-api-production"
refactor(api): update key_test.go to use NewV1Key instead of NewKey

fix(keys.go): fix import order and remove unused import
feat(keys.go): add support for version 1 keys
fix(keys.go): fix NewKey function to use keyV1 struct
fix(keys.go): fix DecodeKey function to use keyV1 struct
fix(keys.go): fix versionToBytes function to return byte slice
fix(keys.go): fix versionFromBytes function to return uint8
feat(keys.go): add NewV1Key function to generate version 1 keys
fix(key_create.go): use NewV1Key function to generate keys
fix(root_key_create.go): use NewV1Key function to generate keys
fix(root_key_create_test.go): remove unused imports and use resources.Database
fix(root_key_create_test.go): remove unused imports and use resources.Database
fix(root_key_create_test.go): remove unused imports and use resources.Database
fix(root_key_create_test.go): remove unused imports and use resources.Database
fix(testutil/setup.go):
fix(CreateKey.tsx): fix condition for deleting meta property
fix(CreateKey.tsx): fix condition for deleting meta property
fix(CreateKey.tsx): fix indentation and formatting
fix(CreateKey.tsx): fix indentation and formatting
fix(CreateKey.tsx): fix indentation and formatting
fix(CreateKey.tsx): fix indentation and formatting
fix(CreateKey.tsx): fix indentation and formatting
fix(CreateKey.tsx): fix indentation and formatting
fix(CreateKey.tsx): fix indentation and formatting
fix(CreateKey.tsx): fix indentation and formatting
fix(CreateKey.tsx): fix indentation and formatting
fix(CreateKey.tsx): fix indentation and formatting
fix(CreateKey.tsx): fix indentation and formatting
fix(CreateKey.tsx): fix indentation and formatting
fix(CreateKey.tsx): fix indentation and formatting
fix(CreateKey.tsx): fix indentation and formatting
fix(CreateKey.ts
@chronark chronark merged commit 4647d98 into main Jul 1, 2023
@chronark chronark deleted the go-api branch July 1, 2023 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants