-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: migrate from Express/Node.js to ElysiaJS/Bun #55
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
base: rolling
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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/ |
| 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" | ||
| } | ||
| } |
| 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"] |
This file was deleted.
Large diffs are not rendered by default.
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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", | ||||||
| "test": "mocha test --exit --recursive --timeout 5000", | ||||||
| "test": "bun test", | ||||||
| "cover": "nyc mocha test --recursive --timeout 5000 --exit", | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||
| "prepare": "husky install" | ||||||
| }, | ||||||
| "lint-staged": { | ||||||
| "*.js": "eslint" | ||||||
| "*.{js,ts}": "eslint" | ||||||
| }, | ||||||
|
Comment on lines
17
to
19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||
| "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", | ||||||
|
|
@@ -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", | ||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
lint:es:fixscript targets.jsfiles, which are largely removed in this refactor. It should be updated to work with.tsfiles to remain useful.