-
Notifications
You must be signed in to change notification settings - Fork 0
feat: create "identity" field for Site and update endpoints accordingly #12
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
base: main
Are you sure you want to change the base?
Conversation
Add two new API endpoints for site management: - /api/secure-site with POST, PUT, and DELETE operations for authenticated site management - /api/public-sites with GET operation to retrieve public sites list Regenerated schema.d.ts using make build-typescript to include TypeScript definitions for the new endpoints and their request/response types.
add mongoose schema to represent Site. includes support for required fields such as name, coordinates, status, address, and cell_id, as well as optional fields like color and boundary with validation.
- Add POST /api/secure-site to create new sites - Add PUT /api/secure-site to update existing sites - Add DELETE /api/secure-site to remove sites
Routes were missing leading slash causing 404 errors for /api/secure-site
Create /api/public-sites GET route that returns list of sites
Apply suggested changes from code review
Update public sites endpoint name to /api/sites
…changes to ensure compatability
- Create secure-site.test.ts to test all the functions in secure-site.ts with exhaustive cases - Update package.json to include an "npm run test" script to run tests - Change secure-site.ts to use event handlers for ease of testing
|
One thing, use a more descriptive branch name for each PR. This will help tell the work quickly :) |
src/routes/secure-site.ts
Outdated
|
|
||
| // Generate identity using SHA256 hash | ||
| const skpk = siteData.name; | ||
| const identity = crypto.createHash('sha256').update(skpk).digest('hex'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the identity is generated from skpk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just copied what was being done for User, I changed it to reflect the name correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this is correct. Site identity should not have any association with private key
|
Can you also briefly describe the new design in the comment section? |
|
Can you move this to the description section at the top? |
Essentially, I added an additional "identity" field to uniquely identify Sites that is generated each time a new site is created
![Uploading Database.png…]()