Skip to content

Commit

Permalink
feat(identity): infrastructure changes (#405)
Browse files Browse the repository at this point in the history
* chore(www.js): rename www -> www.js for ts to transpile it

* build(package): changed start commands and added a build script

the start command is retrieved from:
https://stackoverflow.com/questions/61342753/paths-from-tsconfig-json-doesnt-work-after-tsc

this is required because ts doesn't destructure the path aliases into the actual imports.

* build(tsocnfig): updated tsconfig to emit

this won't affect npm run dev as we are using ts-node and it will transpile on the fly

* ci(ci): add step to build

* chore(gitignore): ignore build drivre

* fix(tsconfig): remove swc :(

swc transpiles experimental flags (metadata/decorators) wrongly; this results in
sequelize-typescript being transpiled wrongly

* chore(authmiddlewareservice): remove logging of cookies
  • Loading branch information
seaerchin authored Mar 30, 2022
1 parent ec16fa8 commit ed1ca83
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 68 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ jobs:
${{ runner.OS }}-
- name: Install NPM
run: npm ci
- name: Build application
run: npm run build
- name: Zip application
run: zip -r "deploy.zip" * .platform -x .env-example .gitignore package-lock.json
- name: Get timestamp
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.env
node_modules/
.vscode/
.vscode/
build/
File renamed without changes.
158 changes: 102 additions & 56 deletions package-lock.json

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

10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"version": "0.3.0",
"private": true,
"scripts": {
"start": "ts-node ./bin/www",
"build": "tsc -p tsconfig.build.json",
"start": "node -r ts-node/register/transpile-only -r tsconfig-paths/register build/bin/www.js",
"dev:services": "docker compose up -d",
"dev": "source .env && ts-node-dev --respawn ./bin/www",
"dev": "source .env && ts-node-dev --respawn ./bin/www.js",
"test": "source .env.test && jest",
"release": "npm version $npm_config_isomer_update && git push --tags",
"lint": "npx eslint .",
Expand All @@ -16,7 +17,6 @@
},
"dependencies": {
"@aws-sdk/client-secrets-manager": "^3.24.0",
"@swc/core": "^1.2.152",
"auto-bind": "^4.0.0",
"aws-sdk": "^2.946.0",
"axios": "^0.21.3",
Expand Down Expand Up @@ -64,6 +64,9 @@
"yaml": "^1.10.2"
},
"devDependencies": {
"@swc/cli": "^0.1.56",
"@swc/core": "^1.2.160",
"@swc/helpers": "^0.3.8",
"@tsconfig/recommended": "^1.0.1",
"@types/express": "^4.17.13",
"@types/jest": "^27.4.1",
Expand All @@ -87,6 +90,7 @@
"jest-mock-axios": "^4.5.0",
"lint-staged": "^11.1.2",
"prettier": "2.2.1",
"regenerator-runtime": "^0.13.9",
"sqlite3": "^5.0.2",
"ts-jest": "^27.1.3",
"ts-node-dev": "^1.1.8",
Expand Down
10 changes: 5 additions & 5 deletions services/middlewareServices/AuthMiddlewareService.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,20 +64,20 @@ class AuthMiddlewareService {
const userId = retrievedId
return { accessToken, userId }
} catch (err) {
// NOTE: Cookies aren't being logged here because they get caught as "Object object", which is not useful
// The cookies should be converted to a JSON struct before logging
if (err.name === "NotLoggedInError") {
logger.error(
`Authentication error: user not logged in with email. Cookie: ${cookies}, Url: ${url}`
`Authentication error: user not logged in with email. Url: ${url}`
)
throw new AuthError(
`Authentication error: user not logged in with email`
)
} else if (err.name === "TokenExpiredError") {
logger.error(
`Authentication error: JWT token expired. Cookie: ${cookies}, Url: ${url}`
)
logger.error(`Authentication error: JWT token expired. Url: ${url}`)
throw new AuthError(`JWT token has expired`)
} else {
logger.error(`Authentication error. Cookie: ${cookies}, Url: ${url}`)
logger.error(`Authentication error. Url: ${url}`)
}
throw err
}
Expand Down
11 changes: 11 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Main tsconfig for building, prevents tests from being compiled.
{
"extends": "./tsconfig.json",
"exclude": [
"tests/",
"**/*.spec.ts",
"**/*.test.ts",
"**/__tests__/",
"**/__mocks__/"
]
}
5 changes: 2 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
"skipLibCheck": true,
"esModuleInterop": true,
"strict": true,
"outDir": "build/",
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "commonjs",
"moduleResolution": "node",
"isolatedModules": true,
"noEmit": true,
"downlevelIteration": true,
"baseUrl": "./",
"resolveJsonModule": true,
Expand All @@ -37,8 +37,7 @@
},
"ts-node": {
"require": ["tsconfig-paths/register"],
"transpileOnly": true,
"swc": true
"transpileOnly": true
},
"exclude": ["node_modules", "dist"]
}

0 comments on commit ed1ca83

Please sign in to comment.