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

Feat/2024-improvements #9

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
bc9e6bb
chore: improved .gitignore file
TyIsI Dec 15, 2024
ed52882
dependencies: updated dependencies to most recent-ish versions
TyIsI Dec 15, 2024
bead510
refactor: retired supertest-as-promised for supertest
TyIsI Dec 15, 2024
6761949
refactor: replace jade with pug
TyIsI Dec 15, 2024
295eaff
refactor(laserAccess.js): replace request-promise with fetch request
TyIsI Dec 15, 2024
1757717
dependencies: retired request request-promise
TyIsI Dec 15, 2024
89ffd82
package: retired obsoleted scripts
TyIsI Dec 15, 2024
59db766
dependencies: remove gulp
TyIsI Dec 15, 2024
340ea9e
package: switched to pnpm
TyIsI Dec 20, 2024
eb446b3
package(dev): added jest
TyIsI Dec 20, 2024
92da13b
chore: added pnpm-lock.yaml to gitignore
TyIsI Dec 20, 2024
ddbc587
refactor: moved mqtt stuff to mqtt.js file
TyIsI Dec 20, 2024
ce3efcf
test: retired Bluebird in testutils
TyIsI Dec 20, 2024
3473536
refactor(buildx.sh): formatting and quoting
TyIsI Dec 20, 2024
875133c
refactor: moved all other sources to lib/
TyIsI Dec 20, 2024
75c0c85
refactor: renamed mmp.js to nomos.js
TyIsI Dec 20, 2024
54084b2
chore: removed obsolete js files entries from gitignore
TyIsI Dec 20, 2024
afeaa84
refactor: app import path in bin/www
TyIsI Dec 20, 2024
d4a4aee
refactor: config.json imports
TyIsI Dec 20, 2024
7702ab1
chore: renamed sample config.json file
TyIsI Dec 20, 2024
693252b
refactor: changed mmp config references to nomos
TyIsI Dec 20, 2024
f6d0803
dependencies: @types/jest
TyIsI Dec 20, 2024
7a6e000
dependencies: upgrade chai/chai-as-promised
TyIsI Dec 20, 2024
995b3cc
formatting(clean code): tests files
TyIsI Dec 20, 2024
951fe6e
package: removed jshint config
TyIsI Dec 20, 2024
e0ae67e
Revert "dependencies: upgrade chai/chai-as-promised"
TyIsI Dec 20, 2024
91e41a4
feat: improved mock loading for laserAccess.js
TyIsI Dec 20, 2024
bc86f9d
refactor: public/view directory paths
TyIsI Dec 20, 2024
31cb15f
refactor: view template extensions
TyIsI Dec 20, 2024
12f9d4f
test: fixed should import in laserAccess.test.js
TyIsI Dec 20, 2024
6562adc
formatting: lib/laserAccess.js
TyIsI Dec 20, 2024
304088f
refactor: gpio, OFF, ON constants to constants.js
TyIsI Dec 20, 2024
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
51 changes: 40 additions & 11 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,40 @@
node_modules
.idea
.sass-cache
.DS_Store
coverage
config.json
.project
public/components/**/
public/components/**/*
!public/components/
.wireit
*
!.gitignore

!bin/
!bin/www

!lib/
!lib/*

!public/
!public/**/
!public/**/*
public/components/

!routes/
!routes/*

!test/
!test/**/
!test/**/*

!views/
!views/*

!.bowerrc
!.editorconfig
!.gitignore
!.prettierignore
!Dockerfile
!README.md
!bower.json
!buildx-setup.sh
!buildx.sh
!config.sample.json
!eslint.config.mjs
!gulpfile.js
!prettier.config.js

!package.json
!pnpm-lock.yaml
2 changes: 1 addition & 1 deletion bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

const debug = require('debug')('laser:web')

const app = require('../app')
const app = require('../lib/app')

app.app()

Expand Down
19 changes: 10 additions & 9 deletions buildx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

TEMPLATE=$1

if [ "${TEMPLATE}" = "" ] ; then
TEMPLATE=vanhack/vhs-laser-access:buildx-test
if [ "${TEMPLATE}" = "" ]; then
TEMPLATE=vanhack/vhs-laser-access:buildx-test
fi

TEMPLATE_PATH=$(echo "${TEMPLATE}" | cut -f1 -d:)
Expand All @@ -12,19 +12,20 @@ TEMPLATE_TAG=$(echo "${TEMPLATE}" | cut -f2- -d: | sed 's:/:-:g')
TEMPLATE="${TEMPLATE_PATH}:${TEMPLATE_TAG}"

if [ -f .build.env ]; then
. .build.env
# shellcheck source=/dev/null
. .build.env
fi

jq '. += {"experimental": "enabled"}' ~/.docker/config.json >~/.docker/config.json.tmp
cat ~/.docker/config.json.tmp >~/.docker/config.json
jq '. += {"experimental": "enabled"}' ~/.docker/config.json > ~/.docker/config.json.tmp
cat ~/.docker/config.json.tmp > ~/.docker/config.json
rm ~/.docker/config.json.tmp

XBUILDER=$(docker buildx ls | egrep xbuilder)
XBUILDER=$(docker buildx ls | grep xbuilder)

if [ "$XBUILDER" = "" ]; then
docker buildx create --name xbuilder --driver docker-container --use
docker buildx create --name xbuilder --driver docker-container --use
else
docker buildx use xbuilder
docker buildx use xbuilder
fi

docker buildx build --platform linux/arm64,linux/arm/v7,linux/arm/v6 -t $TEMPLATE --push .
docker buildx build --platform linux/arm64,linux/arm/v7,linux/arm/v6 -t "${TEMPLATE}" --push .
4 changes: 2 additions & 2 deletions config.json.sample → config.sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"clientID": "<clientId>",
"clientSecret": "<secret>"
},
"mmpUrl": "https://membership.vanhack.ca/services/web/AuthService1.svc/CheckService",
"mmpApiKey": "<mmpKey>",
"nomosUrl": "https://membership.vanhack.ca/services/web/AuthService1.svc/CheckService",
"nomosApiKey": "<nomosKey>",
"callbackHost": "http://localhost:3000 <callback for the api, cannot be an internal IP for google but it can be a dns name that is internal>",
"api": {
"baseUrl": "https://api.vanhack.ca",
Expand Down
8 changes: 4 additions & 4 deletions app.js → lib/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const debug = require('debug')('laser:web')
const express = require('express')
const session = require('express-session')

const routes = require('./routes')
const routes = require('../routes')

const app = express()

Expand All @@ -21,8 +21,8 @@ require('./socket').init(server)
let init = false

// view engine setup
app.set('views', path.join(__dirname, 'views'))
app.set('view engine', 'jade')
app.set('views', path.join(__dirname, '..', 'views'))
app.set('view engine', 'pug')

app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }))
Expand All @@ -46,7 +46,7 @@ module.exports.app = function () {
app.use('/', routes.router)
routes.addErrorHandlers(app)

app.use(express.static(path.join(__dirname, 'public')))
app.use(express.static(path.join(__dirname, '..', 'public')))

// catch 404 and forward to error handler
app.use(function (_req, _res, next) {
Expand Down
18 changes: 18 additions & 0 deletions lib/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
const gpios = {
GPIO_LASER: 22,
GPIO_BLOWER: 27,
GPIO_CHILLER: 17,

GPIO_LED_GREEN: 23,
GPIO_LED_RED: 24,

GPIO_MAIN_SWITCH: 4
}

module.exports.gpios = gpios

const ON = 1
const OFF = 0

module.exports.ON = ON
module.exports.OFF = OFF
Loading
Loading