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

Update for running the Tesla Auth endpoint on the OpenEVSE servers #238

Merged
merged 5 commits into from
Aug 26, 2021
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
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ full-upload.sh

# Simulator
node_modules
package-lock.json

.vagrant
ubuntu-xenial-16.04-cloudimg-console.log
Expand Down
2 changes: 1 addition & 1 deletion gui
4 changes: 2 additions & 2 deletions src/web_static/web_server.home.js.h

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions tesla_login/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
npm-debug.log
.git
node_modules
16 changes: 16 additions & 0 deletions tesla_login/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
FROM node:16-buster

ARG PORT=3000
ENV PORT $PORT
EXPOSE $PORT

ARG NODE_ENV=production
ENV NODE_ENV $NODE_ENV

WORKDIR /app
COPY . /app

RUN npm install

USER node
ENTRYPOINT [ "/app/entrypoint.sh" ]
10 changes: 7 additions & 3 deletions tesla_login/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ let args = minimist(process.argv.slice(2), {
default: {
help: false,
version: false,
port: 3000
port: 3000,
log: 0
},
});

Expand All @@ -31,7 +32,8 @@ if(args.version) {
return 0;
}

var port = args.port;
const port = args.port;
const log = args.log;

const app = express();

Expand All @@ -44,6 +46,8 @@ app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cors());

teslajs.setLogLevel(log);

app.post("/login", function (req, res) {
teslajs.login({
username: req.body.username,
Expand All @@ -53,7 +57,7 @@ app.post("/login", function (req, res) {
}, (err, result) => {
if(err) {
res.status(403).send({
error: err
error: err.message
});
return;
}
Expand Down
3 changes: 3 additions & 0 deletions tesla_login/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

exec npm start -- --port ${PORT:=3000} $@
Loading