Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Aldhanekaa committed Jun 21, 2021
2 parents 2cbe831 + 91d104a commit cc7bcd0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 30 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ hi there

to be able run the bash (sh files extension) script, please run these first to your terminal

```js
```shell
chmod +x log.sh
chmod +x commit.sh
chmod +x test.sh
chmod +x about.sh

```

3 changes: 2 additions & 1 deletion src/graphql/typeDefs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,15 @@ export default gql`
type ArduinoSensorData {
_id: ID!
data: Int
date: Int
date: String
}
type ArduinoSensor {
_id: ID!
name: String!
own: String!
appID: String!
data: [ArduinoSensorData]
}
# arduino app
Expand Down
57 changes: 32 additions & 25 deletions src/routes/any.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,34 +72,41 @@ AnyRouter.get('/allData', async (req, res) => {
AnyRouter.get('/api/getArduinoApp', async (req, res) => {
const { appId } = req.query;

const App = await ArduinoApp.findById(appId);
// const App = await AppDoc?.getApp();

if (App) {
const AppSensors = await Sensor.find({ appID: App?._id });

// @ts-ignore
App.token = '';

AppSensors.forEach((sensor) => {
App.sensors.push(sensor._id);
});

res.send({
message: 'app found!',
status: 'success',
app: Object.assign(
{},
// @ts-ignore
App._doc,
// @ts-ignore
{ sensors: App.sensors },
),
});
try {
const App = await ArduinoApp.findById(appId);
// const App = await AppDoc?.getApp();

if (App) {
const AppSensors = await Sensor.find({ appID: App?._id });

// @ts-ignore
App.token = '';

AppSensors.forEach((sensor) => {
App.sensors.push(sensor._id);
});

res.send({
message: 'app found!',
status: 'success',
app: Object.assign(
{},
// @ts-ignore
App._doc,
// @ts-ignore
{ sensors: App.sensors },
),
});
return;
}
}catch(err) {
res.send({ message: 'app not found', status: 'warning' });
return;
}


res.send({ message: 'app not found', status: 'warning' });
return;
});

AnyRouter.get('/api/getSensor', async (req, res) => {
Expand All @@ -110,7 +117,7 @@ AnyRouter.get('/api/getSensor', async (req, res) => {

if (sensor) {
res.send({
message: 'app found!',
message: 'sensor found!',
status: 'success',
sensor: sensor,
});
Expand Down
1 change: 0 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ app.use('/auth', cors(corsOptions), AuthRouter);
app.use('/contact', cors(corsOptions), ContactRouter);
app.use(
'/arduino',
cors(corsOptions),
ArduinoRouter,
);
app.use('/', StoryRouter);
Expand Down

0 comments on commit cc7bcd0

Please sign in to comment.