Skip to content
Open
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
34 changes: 34 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# App config files (must be mounted at runtime)
keypair_*.pem
.env

# macOS
.DS_Store

# Build artifacts
node_modules
dist
coverage
.nyc_output
openapi_exported.json

# Editor
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# Debug logs
*.log

# Git
.git
.github
.gitignore
.husky

# Test files (not needed in production image)
test/
52 changes: 38 additions & 14 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,29 +1,53 @@
{
"parser": "@typescript-eslint/parser",
"plugins": [
"jsdoc"
"jsdoc",
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"google"
"google",
"plugin:@typescript-eslint/recommended"
],
"rules": {
"linebreak-style": 1,
"indent": [
"error",
4
],
"quotes": [
"error",
"double"
]
},
"rules": {
"linebreak-style": 0,
"indent": [
"error",
4
],
"quotes": [
"error",
"double"
],
"@typescript-eslint/no-explicit-any": 0,
"new-cap": [
"error",
{
"capIsNewExceptions": [
"Object",
"String",
"Optional",
"Number",
"Boolean",
"Any",
"Union",
"Intersect",
"Record",
"Array",
"Enum",
"Nullable"
]
}
]
},
"env": {
"es6": true,
"node": true,
"mocha": true,
"browser": false
},
"parserOptions": {
"ecmaVersion": 2021
"ecmaVersion": 2021,
"sourceType": "module"
}
}
30 changes: 17 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
FROM node:20-alpine
FROM oven/bun:alpine

ENV RUNTIME_ENV=container
ENV TRUST_PROXY="uniquelocal"
ENV HTTP_HOSTNAME="0.0.0.0"
ENV RUNTIME_ENV="container"

RUN adduser -u 3000 -D recv
RUN addgroup -g 3000 recv && \
adduser -HD -u 3000 -G recv -h /app recv

RUN mkdir -p /.npm /workplace
WORKDIR /workplace
ADD . /workplace

RUN chown -R \
3000:3000 \
/.npm /workplace
WORKDIR /app
RUN chown 3000:3000 /app

USER 3000
RUN npm install

EXPOSE 3000
CMD ["npm", "start"]
COPY --chown=3000:3000 package.json ./
RUN bun install --production

COPY --chown=3000:3000 . .

EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=3s \
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/robots.txt || exit 1
CMD ["bun", "start"]
66 changes: 0 additions & 66 deletions app.js

This file was deleted.

1,711 changes: 1,711 additions & 0 deletions bun.lock

Large diffs are not rendered by default.

File renamed without changes.
32 changes: 0 additions & 32 deletions export_openapi.js

This file was deleted.

26 changes: 17 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,29 @@
"description": "A passwordless authentication system.",
"author": "Taiwan Web Technology Promotion Organization",
"license": "MIT",
"main": "app.js",
"scripts": {
"export-openapi": "node export_openapi.js",
"dev": "nodemon app.js",
"start": "node app.js",
"lint": "npx lint-staged",
"lint:es": "eslint \"*.js\" \"src/**/*.js\"",
"dev": "bun --hot src/index.ts",
"start": "bun src/index.ts",
"lint": "eslint src test --ext .ts",
"lint:es:fix": "eslint \"*.js\" \"src/**/*.js\" --fix",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The lint:es:fix script targets .js files, which are largely removed in this refactor. It should be updated to work with .ts files to remain useful.

Suggested change
"lint:es:fix": "eslint \"*.js\" \"src/**/*.js\" --fix",
"lint:es:fix": "eslint src --ext .ts --fix",

"test": "mocha test --exit --recursive --timeout 5000",
"test": "bun test",
"cover": "nyc mocha test --recursive --timeout 5000 --exit",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The cover script uses nyc and mocha, which may be outdated with the migration to Bun. Bun has built-in support for code coverage via bun test --coverage. You should update this script to use the new toolchain.

Suggested change
"cover": "nyc mocha test --recursive --timeout 5000 --exit",
"cover": "bun test --coverage",

"prepare": "husky install"
},
"lint-staged": {
"*.js": "eslint"
"*.{js,ts}": "eslint"
},
Comment on lines 17 to 19

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The lint-staged configuration is still set up for .js files. It should be updated to lint .ts files to be effective with the new TypeScript codebase.

Suggested change
"lint-staged": {
"*.js": "eslint"
},
"lint-staged": {
"*.ts": "eslint"
},

"dependencies": {
"@elysiajs/cors": "^1.4.2",
"@elysiajs/swagger": "^1.3.1",
"@simplewebauthn/server": "^11.0.0",
"@simplewebauthn/types": "^11.0.0",
"@sinclair/typebox": "^0.34.49",
"cors": "^2.8.5",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"express-validator": "^6.14.3",
"elysia": "^1.4.28",
"elysia-rate-limit": "^4.6.1",
"http-status-codes": "^2.2.0",
"jsonwebtoken": "^9.0.0",
"mongoose": "^7.0.3",
Expand All @@ -40,6 +41,13 @@
"devDependencies": {
"@commitlint/cli": "^17.4.4",
"@commitlint/config-conventional": "^17.4.4",
"@types/bun": "^1.3.13",
"@types/jsonwebtoken": "^9.0.10",
"@types/node": "^20.0.0",
"@types/nodemailer": "^8.0.0",
"@types/ua-parser-js": "^0.7.39",
"@typescript-eslint/eslint-plugin": "^8.59.3",
"@typescript-eslint/parser": "^8.59.3",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8.17.0",
"eslint-config-google": "^0.14.0",
Expand Down
Loading