Skip to content

Commit

Permalink
Change structure
Browse files Browse the repository at this point in the history
  • Loading branch information
sigorilla committed Feb 7, 2020
1 parent d0f375a commit 43c402f
Show file tree
Hide file tree
Showing 20 changed files with 15 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module.exports = {
'no-empty': ['error', {allowEmptyCatch: true}],
},
overrides: [{
files: 'client/**/*.js',
files: 'src/client/**/*.js',
env: {
node: false,
browser: true
Expand Down
3 changes: 1 addition & 2 deletions .tesselinclude
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
.env
server/
client/
src/
node_modules/socket.io-client/dist/socket.io.js
node_modules/justgage/*js
19 changes: 6 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,28 @@

Node: 8.11.3

## Examples

* [without j5 lib](./examples/index.js)
* [j5 leds blinking](./example/led-blink.js)
* [j5 sensor](./example/sensor.js)
* [j5 button](./example/button.js)

### Try example

```sh
npm run try -- example/sensor.js
npm run try -- example/index.js
```

## Projects

```sh
t2 ap -n <SSID_NAME>
t2 run server/<PROJECT>/index.js
# Connect to http://<tessel_name>.local/<PROJECT>/
t2 run src/server/<PROJECT>/index.js
# Connect to http://<tessel_name>/<PROJECT>/
```

Available projects:
- `motors` — control servo via socket.io.
- `monitor` — BME-280.s
- `monitor` — BME-280.

### Deploy

```
t2 push server/<PROJECT>/index.js
```sh
npx t2 push src/server/<PROJECT>/index.js
```

## Auth
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "tessel",
"version": "0.0.1",
"description": "Tessel project",
"main": "example/index.js",
"main": "examples/index.js",
"dependencies": {
"date-fns": "1.30.1",
"debug": "2.6.8",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 2 additions & 6 deletions server/lib/server.js → src/server/lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@

const http = require('http');
const path = require('path');

const express = require('express');

const app = express();
const server = new http.Server(app);

const assetsPath = path.join(__dirname, '../../client');
const vendorPath = path.join(__dirname, '../../node_modules');

app
const app = express()
.use(express.static(assetsPath))
.use('/vendor', express.static(vendorPath))
.use((_req, res) => {
Expand All @@ -22,4 +18,4 @@ app
res.sendStatus(500);
});

module.exports = server;
module.exports = new http.Server(app);
2 changes: 1 addition & 1 deletion server/monitor/index.js → src/server/monitor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function onReady() {
});

server.listen(PORT, () => {
console.log(`Server started, go to http://${os.hostname()}`);
console.log(`Server started, go to http://${os.hostname()}/motors/`);
});

process.on('SIGINT', () => server.close());
Expand Down
2 changes: 1 addition & 1 deletion server/motors/index.js → src/server/motors/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function onReady() {
});

server.listen(PORT, () => {
console.log(`Server started, go to http://${os.hostname()}`);
console.log(`Server started, go to http://${os.hostname()}/motors/`);
});

process.on('SIGINT', () => server.close());
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const MAX_VALUE = 500;
const NOTIFY_THRESHOLD = MAX_VALUE / 2;
const NOTIFY_DELAY = 5000;

// https://ifttt.com/maker_webhooks
const ifttt = new IFTTTMaker({
token: process.env.IFTTT_TOKEN
});
Expand Down Expand Up @@ -67,7 +68,7 @@ function onReady() {
});

server.listen(PORT, () => {
console.log(`Server started, go to http://${os.hostname()}`);
console.log(`Server started, go to http://${os.hostname()}/water-level/`);
});

process.on('SIGINT', () => server.close());
Expand Down

0 comments on commit 43c402f

Please sign in to comment.