diff --git a/docs/auth-server.md b/docs/auth-server.md index ccb172d3..0d721a8b 100644 --- a/docs/auth-server.md +++ b/docs/auth-server.md @@ -97,17 +97,7 @@ npm run node:dev ``` ### 3. Production Build -To prepare for production, follow these steps: -1. Update server/src/routes/other.tsx file -``` -# Comment out the current swagger.json import statement: -// import swaggerSpec from '../scripts/swagger.json'; - -# Uncomment the other swagger.json import statement which contains with { type: "json" }: -import swaggerSpec from '../scripts/swagger.json' with { type: "json" } -``` - -2. Run the following commands to build and start the server: +Run the following commands to build and start the server: ``` cd server npm run node:build diff --git a/package-lock.json b/package-lock.json index 8dec350b..60897ad7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "melody-auth", - "version": "0.1.1", + "version": "1.0.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "melody-auth", - "version": "0.1.1", + "version": "1.0.4", "license": "MIT", "workspaces": [ "shared", @@ -8065,7 +8065,9 @@ } }, "node_modules/path-to-regexp": { - "version": "6.2.2", + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-6.3.0.tgz", + "integrity": "sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==", "dev": true, "license": "MIT" }, @@ -10721,10 +10723,11 @@ } }, "node_modules/vite": { - "version": "5.3.4", - "resolved": "https://registry.npmjs.org/vite/-/vite-5.3.4.tgz", - "integrity": "sha512-Cw+7zL3ZG9/NZBB8C+8QbQZmR54GwqIz+WMI4b3JgdYJvX+ny9AjJXqkGQlDXSXRP9rP0B4tbciRMOVEKulVOA==", + "version": "5.3.6", + "resolved": "https://registry.npmjs.org/vite/-/vite-5.3.6.tgz", + "integrity": "sha512-es78AlrylO8mTVBygC0gTC0FENv0C6T496vvd33ydbjF/mIi9q3XQ9A3NWo5qLGFKywvz10J26813OkLvcQleA==", "dev": true, + "license": "MIT", "dependencies": { "esbuild": "^0.21.3", "postcss": "^8.4.39", @@ -11675,7 +11678,7 @@ }, "react-sdk": { "name": "@melody-auth/react", - "version": "0.0.6", + "version": "0.0.8", "license": "MIT", "devDependencies": { "@rollup/plugin-alias": "^5.1.0", @@ -11722,6 +11725,7 @@ "node-jose": "^2.2.0", "otplib": "^12.0.1", "pg-mem": "^3.0.2", + "rimraf": "^6.0.1", "swagger-jsdoc": "^6.2.8", "tsc-alias": "^1.8.10", "tsx": "^4.19.0", @@ -11731,6 +11735,112 @@ "wrangler": "^3.57.2" } }, + "server/node_modules/glob": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.0.tgz", + "integrity": "sha512-9UiX/Bl6J2yaBbxKoEBRm4Cipxgok8kQYcOPEhScPwebu2I0HoQOuYdIO6S3hLuWoZgpDpwQZMzTFxgpkyT76g==", + "dev": true, + "license": "ISC", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^4.0.1", + "minimatch": "^10.0.0", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^2.0.0" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "server/node_modules/jackspeak": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.0.1.tgz", + "integrity": "sha512-cub8rahkh0Q/bw1+GxP7aeSe29hHHn2V4m29nnDlvCdlgU+3UGxkZp7Z53jLUdpX3jdTO0nJZUDl3xvbWc2Xog==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, + "server/node_modules/lru-cache": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.0.1.tgz", + "integrity": "sha512-CgeuL5uom6j/ZVrg7G/+1IXqRY8JXX4Hghfy5YE0EhoYQWvndP1kufu58cmZLNIDKnRhZrXfdS9urVWx98AipQ==", + "dev": true, + "license": "ISC", + "engines": { + "node": "20 || >=22" + } + }, + "server/node_modules/minimatch": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.1.tgz", + "integrity": "sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "server/node_modules/path-scurry": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz", + "integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "server/node_modules/rimraf": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.0.1.tgz", + "integrity": "sha512-9dkvaxAsk/xNXSJzMgFqqMCuFgt2+KsOFek3TMLfo8NCPfWpBmqwyNn5Y+NX56QUYfCtsyhF3ayiboEoUmJk/A==", + "dev": true, + "license": "ISC", + "dependencies": { + "glob": "^11.0.0", + "package-json-from-dist": "^1.0.0" + }, + "bin": { + "rimraf": "dist/esm/bin.mjs" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "shared": {}, "web-sdk": {} } diff --git a/package.json b/package.json index 09805963..0bd9f027 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "melody-auth", - "version": "1.0.4", + "version": "1.0.5", "description": "A turnkey OAuth & authentication system.", "license": "MIT", "author": "Baozier", diff --git a/server/package.json b/server/package.json index eb05741c..742b400d 100644 --- a/server/package.json +++ b/server/package.json @@ -11,7 +11,7 @@ "dev:secret:generate": "node ./src/scripts/generate-secret.cjs", "dev:secret:clean": "node ./src/scripts/clean-secret.cjs", "node:dev": "tsx watch src/node.tsx", - "node:build": "tsc && tsc-alias", + "node:build": "rimraf dist && tsc && tsc-alias && node ./src/scripts/node-build-patch.cjs", "node:start": "node dist/node.js", "node:migration:apply": "knex --knexfile knexfile.cjs migrate:latest", "node:secret:generate": "node ./src/scripts/generate-secret.cjs node", @@ -48,6 +48,7 @@ "@types/jsdom": "^21.1.7", "@types/jwk-to-pem": "^2.0.3", "@types/node-jose": "^1.1.13", + "@types/nodemailer": "^6.4.15", "@vitest/coverage-v8": "^2.0.5", "better-sqlite3": "^11.2.1", "ioredis-mock": "^8.9.0", @@ -55,8 +56,8 @@ "node-jose": "^2.2.0", "otplib": "^12.0.1", "pg-mem": "^3.0.2", + "rimraf": "^6.0.1", "swagger-jsdoc": "^6.2.8", - "@types/nodemailer": "^6.4.15", "tsc-alias": "^1.8.10", "tsx": "^4.19.0", "typescript": "^5.5.4", diff --git a/server/src/routes/other.tsx b/server/src/routes/other.tsx index 0b95b548..05d7add6 100644 --- a/server/src/routes/other.tsx +++ b/server/src/routes/other.tsx @@ -1,7 +1,6 @@ import { swaggerUI } from '@hono/swagger-ui' import { Hono } from 'hono' import swaggerSpec from '../scripts/swagger.json' -// import swaggerSpec from '../scripts/swagger.json' with { type: 'json' } import { otherHandler } from 'handlers' import { typeConfig } from 'configs' diff --git a/server/src/scripts/node-build-patch.cjs b/server/src/scripts/node-build-patch.cjs new file mode 100644 index 00000000..1f4c7dd7 --- /dev/null +++ b/server/src/scripts/node-build-patch.cjs @@ -0,0 +1,42 @@ +const fs = require('fs') +const path = require('path') + +const filePath = path.join( + __dirname, + '../../dist/routes/other.js', +) + +fs.readFile( + filePath, + 'utf8', + ( + err, data, + ) => { + if (err) { + console.error( + 'Error reading file:', + err, + ) + return + } + + const result = data.replace( + "import swaggerSpec from '../scripts/swagger.json'", + "import swaggerSpec from '../scripts/swagger.json' with { type: 'json' }", + ) + + fs.writeFile( + filePath, + result, + 'utf8', + (err) => { + if (err) { + console.error( + 'Error writing file:', + err, + ) + } + }, + ) + }, +) diff --git a/server/tsconfig.json b/server/tsconfig.json index 83b13685..a9297491 100644 --- a/server/tsconfig.json +++ b/server/tsconfig.json @@ -3,6 +3,7 @@ "target": "ESNext", "module": "ESNext", "moduleResolution": "Bundler", + "resolveJsonModule": true, "strict": true, "skipLibCheck": true, "lib": [