Skip to content
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

Make better CI progress #95

Merged
merged 8 commits into from
Jan 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ node_modules/
encryption/
data/
logs/
.env
.env
coverage
.nyc_output
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
matrix:
include:
-
before_install:
- "cd backend"
language: node_js
node_js:
- stable
install:
- npm install
env:
- TEST_LONG_SPECS=false
script:
- npm run cover
after_script: "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js"
-
before_install:
- "cd frontend"
language: node_js
node_js:
- stable
install:
- npm install
script:
- npm run build
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ Let's create a smart home, without giving anyone access to our house 😊.
## CASA-NET.
Open-source server to control IoT devices in a local home network.


[![Build Status](https://travis-ci.org/casanet/casanet-server.svg?branch=master)](https://travis-ci.org/casanet/casanet-server)
[![Coverage Status](https://coveralls.io/repos/github/casanet/casanet-server/badge.svg?branch=master)](https://coveralls.io/github/casanet/casanet-server?branch=master)


## Philosophy.
In this project, I wanted to solve a number of troubles. first of all, anyone who uses a number of smart devices (smart IR, smart socket, or anything of that kind) of different companies is familiar with the problem of dealing with a number of different applications;
holding 10 applications for each home appliance when each is completely different in the interface and operations and authentication.
Expand Down
5 changes: 5 additions & 0 deletions backend/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"printWidth": 120,
"trailingComma": "all",
"singleQuote": true
}
16 changes: 7 additions & 9 deletions backend/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,16 @@
"sourceMaps": true,
"smartStep": true,
"internalConsoleOptions": "openOnSessionStart",
"outFiles": [
"${workspaceFolder}/dist/**/*.js"
],
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"env": {
"NODE_ENV": "debug",
"NODE_ENV": "debug"
}
},
{
"type": "node",
"request": "launch",
"name": "Mocha Tests",
"preLaunchTask": "npm: test",
"preLaunchTask": "npm: test:unit",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"env": {
"NODE_ENV": "test",
Expand All @@ -36,15 +34,15 @@
"999999",
"--colors",
"--recursive",
"${workspaceFolder}/test/**/*.spec.ts",
"${workspaceFolder}/test/**/*.spec.ts"
],
"internalConsoleOptions": "openOnSessionStart"
},
{
"type": "node",
"request": "launch",
"name": "Mocha e2e",
"preLaunchTask": "npm: test",
"preLaunchTask": "npm: test:e2e",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"env": {
"NODE_ENV": "test",
Expand All @@ -62,6 +60,6 @@
"${workspaceFolder}/e2e/**/*.spec.ts"
],
"internalConsoleOptions": "openOnSessionStart"
},
}
]
}
}
51 changes: 31 additions & 20 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# Casanet server - backend
This is the casa-net local server to communicate and control IoT devices in a home.

This is the casa-net local server to communicate and control IoT devices in a home.

[![Build Status](https://travis-ci.org/casanet/casanet-server.svg?branch=master)](https://travis-ci.org/casanet/casanet-server)
[![Coverage Status](https://coveralls.io/repos/github/casanet/casanet-server/badge.svg?branch=master)](https://coveralls.io/github/casanet/casanet-server?branch=master)

### Server installation

1. Download the project via git or download files as a zip.
1. In Linux OS, make sure `net-tools` installed.
1. Install Node.js on the machine.
Expand All @@ -21,42 +26,51 @@ You can load the environment using a .env file.
Also in the `casanet.json` file, you can edit the configuration of a few stuff (if not set by the environments variables).

#### Default user
Can edit any property of the default user.

Can edit any property of the default user.

Except for the user account in the email. this will be always the mac address of the machine.
(The reason is for security, the only owner of the machine should know the default username).

#### HTTP/HTTPS server ports

You can edit port and HTTPS using.
Also can set it by environment variables:
* `HTTP_PORT`
* `HTTPS_PORT`
* `USE_HTTPS`

- `HTTP_PORT`
- `HTTPS_PORT`
- `USE_HTTPS`

> HTTPS require `private.key` `certificate.crt` and `ca_bundle.crt` files to be in `$/.../backend/encryption/` directory.

#### Requests limit

To block brute-force attacks there is a request limit per IP.

#### Home position

To allows timings based on sun events (such as turn on a light in the sunset) the server needs to know the location area of the home.
It doesn't need to be the exact location but needs to be close enough.

To get your home latitude and longitude you can use https://www.latlong.net/.

#### Password hash salt
set `SALT_KEYS` env var for salt sessions hash. otherways the salt will generate randomly on runtime, and in the next running, all sessions will be invalid.

set `SALT_KEYS` env var for salt sessions hash. otherways the salt will generate randomly on runtime, and in the next running, all sessions will be invalid.

#### Specify devices network
set `SUBNET_TO_SCAN` env var to specify the network to scan devices IP's in it. the format is `xxx.xxx.xxx`.

if not set, the default network is the first current machine IP subnet.
set `SUBNET_TO_SCAN` env var to specify the network to scan devices IP's in it. the format is `xxx.xxx.xxx`.

if not set, the default network is the first current machine IP subnet.

#### Specify physical address

set `PHYSICAL_ADDRESS` env var to specify the physical (aka MAC) address to use.
if not set, the address will be the first real machine address.

#### Two factor authentication (MFA)

To Allows MFA protection the server needs access to the email account to send the code to user email before login is done.

Let's take for example how to configure a Gmail account: (Of course, it will work for any other SMTP services).
Expand All @@ -66,31 +80,28 @@ First needs to turn on the IMAP/SMTP access service for the account, [see google
If MFA is enabled for the Gmail account to create an application key for the password. [see google instructions](https://support.google.com/accounts/answer/185833).

And use the following environment variables:
* `TFA_SMTP_SERVER` (value example: `smtp.gmail.com`)
* `TFA_USER_NAME` (value example: `[email protected]`)
* `TFA_USER_KEY` (value example: `my-gmail-password or my-application-password`)

- `TFA_SMTP_SERVER` (value example: `smtp.gmail.com`)
- `TFA_USER_NAME` (value example: `[email protected]`)
- `TFA_USER_KEY` (value example: `my-gmail-password or my-application-password`)

that's all.

## Devices connection

Each IoT device should be connected to the local network before it can add it to the casa-net server.
For each supported IoT device model connection and pairing instructions see [modules documentation](./src/modules/README.md).

## Fetch RF (IR / 433MHz etc.) commands from a commands repository

When using RF transmitter to control home devices it's possible to record the command from the original remote control or generating random command.
So to avoid recording a lot of commands one by one there is another project to store commands and serve then on demand. see the [project page](https://github.com/casanet/rf-commands-repo).
The `rf-commands-repo` URL placed in the `casanet.json` configuration file.

If you want to update my repo, feel free to contact me.
If you want to update my repo, feel free to contact me.

## API
The UI should wrap API.

The full specs of API are documented in [swagger API file](./swagger.yaml).






The UI should wrap API.

The full specs of API are documented in [swagger API file](./swagger.yaml).
2 changes: 1 addition & 1 deletion backend/dist/app.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/dist/app.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 15 additions & 15 deletions backend/dist/business-layer/authBl.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading