-
-
Notifications
You must be signed in to change notification settings - Fork 0
Feat: post api boxes #616
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
Feat: post api boxes #616
Changes from all commits
Commits
Show all changes
95 commits
Select commit
Hold shift + click to select a range
35eeb87
feat: add draft for port of user registration to resource route
scheidtdav 42593f0
feat: partly implement refresh token
scheidtdav dcd635f
docs: simplify contributing and add info about api routes and shared …
scheidtdav be4ebed
feat(api): finalize user registration endpoint
scheidtdav b4b8421
fix(tests): get the tests to run be reconfiguring build steps
scheidtdav 8fbb075
docs(db): readd db setup and seed scripts with README info for it
scheidtdav 1de6e69
fix: wrong import of utils
scheidtdav 08f4405
refactor: remove leftover custom server stuff
scheidtdav 4a3f8e4
fix(tests): add missing refresh token table
scheidtdav 29d3034
fix(tests): reenable remaining tests for registration
scheidtdav d164738
fix(ci): remove playwright and use correct node version
scheidtdav 7566724
fix(ci): run the tests with a postgres container
scheidtdav 44894b4
feat(tests): add coverage report
scheidtdav 77b4cc9
fix(build): reorganize server modules to correctly split client/ server
scheidtdav 5612a5f
fix(build): miss an import
scheidtdav 2e335d5
fix(build): remove leftovers from custom server implementation
scheidtdav bbf5430
chore(deps): bump react-router dependencies
scheidtdav bf19c7e
chore(deps): update react-router
scheidtdav 7d91045
feat/user me api (#559)
scheidtdav a5699de
feat(api): add root route (#560)
scheidtdav 760914b
start
JerryVincent 81a1f9c
new commit
JerryVincent acf1770
tested docs
JerryVincent eedb806
added a route
JerryVincent a6245ea
Added API Docs
JerryVincent 4712c6a
modified
JerryVincent f63dc07
removed unsupported packages
JerryVincent 7741945
updated
JerryVincent 3b620a0
Modified
JerryVincent f51f518
script generation without using ts-node.
JerryVincent 5f7a6ef
modified
JerryVincent f9ecca4
Merge branch 'api-prod' into feat/user-registration-api
scheidtdav bd0e52e
fix: update package-lock.json
scheidtdav 31f793c
Updated (#575)
JerryVincent c5b9835
feat: add command for drizzle studio
jona159 43798ff
feat: devices loader
jona159 a9262df
feat: load single device
jona159 e5f0e9f
feat: uncomment get boxes, delete box path
jona159 87c390d
feat(wip): add boxes test suite
jona159 6301974
feat: add devices service
jona159 e96766c
fix: some types, formatting
jona159 511b94a
Removed duplicate Documentation section (#576)
JerryVincent 98617c3
Update README.md
JerryVincent 9492e13
Feat/api email and password (#561)
scheidtdav 8a721f7
feat/api auth (#562)
scheidtdav ef552e1
feat(api): boxes for user endpoints (#573)
scheidtdav 46e89cd
feat/api misc (#571)
scheidtdav fcf4b8d
Merge branch 'dev' into feat/user-registration-api
jona159 1bd97eb
feat(api): add route and test files
scheidtdav 46b0422
feat: add test code
scheidtdav 787b662
feat: add dummy sensors to devices and implement getting them back
scheidtdav 95acb53
Merge branch 'dev' into feat/api-boxes-sensors
scheidtdav eb84619
feat: prefer dev server in no production envs and hide dev in prod
scheidtdav 84f57ca
feat(docs): start adding docs to route
scheidtdav eeb6049
feat: wip devices api
jona159 a232d6b
Merge branch 'dev' into feat/api-boxes-sensors
scheidtdav cf36b0a
feat: finish up to the point where we need measurements
scheidtdav 0a35d3b
fix: api routes without need for measurements
scheidtdav 89e8c04
fix: stats call
scheidtdav 9a8e679
fix: remaining tests
scheidtdav 32bdb9e
fix: frontend issue from changing the service implementation
scheidtdav 711ea65
fix: tests
scheidtdav 6f1520f
Merge branch 'feat/api-boxes-sensors' into feat/api-boxes
scheidtdav c0713e9
refactor: use modern syntax for assertion
scheidtdav 1bbf604
feat: adjust for zod schema
jona159 38c763f
feat: add drizzle check
jona159 0e60abb
feat: add phenomenon and dates to where clause
jona159 33d52cd
feat: update returned data format of users/me/boxes endpoint to match…
mashazyu cd3ad95
feat: expose additional device attributes
mashazyu f2ebd75
fix: return jwt token as access_token
mashazyu 8e45d96
feat: add post and get /boxes
mashazyu 527d3ef
refactor: move CreateBoxSchema to devices-service.server.ts
mashazyu aa60342
fix: comment get /boxes route since this functionality is not impleme…
mashazyu 65ad8ad
fix: linting errors
mashazyu 8dad3b8
fix: failing tests
mashazyu a000876
feat: add type check
mashazyu 2c359d2
feat: add check for authHeader for GET /users/me/boxes
mashazyu 1541ffe
refactor: return box with sensor data from createDevice
mashazyu fc7b3f3
test: createDevice
mashazyu 1a21ea8
test: post /boxes
mashazyu 7120d4b
fix: return last measurements as string
mashazyu 98417e4
fix: lastMeasurements types
mashazyu f0e928f
fix: linter warnings
mashazyu a91509c
refactor: device.server.ts
mashazyu 527ebf1
fix: linter warnings
mashazyu 392635b
doc: udpate post api documentation
mashazyu 9e41ba3
Merge branch 'dev' into feat/post-api-boxes
mashazyu 8a3a949
fix: after merging dev into current branch.
mashazyu 73021d2
refactor: remove access_token mentions from api responses
mashazyu d39c4fc
refactor: add check for request type for api/boxes endpoint
mashazyu 3fe045c
doc: update api/boxes documentation after allowing different request …
mashazyu 97c5915
refactor: remove unused code and fix linter errors
mashazyu 501a3fd
Merge branch 'dev' into feat/post-api-boxes
mashazyu 9e4d525
fix: linting issues
scheidtdav 396f241
Merge branch 'dev' into feat/post-api-boxes
scheidtdav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,102 @@ | ||
| import { type Device, type Sensor } from '~/schema'; | ||
|
|
||
| export type DeviceWithSensors = Device & { | ||
| sensors: Sensor[]; | ||
| }; | ||
|
|
||
| export type TransformedDevice = { | ||
| _id: string; | ||
| name: string; | ||
| description: string | null; | ||
| image: string | null; | ||
| link: string | null; | ||
| grouptag: string[]; | ||
| exposure: string | null; | ||
| model: string | null; | ||
| latitude: number; | ||
| longitude: number; | ||
| useAuth: boolean | null; | ||
| public: boolean | null; | ||
| status: string | null; | ||
| createdAt: Date; | ||
| updatedAt: Date; | ||
| expiresAt: Date | null; | ||
| userId: string; | ||
| sensorWikiModel?: string | null; | ||
| currentLocation: { | ||
| type: "Point"; | ||
| coordinates: number[]; | ||
| timestamp: string; | ||
| }; | ||
| lastMeasurementAt: string; | ||
| loc: Array<{ | ||
| type: "Feature"; | ||
| geometry: { | ||
| type: "Point"; | ||
| coordinates: number[]; | ||
| timestamp: string; | ||
| }; | ||
| }>; | ||
| integrations: { | ||
| mqtt: { | ||
| enabled: boolean; | ||
| }; | ||
| }; | ||
| sensors: Array<{ | ||
| _id: string; | ||
| title: string | null; | ||
| unit: string | null; | ||
| sensorType: string | null; | ||
| lastMeasurement: { | ||
| value: string; | ||
| createdAt: string; | ||
| } | null; | ||
| }>; | ||
| }; | ||
|
|
||
| /** | ||
| * Transforms a device with sensors from database format to openSenseMap API format | ||
| * @param box - Device object with sensors from database | ||
| * @returns Transformed device in openSenseMap API format | ||
| * | ||
| * Note: Converts lastMeasurement.value from number to string to match API specification | ||
| */ | ||
| export function transformDeviceToApiFormat( | ||
| box: DeviceWithSensors | ||
| ): TransformedDevice { | ||
| const { id, tags, sensors, ...rest } = box; | ||
| const timestamp = box.updatedAt.toISOString(); | ||
| const coordinates = [box.longitude, box.latitude]; | ||
|
|
||
| return { | ||
| _id: id, | ||
| grouptag: tags || [], | ||
| ...rest, | ||
| currentLocation: { | ||
| type: "Point", | ||
| coordinates, | ||
| timestamp | ||
| }, | ||
| lastMeasurementAt: timestamp, | ||
| loc: [{ | ||
| geometry: { type: "Point", coordinates, timestamp }, | ||
| type: "Feature" | ||
| }], | ||
| integrations: { mqtt: { enabled: false } }, | ||
| sensors: sensors?.map((sensor) => ({ | ||
| _id: sensor.id, | ||
| title: sensor.title, | ||
| unit: sensor.unit, | ||
| sensorType: sensor.sensorType, | ||
| lastMeasurement: sensor.lastMeasurement | ||
| ? { | ||
| createdAt: sensor.lastMeasurement.createdAt, | ||
| // Convert numeric values to string to match API specification | ||
| value: typeof sensor.lastMeasurement.value === 'number' | ||
| ? String(sensor.lastMeasurement.value) | ||
| : sensor.lastMeasurement.value, | ||
| } | ||
| : null, | ||
| })) || [], | ||
| }; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.