Comments (8)
Hii @glaslos ,
I am exited to work on this issue .
Meanwhile if i run backend server locally what arguments do i need to pass with "go run server.go" to pass token middleware .
from ochi.
You can just use make or copy the command from here
from ochi.
Can you check if my approach is correct to address this issue .
- Intercept the msg variable from here .
- Decode this msg []byte back to go object by taking reference of Event interface used in frontend .
- Pull out sensorID from this object .
- Alter it according to conditions.
- Convert back into []byte.
- Call cs.publish function .
from ochi.
Yes, that sound about right. Maybe try without defining the Event type too specific, maybe a map[string]interface{}
does the trick here.
from ochi.
Please check if my snippet is correct and let me know how can i test this , i mean how these endpoints will be called when i run locally go server. afterward i will generate PR.
At line
I will put this below snippet in action :
`// Unmarshal the JSON message into a map
var data map[string]interface{}
if err := json.Unmarshal(msg, &data); err != nil {
http.Error(w, "Invalid JSON payload", http.StatusBadRequest)
return
}
// Check if "sensorID" key exists
if sensorID, ok := data["sensorID"].(string); ok {
// Manipulate the "sensorID"
sensorID = splitSensorID(sensorID)
// Update the map with the new "sensorID" value
data["sensorID"] = sensorID
}
// Marshal the map back to a JSON message
alteredMsg , err := json.Marshal(data)
if err != nil {
http.Error(w, "Error processing JSON", http.StatusInternalServerError)
return
}
cs.publish(alteredMsg)
//Helper function which splits into two parts the sensorID by the hyphen
func splitSensorID(sensorID string) string {
parts := strings.Split(sensorID, "-")
if len(parts) > 0 {
return parts[0]
}
return sensorID // Return the original sensorID if there's no hyphen
}`
from ochi.
Yes, this looks good!
from ochi.
I was curious to know , why havn't we implemented Lint , and designed test cases for both Frontend and backend . Let me if maintainers are looking into this field . I would be happy to implement these .
from ochi.
I will add linting in the GitHub actions in the future. Considering we are only a few people working in this at the moment, we didn't consider it a priority. Same for the testing, right now we do a lot of manual tests before we release. But feel free to add more tests!
from ochi.
Related Issues (20)
- Unable to reset event filter
- Improved filter input HOT 1
- Add syntactic content assistance to the filter field HOT 3
- Improve readability of Content component HOT 1
- Make Content component responsive
- Uncaught (in promise) DOMException: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded. HOT 2
- Add tags to saved queries
- Add a modal popup for editing a saved query
- Implement hot reloading for golang backend
- Add Apply button on My Queries page HOT 1
- Support for UDP events in the event filter HOT 1
- Apply all enable, saved queries to incoming events HOT 2
- Add prometheus for server metrics
- Add a page to list all sensors HOT 1
- Add a button to create a new sensor HOT 2
- Per sensor add delete button HOT 1
- Per sensor add download button for ARM and AMD64 binaries
- New endpoints to return config and rules by sensor uuid HOT 2
- Authenticate sensors by sensor UUID HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ochi.