diff --git a/config/config.json b/config/config.json deleted file mode 100644 index 65d5ee1..0000000 --- a/config/config.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "development": { - "username": "root", - "password": null, - "database": "database_development", - "host": "127.0.0.1", - "dialect": "sqlite" - }, - "test": { - "username": "root", - "password": null, - "database": "database_test", - "host": "127.0.0.1", - "dialect": "sqlite" - }, - "production": { - "username": "root", - "password": null, - "database": "database_production", - "host": "127.0.0.1", - "dialect": "sqlite" - } -} diff --git a/models/index.js b/models/index.js deleted file mode 100644 index 024200e..0000000 --- a/models/index.js +++ /dev/null @@ -1,43 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const path = require('path'); -const Sequelize = require('sequelize'); -const process = require('process'); -const basename = path.basename(__filename); -const env = process.env.NODE_ENV || 'development'; -const config = require(__dirname + '/../config/config.json')[env]; -const db = {}; - -let sequelize; -if (config.use_env_variable) { - sequelize = new Sequelize(process.env[config.use_env_variable], config); -} else { - sequelize = new Sequelize(config.database, config.username, config.password, config); -} - -fs - .readdirSync(__dirname) - .filter(file => { - return ( - file.indexOf('.') !== 0 && - file !== basename && - file.slice(-3) === '.js' && - file.indexOf('.test.js') === -1 - ); - }) - .forEach(file => { - const model = require(path.join(__dirname, file))(sequelize, Sequelize.DataTypes); - db[model.name] = model; - }); - -Object.keys(db).forEach(modelName => { - if (db[modelName].associate) { - db[modelName].associate(db); - } -}); - -db.sequelize = sequelize; -db.Sequelize = Sequelize; - -module.exports = db; diff --git a/next.config.js b/next.config.js index ae05198..1a601fd 100644 --- a/next.config.js +++ b/next.config.js @@ -1,9 +1,15 @@ /** @type {import('next').NextConfig} */ const nextConfig = { experimental: { - serverComponentsExternalPackages: ['sequelize', 'sequelize-typescript'], - serverActions: true, - } + serverComponentsExternalPackages: ['sequelize', 'sequelize-typescript', 'bcrypt', '@sequelize/core'], + serverActions: { + + }, + }, + webpack: (config) => { + config.externals = [...config.externals, 'bcrypt']; + return config; + }, } module.exports = nextConfig diff --git a/package-lock.json b/package-lock.json index c039c25..c84f0c5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,8 @@ "name": "portfolio2023", "version": "0.1.0", "dependencies": { + "@sequelize/core": "^7.0.0-alpha.40", + "@sequelize/sqlite3": "^7.0.0-alpha.40", "@types/bcrypt": "^5.0.0", "@types/cookie": "^0.5.1", "@types/node": "20.1.7", @@ -23,6 +25,7 @@ "fetch-cookie": "^3.0.1", "flowbite": "^2.3.0", "flowbite-react": "^0.7.5", + "moment": "^2.30.1", "mysql": "^2.18.1", "mysql2": "^3.3.3", "next": "14.1.4", @@ -31,7 +34,6 @@ "react": "18.2.0", "react-bootstrap": "^2.7.4", "react-dom": "18.2.0", - "sequelize": "^6.32.0", "sqlite": "^4.2.1", "tailwindcss": "3.3.2", "ts-node": "^10.9.2", @@ -195,7 +197,6 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz", "integrity": "sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==", - "dev": true, "optional": true }, "node_modules/@humanwhocodes/config-array": { @@ -531,7 +532,6 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/@npmcli/fs/-/fs-1.1.1.tgz", "integrity": "sha512-8KG5RD0GVP4ydEzRn/I4BNDuxDtqVbOdm8675T49OIG/NGhaK0pjPX7ZcDlvKYbA+ulvVK3ztfcF4uBdOxuJbQ==", - "dev": true, "optional": true, "dependencies": { "@gar/promisify": "^1.0.1", @@ -543,7 +543,6 @@ "resolved": "https://registry.npmjs.org/@npmcli/move-file/-/move-file-1.1.2.tgz", "integrity": "sha512-1SUf/Cg2GzGDyaf15aR9St9TWlb+XvbZXWpDx8YKs7MLzMH/BCeopv+y9vzrzgkfykCGuWOlSu3mZhj2+FQcrg==", "deprecated": "This functionality has been moved to @npmcli/fs", - "dev": true, "optional": true, "dependencies": { "mkdirp": "^1.0.4", @@ -629,6 +628,74 @@ "resolved": "https://registry.npmjs.org/@rushstack/eslint-patch/-/eslint-patch-1.7.2.tgz", "integrity": "sha512-RbhOOTCNoCrbfkRyoXODZp75MlpiHMgbE5MEBZAnnnLyQNgrigEj4p0lzsMDyc1zVsJDLrivB58tgg3emX0eEA==" }, + "node_modules/@sequelize/core": { + "version": "7.0.0-alpha.40", + "resolved": "https://registry.npmjs.org/@sequelize/core/-/core-7.0.0-alpha.40.tgz", + "integrity": "sha512-wj91y6Vx9k4pLOQVFyZLlq01xnS08dOPO/7//vtI20FVbPnmJpHnaqcuWYhkC0XGTmtPGfx9ZDJJ1rMG8tTFoA==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/sequelize" + } + ], + "dependencies": { + "@sequelize/utils": "7.0.0-alpha.40", + "@types/debug": "^4.1.12", + "@types/validator": "^13.11.9", + "bnf-parser": "^3.1.6", + "chalk": "^4.1.2", + "dayjs": "^1.11.10", + "debug": "^4.3.4", + "dottie": "^2.0.6", + "fast-glob": "^3.3.2", + "inflection": "^3.0.0", + "lodash": "^4.17.21", + "retry-as-promised": "^7.0.4", + "semver": "^7.3", + "sequelize-pool": "^8.0.0", + "toposort-class": "^1.0.1", + "type-fest": "^4.14.0", + "uuid": "^9.0.1", + "validator": "^13.11.0" + }, + "engines": { + "node": ">=18.0.0" + } + }, + "node_modules/@sequelize/core/node_modules/type-fest": { + "version": "4.15.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.15.0.tgz", + "integrity": "sha512-tB9lu0pQpX5KJq54g+oHOLumOx+pMep4RaM6liXh2PKmVRFF+/vAtUP0ZaJ0kOySfVNjF6doBWPHhBhISKdlIA==", + "engines": { + "node": ">=16" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@sequelize/sqlite3": { + "version": "7.0.0-alpha.40", + "resolved": "https://registry.npmjs.org/@sequelize/sqlite3/-/sqlite3-7.0.0-alpha.40.tgz", + "integrity": "sha512-sBVtpYfGst6X2/3wcfLhPJQi3N+lGQwEQz9g3TBd0Ai6Q2GTbUg+SgNoJwABzUy/kDvzSWaTf0WdQr5mpftUgg==", + "dependencies": { + "@sequelize/core": "7.0.0-alpha.40", + "@sequelize/utils": "7.0.0-alpha.40", + "lodash": "^4.17.21", + "sqlite3": "^5.1.7" + } + }, + "node_modules/@sequelize/utils": { + "version": "7.0.0-alpha.40", + "resolved": "https://registry.npmjs.org/@sequelize/utils/-/utils-7.0.0-alpha.40.tgz", + "integrity": "sha512-npN1C6m3QPvrDlZSveB9DHSyx2I4EGEshIv7R7jCXt7iKFVG2o/LLYlFK4rwzND5YtNRI6ES69UxLg/65KSa5g==", + "dependencies": { + "@types/lodash": "^4.17.0", + "lodash": "^4.17.21" + }, + "engines": { + "node": ">=18.0.0" + } + }, "node_modules/@swc/helpers": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.2.tgz", @@ -641,7 +708,6 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/@tootallnate/once/-/once-1.1.2.tgz", "integrity": "sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==", - "dev": true, "optional": true, "engines": { "node": ">= 6" @@ -693,6 +759,11 @@ "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==" }, + "node_modules/@types/lodash": { + "version": "4.17.0", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.0.tgz", + "integrity": "sha512-t7dhREVv6dbNj0q17X12j7yDG4bD/DHYX7o5/DbDxobP0HnGPgpRz2Ej77aL7TZT3DSw13fqUTj8J4mMnqa7WA==" + }, "node_modules/@types/ms": { "version": "0.7.34", "resolved": "https://registry.npmjs.org/@types/ms/-/ms-0.7.34.tgz", @@ -900,7 +971,6 @@ "version": "4.5.0", "resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.5.0.tgz", "integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==", - "dev": true, "optional": true, "dependencies": { "humanize-ms": "^1.2.1" @@ -913,7 +983,6 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.1.0.tgz", "integrity": "sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==", - "dev": true, "optional": true, "dependencies": { "clean-stack": "^2.0.0", @@ -1282,7 +1351,6 @@ "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", - "dev": true, "funding": [ { "type": "github", @@ -1331,7 +1399,6 @@ "version": "1.5.0", "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", - "dev": true, "dependencies": { "file-uri-to-path": "1.0.0" } @@ -1340,7 +1407,6 @@ "version": "4.1.0", "resolved": "https://registry.npmjs.org/bl/-/bl-4.1.0.tgz", "integrity": "sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==", - "dev": true, "dependencies": { "buffer": "^5.5.0", "inherits": "^2.0.4", @@ -1351,7 +1417,6 @@ "version": "3.6.2", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "dev": true, "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -1361,6 +1426,11 @@ "node": ">= 6" } }, + "node_modules/bnf-parser": { + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/bnf-parser/-/bnf-parser-3.1.6.tgz", + "integrity": "sha512-3x0ECh6CghmcAYnY6uiVAOfl263XkWffDq5fQS20ac3k0U7TE5rTWNXTnOTckgmfZc94iharwqCyoV8OAYxYoA==" + }, "node_modules/bootstrap": { "version": "5.3.3", "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-5.3.3.tgz", @@ -1434,7 +1504,6 @@ "version": "5.7.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.7.1.tgz", "integrity": "sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==", - "dev": true, "funding": [ { "type": "github", @@ -1469,7 +1538,6 @@ "version": "15.3.0", "resolved": "https://registry.npmjs.org/cacache/-/cacache-15.3.0.tgz", "integrity": "sha512-VVdYzXEn+cnbXpFgWs5hTT7OScegHVmLhJIR8Ufqk3iFD6A6j5iSX1KuBTfNEv4tdJWE2PzA6IVFtcLC7fN9wQ==", - "dev": true, "optional": true, "dependencies": { "@npmcli/fs": "^1.0.0", @@ -1499,7 +1567,6 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, "optional": true, "dependencies": { "yallist": "^4.0.0" @@ -1627,7 +1694,6 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", - "dev": true, "optional": true, "engines": { "node": ">=6" @@ -1732,6 +1798,11 @@ "resolved": "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz", "integrity": "sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==" }, + "node_modules/dayjs": { + "version": "1.11.10", + "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.11.10.tgz", + "integrity": "sha512-vjAczensTgRcqDERK0SR2XMwsF/tSvnvlv6VcF2GIhg6Sx4yOIt/irsr1RDJsKiIyBzJDpCoXiWWq28MqH2cnQ==" + }, "node_modules/debounce": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/debounce/-/debounce-2.0.0.tgz", @@ -1763,7 +1834,6 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-6.0.0.tgz", "integrity": "sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==", - "dev": true, "dependencies": { "mimic-response": "^3.1.0" }, @@ -1778,7 +1848,6 @@ "version": "0.6.0", "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz", "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==", - "dev": true, "engines": { "node": ">=4.0.0" } @@ -1931,7 +2000,6 @@ "version": "1.4.4", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", - "dev": true, "dependencies": { "once": "^1.4.0" } @@ -1952,7 +2020,6 @@ "version": "2.2.1", "resolved": "https://registry.npmjs.org/env-paths/-/env-paths-2.2.1.tgz", "integrity": "sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==", - "dev": true, "optional": true, "engines": { "node": ">=6" @@ -1962,7 +2029,6 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/err-code/-/err-code-2.0.3.tgz", "integrity": "sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA==", - "dev": true, "optional": true }, "node_modules/es-abstract": { @@ -2518,7 +2584,6 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz", "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==", - "dev": true, "engines": { "node": ">=6" } @@ -2595,8 +2660,7 @@ "node_modules/file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", - "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==", - "dev": true + "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" }, "node_modules/fill-range": { "version": "7.0.1", @@ -2718,8 +2782,7 @@ "node_modules/fs-constants": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", - "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", - "dev": true + "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==" }, "node_modules/fs-minipass": { "version": "2.1.0", @@ -2858,8 +2921,7 @@ "node_modules/github-from-package": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", - "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==", - "dev": true + "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==" }, "node_modules/glob": { "version": "7.1.7", @@ -3042,14 +3104,12 @@ "version": "4.1.1", "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz", "integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==", - "dev": true, "optional": true }, "node_modules/http-proxy-agent": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-4.0.1.tgz", "integrity": "sha512-k0zdNgqWTGA6aeIRVpvfVob4fL52dTfaehylg0Y4UvSySvOq/Y+BOyPrgpUrA7HylqvU8vIZGsRuXmspskV0Tg==", - "dev": true, "optional": true, "dependencies": { "@tootallnate/once": "1", @@ -3076,7 +3136,6 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz", "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", - "dev": true, "optional": true, "dependencies": { "ms": "^2.0.0" @@ -3097,7 +3156,6 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", - "dev": true, "funding": [ { "type": "github", @@ -3148,7 +3206,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", - "dev": true, "optional": true, "engines": { "node": ">=8" @@ -3158,16 +3215,15 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/infer-owner/-/infer-owner-1.0.4.tgz", "integrity": "sha512-IClj+Xz94+d7irH5qRyfJonOdfTzuDaifE6ZPWfx0N0+/ATZCbuTPq2prFl526urkQd90WyUKIh1DfBQ2hMz9A==", - "dev": true, "optional": true }, "node_modules/inflection": { - "version": "1.13.4", - "resolved": "https://registry.npmjs.org/inflection/-/inflection-1.13.4.tgz", - "integrity": "sha512-6I/HUDeYFfuNCVS3td055BaXBwKYuzw7K3ExVMStBowKo9oOAMJIXIHvdyR3iboTCp1b+1i5DSkIZTcwIktuDw==", - "engines": [ - "node >= 0.4.0" - ] + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/inflection/-/inflection-3.0.0.tgz", + "integrity": "sha512-1zEJU1l19SgJlmwqsEyFTbScw/tkMHFenUo//Y0i+XEP83gDFdMvPizAD/WGcE+l1ku12PcTVHQhO6g5E0UCMw==", + "engines": { + "node": ">=18.0.0" + } }, "node_modules/inflight": { "version": "1.0.6", @@ -3186,8 +3242,7 @@ "node_modules/ini": { "version": "1.3.8", "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.8.tgz", - "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==", - "dev": true + "integrity": "sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==" }, "node_modules/internal-slot": { "version": "1.0.7", @@ -3214,7 +3269,6 @@ "version": "9.0.5", "resolved": "https://registry.npmjs.org/ip-address/-/ip-address-9.0.5.tgz", "integrity": "sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==", - "dev": true, "optional": true, "dependencies": { "jsbn": "1.1.0", @@ -3382,7 +3436,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-lambda/-/is-lambda-1.0.1.tgz", "integrity": "sha512-z7CMFGNrENq5iFB9Bqo64Xk6Y9sg+epq1myIcdHaGnbMTYOxvzsEtdYqQUylB7LxfkvgrrjP32T6Ywciio9UIQ==", - "dev": true, "optional": true }, "node_modules/is-map": { @@ -3637,7 +3690,6 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-1.1.0.tgz", "integrity": "sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==", - "dev": true, "optional": true }, "node_modules/json-buffer": { @@ -3808,7 +3860,6 @@ "version": "9.1.0", "resolved": "https://registry.npmjs.org/make-fetch-happen/-/make-fetch-happen-9.1.0.tgz", "integrity": "sha512-+zopwDy7DNknmwPQplem5lAZX/eCOzSvSNNcSKm5eVwTkOBzoktEfXsa9L23J/GIRhxRsaxzkPEhrJEpE2F4Gg==", - "dev": true, "optional": true, "dependencies": { "agentkeepalive": "^4.1.3", @@ -3836,7 +3887,6 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", - "dev": true, "optional": true, "dependencies": { "yallist": "^4.0.0" @@ -3869,7 +3919,6 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-3.1.0.tgz", "integrity": "sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==", - "dev": true, "engines": { "node": ">=10" }, @@ -3919,7 +3968,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/minipass-collect/-/minipass-collect-1.0.2.tgz", "integrity": "sha512-6T6lH0H8OG9kITm/Jm6tdooIbogG9e0tLgpY6mphXSm/A9u8Nq1ryBG+Qspiub9LjWlBPsPS3tWQ/Botq4FdxA==", - "dev": true, "optional": true, "dependencies": { "minipass": "^3.0.0" @@ -3932,7 +3980,6 @@ "version": "1.4.1", "resolved": "https://registry.npmjs.org/minipass-fetch/-/minipass-fetch-1.4.1.tgz", "integrity": "sha512-CGH1eblLq26Y15+Azk7ey4xh0J/XfJfrCox5LDJiKqI2Q2iwOLOKrlmIaODiSQS8d18jalF6y2K2ePUm0CmShw==", - "dev": true, "optional": true, "dependencies": { "minipass": "^3.1.0", @@ -3950,7 +3997,6 @@ "version": "1.0.5", "resolved": "https://registry.npmjs.org/minipass-flush/-/minipass-flush-1.0.5.tgz", "integrity": "sha512-JmQSYYpPUqX5Jyn1mXaRwOda1uQ8HP5KAT/oDSLCzt1BYRhQU0/hDtsB1ufZfEEzMZ9aAVmsBw8+FWsIXlClWw==", - "dev": true, "optional": true, "dependencies": { "minipass": "^3.0.0" @@ -3963,7 +4009,6 @@ "version": "1.2.4", "resolved": "https://registry.npmjs.org/minipass-pipeline/-/minipass-pipeline-1.2.4.tgz", "integrity": "sha512-xuIq7cIOt09RPRJ19gdi4b+RiNvDFYe5JH+ggNvBqGqpQXcru3PcRmOZuHBKWK1Txf9+cQ+HMVN4d6z46LZP7A==", - "dev": true, "optional": true, "dependencies": { "minipass": "^3.0.0" @@ -3976,7 +4021,6 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/minipass-sized/-/minipass-sized-1.0.3.tgz", "integrity": "sha512-MbkQQ2CTiBMlA2Dm/5cY+9SWFEN8pzzOXi6rlM5Xxq0Yqbda5ZQy9sU75a673FE9ZK0Zsbr6Y5iP6u9nktfg2g==", - "dev": true, "optional": true, "dependencies": { "minipass": "^3.0.0" @@ -4011,8 +4055,7 @@ "node_modules/mkdirp-classic": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz", - "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==", - "dev": true + "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==" }, "node_modules/moment": { "version": "2.30.1", @@ -4022,17 +4065,6 @@ "node": "*" } }, - "node_modules/moment-timezone": { - "version": "0.5.45", - "resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.45.tgz", - "integrity": "sha512-HIWmqA86KcmCAhnMAN0wuDOARV/525R2+lOLotuGFzn4HO+FH+/645z2wx0Dt3iDv6/p61SIvKnDstISainhLQ==", - "dependencies": { - "moment": "^2.29.4" - }, - "engines": { - "node": "*" - } - }, "node_modules/ms": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", @@ -4053,9 +4085,9 @@ } }, "node_modules/mysql2": { - "version": "3.9.2", - "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.9.2.tgz", - "integrity": "sha512-3Cwg/UuRkAv/wm6RhtPE5L7JlPB877vwSF6gfLAS68H+zhH+u5oa3AieqEd0D0/kC3W7qIhYbH419f7O9i/5nw==", + "version": "3.9.6", + "resolved": "https://registry.npmjs.org/mysql2/-/mysql2-3.9.6.tgz", + "integrity": "sha512-9NYUMLQv6yXnu+5hUh8PZ5CdKoG6VWDzXbojIdTyob8upNZXU3rBNQK9viaEqfgw+LMifhd+53VEZPxZk3bTWA==", "dependencies": { "denque": "^2.1.0", "generate-function": "^2.3.1", @@ -4127,8 +4159,7 @@ "node_modules/napi-build-utils": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz", - "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==", - "dev": true + "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==" }, "node_modules/natural-compare": { "version": "1.4.0", @@ -4139,7 +4170,6 @@ "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", - "dev": true, "optional": true, "engines": { "node": ">= 0.6" @@ -4221,7 +4251,6 @@ "version": "3.56.0", "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.56.0.tgz", "integrity": "sha512-fZjdhDOeRcaS+rcpve7XuwHBmktS1nS1gzgghwKUQQ8nTy2FdSDr6ZT8k6YhvlJeHmmQMYiT/IH9hfco5zeW2Q==", - "dev": true, "dependencies": { "semver": "^7.3.5" }, @@ -4257,7 +4286,6 @@ "version": "8.4.1", "resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-8.4.1.tgz", "integrity": "sha512-olTJRgUtAb/hOXG0E93wZDs5YiJlgbXxTwQAFHyNlRsXQnYzUaF2aGgujZbw+hR8aF4ZG/rST57bWMWD16jr9w==", - "dev": true, "optional": true, "dependencies": { "env-paths": "^2.2.0", @@ -4282,7 +4310,6 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-3.0.1.tgz", "integrity": "sha512-QZW4EDmGwlYur0Yyf/b2uGucHQMa8aFUP7eu9ddR73vvhFyt4V0Vl3QHPcTNJ8l6qYOBdxgXdnBXQrHilfRQBg==", - "dev": true, "optional": true, "dependencies": { "delegates": "^1.0.0", @@ -4296,7 +4323,6 @@ "version": "4.0.4", "resolved": "https://registry.npmjs.org/gauge/-/gauge-4.0.4.tgz", "integrity": "sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg==", - "dev": true, "optional": true, "dependencies": { "aproba": "^1.0.3 || ^2.0.0", @@ -4316,7 +4342,6 @@ "version": "6.0.2", "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-6.0.2.tgz", "integrity": "sha512-/vBvz5Jfr9dT/aFWd0FIRf+T/Q2WBsLENygUaFUqstqsycmZAP/t5BvFJTK0viFmSUxiUKTUplWy5vt+rvKIxg==", - "dev": true, "optional": true, "dependencies": { "are-we-there-yet": "^3.0.0", @@ -4332,7 +4357,6 @@ "version": "3.6.2", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "dev": true, "optional": true, "dependencies": { "inherits": "^2.0.3", @@ -4563,7 +4587,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/p-map/-/p-map-4.0.0.tgz", "integrity": "sha512-/bjOqmgETBYB5BoEeGVea8dmvHb2m9GLy1E9W43yeyfP6QQCZGFNa+XRceJEuDB6zqr+gKpIAmlLebMpykw/MQ==", - "dev": true, "optional": true, "dependencies": { "aggregate-error": "^3.0.0" @@ -4654,11 +4677,6 @@ "node": ">=8" } }, - "node_modules/pg-connection-string": { - "version": "2.6.2", - "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.6.2.tgz", - "integrity": "sha512-ch6OwaeaPYcova4kKZ15sbJ2hKb/VP48ZD2gE7i1J+L4MspCtBMAx8nMgz7bksc7IojCIIWuEhHibSMFH8m8oA==" - }, "node_modules/pg-hstore": { "version": "2.3.4", "resolved": "https://registry.npmjs.org/pg-hstore/-/pg-hstore-2.3.4.tgz", @@ -4855,7 +4873,6 @@ "version": "7.1.2", "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.2.tgz", "integrity": "sha512-UnNke3IQb6sgarcZIDU3gbMeTp/9SSU1DAIkil7PrqG1vZlBtY5msYccSKSHDqa3hNg436IXK+SNImReuA1wEQ==", - "dev": true, "dependencies": { "detect-libc": "^2.0.0", "expand-template": "^2.0.3", @@ -4894,14 +4911,12 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", "integrity": "sha512-6zWPyEOFaQBJYcGMHBKTKJ3u6TBsnMFOIZSa6ce1e/ZrrsOlnHRHbabMjLiBYKp+n44X9eUI6VUPaukCXHuG4g==", - "dev": true, "optional": true }, "node_modules/promise-retry": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/promise-retry/-/promise-retry-2.0.1.tgz", "integrity": "sha512-y+WKFlBR8BGXnsNlIHFGPZmyDf3DFMoLhaflAnyZgV6rG6xu+JwesTo2Q9R6XwYmtmwAFCkAk3e35jEdoeh/3g==", - "dev": true, "optional": true, "dependencies": { "err-code": "^2.0.2", @@ -4942,7 +4957,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", "integrity": "sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww==", - "dev": true, "dependencies": { "end-of-stream": "^1.1.0", "once": "^1.3.1" @@ -4984,7 +4998,6 @@ "version": "1.2.8", "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz", "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==", - "dev": true, "dependencies": { "deep-extend": "^0.6.0", "ini": "~1.3.0", @@ -4999,7 +5012,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", "integrity": "sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -5205,7 +5217,6 @@ "version": "0.12.0", "resolved": "https://registry.npmjs.org/retry/-/retry-0.12.0.tgz", "integrity": "sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==", - "dev": true, "optional": true, "engines": { "node": ">= 4" @@ -5347,71 +5358,10 @@ "resolved": "https://registry.npmjs.org/seq-queue/-/seq-queue-0.0.5.tgz", "integrity": "sha512-hr3Wtp/GZIc/6DAGPDcV4/9WoZhjrkXsi5B/07QgX8tsdc6ilr7BFM6PM6rbdAX1kFSDYeZGLipIZZKyQP0O5Q==" }, - "node_modules/sequelize": { - "version": "6.37.1", - "resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.37.1.tgz", - "integrity": "sha512-vIKKzQ9dGp2aBOxQRD1FmUYViuQiKXSJ8yah8TsaBx4U3BokJt+Y2A0qz2C4pj08uX59qpWxRqSLEfRmVOEgQw==", - "funding": [ - { - "type": "opencollective", - "url": "https://opencollective.com/sequelize" - } - ], - "dependencies": { - "@types/debug": "^4.1.8", - "@types/validator": "^13.7.17", - "debug": "^4.3.4", - "dottie": "^2.0.6", - "inflection": "^1.13.4", - "lodash": "^4.17.21", - "moment": "^2.29.4", - "moment-timezone": "^0.5.43", - "pg-connection-string": "^2.6.1", - "retry-as-promised": "^7.0.4", - "semver": "^7.5.4", - "sequelize-pool": "^7.1.0", - "toposort-class": "^1.0.1", - "uuid": "^8.3.2", - "validator": "^13.9.0", - "wkx": "^0.5.0" - }, - "engines": { - "node": ">=10.0.0" - }, - "peerDependenciesMeta": { - "ibm_db": { - "optional": true - }, - "mariadb": { - "optional": true - }, - "mysql2": { - "optional": true - }, - "oracledb": { - "optional": true - }, - "pg": { - "optional": true - }, - "pg-hstore": { - "optional": true - }, - "snowflake-sdk": { - "optional": true - }, - "sqlite3": { - "optional": true - }, - "tedious": { - "optional": true - } - } - }, "node_modules/sequelize-pool": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/sequelize-pool/-/sequelize-pool-7.1.0.tgz", - "integrity": "sha512-G9c0qlIWQSK29pR/5U2JF5dDQeqqHRragoyahj/Nx4KOOQ3CPPfzxnfqFPCSB7x5UgjOgnZ61nSxz+fjDpRlJg==", + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/sequelize-pool/-/sequelize-pool-8.0.0.tgz", + "integrity": "sha512-xY04c5ctp6lKE4ZoSVo7YJHN5FHVhoYMoH2Z8jWIJG26c9kJSkIjql5HgD9XG5cwJbYMF0Ko2Fhgws20HC90Ug==", "engines": { "node": ">= 10.0.0" } @@ -5501,7 +5451,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.1.tgz", "integrity": "sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==", - "dev": true, "funding": [ { "type": "github", @@ -5521,7 +5470,6 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-4.0.1.tgz", "integrity": "sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==", - "dev": true, "funding": [ { "type": "github", @@ -5554,7 +5502,6 @@ "version": "4.2.0", "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", - "dev": true, "optional": true, "engines": { "node": ">= 6.0.0", @@ -5565,7 +5512,6 @@ "version": "2.8.1", "resolved": "https://registry.npmjs.org/socks/-/socks-2.8.1.tgz", "integrity": "sha512-B6w7tkwNid7ToxjZ08rQMT8M9BJAf8DKx8Ft4NivzH0zBUfd6jldGcisJn/RLgxcX3FPNDdNQCUEMMT79b+oCQ==", - "dev": true, "optional": true, "dependencies": { "ip-address": "^9.0.5", @@ -5580,7 +5526,6 @@ "version": "6.2.1", "resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-6.2.1.tgz", "integrity": "sha512-a6KW9G+6B3nWZ1yB8G7pJwL3ggLy1uTzKAgCb7ttblwqdz9fMGJUuTy3uFzEP48FAs9FLILlmzDlE2JJhVQaXQ==", - "dev": true, "optional": true, "dependencies": { "agent-base": "^6.0.2", @@ -5603,7 +5548,6 @@ "version": "1.1.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz", "integrity": "sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==", - "dev": true, "optional": true }, "node_modules/sqlite": { @@ -5615,7 +5559,6 @@ "version": "5.1.7", "resolved": "https://registry.npmjs.org/sqlite3/-/sqlite3-5.1.7.tgz", "integrity": "sha512-GGIyOiFaG+TUra3JIfkI/zGP8yZYLPQ0pl1bH+ODjiX57sPhrLU5sQJn1y9bDKZUFYkX1crlrPfSYt0BKKdkog==", - "dev": true, "hasInstallScript": true, "dependencies": { "bindings": "^1.5.0", @@ -5639,7 +5582,6 @@ "version": "7.1.0", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.0.tgz", "integrity": "sha512-mNcltoe1R8o7STTegSOHdnJNN7s5EUvhoS7ShnTHDyOSd+8H+UdWODq6qSv67PjC8Zc5JRT8+oLAMCr0SIXw7g==", - "dev": true, "engines": { "node": "^16 || ^18 || >= 20" } @@ -5656,7 +5598,6 @@ "version": "8.0.1", "resolved": "https://registry.npmjs.org/ssri/-/ssri-8.0.1.tgz", "integrity": "sha512-97qShzy1AiyxvPNIkLWoGua7xoQzzPjQ0HAH4B0rWKo7SZ6USuPcrUiAFrws0UH8RrbWmgq3LMTObhPIHbbBeQ==", - "dev": true, "optional": true, "dependencies": { "minipass": "^3.1.1" @@ -6019,7 +5960,6 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.1.1.tgz", "integrity": "sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==", - "dev": true, "dependencies": { "chownr": "^1.1.1", "mkdirp-classic": "^0.5.2", @@ -6030,14 +5970,12 @@ "node_modules/tar-fs/node_modules/chownr": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", - "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==", - "dev": true + "integrity": "sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==" }, "node_modules/tar-stream": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.2.0.tgz", "integrity": "sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==", - "dev": true, "dependencies": { "bl": "^4.0.3", "end-of-stream": "^1.4.1", @@ -6053,7 +5991,6 @@ "version": "3.6.2", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", - "dev": true, "dependencies": { "inherits": "^2.0.3", "string_decoder": "^1.1.1", @@ -6221,7 +6158,6 @@ "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", "integrity": "sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==", - "dev": true, "dependencies": { "safe-buffer": "^5.0.1" }, @@ -6369,7 +6305,6 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/unique-filename/-/unique-filename-1.1.1.tgz", "integrity": "sha512-Vmp0jIp2ln35UTXuryvjzkjGdRyf9b2lTXuSYUiPmzRcl3FDtYqAwOnTJkAngD9SWhnoJzDbTKwaOrZ+STtxNQ==", - "dev": true, "optional": true, "dependencies": { "unique-slug": "^2.0.0" @@ -6379,7 +6314,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/unique-slug/-/unique-slug-2.0.2.tgz", "integrity": "sha512-zoWr9ObaxALD3DOPfjPSqxt4fnZiWblxHIgeWqW8x7UqDzEtHEQLzji2cuJYQFCU6KmoJikOYAZlrTHHebjx2w==", - "dev": true, "optional": true, "dependencies": { "imurmurhash": "^0.1.4" @@ -6445,9 +6379,13 @@ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" }, "node_modules/uuid": { - "version": "8.3.2", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", - "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-9.0.1.tgz", + "integrity": "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], "bin": { "uuid": "dist/bin/uuid" } @@ -6589,14 +6527,6 @@ "string-width": "^1.0.2 || 2 || 3 || 4" } }, - "node_modules/wkx": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/wkx/-/wkx-0.5.0.tgz", - "integrity": "sha512-Xng/d4Ichh8uN4l0FToV/258EjMGU9MGcA0HV2d9B/ZpZB3lqQm7nkOdZdm5GhKtLLhAE7PiVQwN4eN+2YJJUg==", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/wrap-ansi": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", diff --git a/package.json b/package.json index 61b02ae..bca3059 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,8 @@ "lint": "next lint" }, "dependencies": { + "@sequelize/core": "^7.0.0-alpha.40", + "@sequelize/sqlite3": "^7.0.0-alpha.40", "@types/bcrypt": "^5.0.0", "@types/cookie": "^0.5.1", "@types/node": "20.1.7", @@ -24,6 +26,7 @@ "fetch-cookie": "^3.0.1", "flowbite": "^2.3.0", "flowbite-react": "^0.7.5", + "moment": "^2.30.1", "mysql": "^2.18.1", "mysql2": "^3.3.3", "next": "14.1.4", @@ -32,7 +35,6 @@ "react": "18.2.0", "react-bootstrap": "^2.7.4", "react-dom": "18.2.0", - "sequelize": "^6.32.0", "sqlite": "^4.2.1", "tailwindcss": "3.3.2", "ts-node": "^10.9.2", diff --git a/src/api/user.ts b/src/api/user.ts index 82d43ac..f9a0c37 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -3,14 +3,14 @@ import { validatePassword } from "@/util/Auth"; import { APIError } from "@/api/error"; -import { User, Auth } from "@/model/sequelize/NewModels"; +import { User } from "@/model/User"; export function parseBasicAuth(authb64:string):UserAuth { - const authString:string = Buffer.from(authb64.split(" ")[1], "base64").toString("utf8"); + const authString:string = Buffer.from(authb64.split(" ")[1] as any, "base64").toString("utf8"); var userAuth:UserAuth = { - username:authString.split(":")[0], - password:authString.split(":")[1] + username:authString.split(":")[0] as any, + password:authString.split(":")[1] as any }; return userAuth } @@ -22,7 +22,6 @@ export type UserAuth = { export async function getAssociatedUser(auth:UserAuth) { - const username = auth.username; let foundUser = await User.findOne({ attributes: {include: ['password']}, where: {username: auth.username} }); if (!foundUser) diff --git a/src/app/admin/login/page.tsx b/src/app/admin/login/page.tsx index f85133e..18f5708 100644 --- a/src/app/admin/login/page.tsx +++ b/src/app/admin/login/page.tsx @@ -1,12 +1,12 @@ 'use client' -import { authenticate } from '@/app/lib/actions' +import { serverAttemptAuthenticateUser } from '@/app/lib/actions' import { useFormState, useFormStatus } from "react-dom"; import { cookies } from 'next/headers'; export default function Page(state:any) { - const [loginResult, dispatch] = useFormState(authenticate, undefined) + const [loginResult, dispatch] = useFormState(serverAttemptAuthenticateUser, undefined) console.log(dispatch); console.log(state); diff --git a/src/app/admin/page.tsx b/src/app/admin/page.tsx index 479e258..ff1034b 100644 --- a/src/app/admin/page.tsx +++ b/src/app/admin/page.tsx @@ -1,5 +1,5 @@ -import AdminPanel from "@/components/admin/adminPanel"; -import AuthHandler from "@/components/admin/authHandler"; +import AdminPanel from "@/components/client/admin/adminPanel"; +import AuthHandler from "@/components/server/admin/authHandler"; import { cookies } from "next/headers"; diff --git a/src/app/api/[...slug]/route.ts b/src/app/api/[...slug]/route.ts index 6f7544c..5cdd574 100644 --- a/src/app/api/[...slug]/route.ts +++ b/src/app/api/[...slug]/route.ts @@ -14,17 +14,10 @@ export async function GET(request:Request, { params }: {params:{slug: string}}){ // @ts-ignore cookies().set('name', 'lee'); return Response.json({ - "a": "lorem", - "b": params + "params": params }); } - - - - - - // export default async function handler(req:NextApiRequest, res:NextApiResponse) { // await MPost.sync(); // switch (req.method) { diff --git a/src/app/api/auth/route.ts b/src/app/api/auth/route.ts index 53c882d..af4664d 100644 --- a/src/app/api/auth/route.ts +++ b/src/app/api/auth/route.ts @@ -1,13 +1,10 @@ 'use server' -import { Model } from "sequelize"; import { cookies } from "next/headers"; -import { Auth, Post, User } from "@/model/sequelize/NewModels"; - - import { APIError} from "@/api/error" import { UserAuth, parseBasicAuth, getAssociatedUser } from "@/api/user" +import { Auth, User } from "@/model/Models"; async function tryAuth(request:Request){ @@ -31,15 +28,24 @@ async function tryAuth(request:Request){ user_id: user.id, }) + console.log('ok'); const foundAuth = await Auth.findOne({ - include: 'user', + include: { + model: User, + as: 'user' + }, where: { user_id: user.id } }) + console.log('ok2'); + if(!foundAuth) return new Response("error",{status:500}); + const usr = foundAuth.user; + + const authUser = await authentication.getUser(); diff --git a/src/app/api/auth/validate/route.ts b/src/app/api/auth/validate/route.ts index a00f847..d4a58c9 100644 --- a/src/app/api/auth/validate/route.ts +++ b/src/app/api/auth/validate/route.ts @@ -1,9 +1,10 @@ 'use server' -import { Model } from "sequelize"; +import { Model } from "@sequelize/core"; import { cookies } from "next/headers"; -import { Auth, Post, User } from "@/model/sequelize/NewModels"; + +import { Auth } from "@/model/Models"; import { APIError} from "@/api/error" @@ -23,9 +24,13 @@ async function tryAuth(request:Request){ console.log(koek); const auth = JSON.parse(koek.value); - const authentication = await Auth.findOne( { include: 'user', where: {token:auth.token} }) + + const authentication = await Auth.findOne( { include: { + association: Auth.associations.user + }, where: { token:auth.token } }) + if(!authentication) return new Response("unauthorized: invalid token",{status:403}); diff --git a/src/app/api/post/[...slug]/route.ts b/src/app/api/post/[...slug]/route.ts index 88d0b0c..4720622 100644 --- a/src/app/api/post/[...slug]/route.ts +++ b/src/app/api/post/[...slug]/route.ts @@ -1,7 +1,7 @@ 'use server' import { APIError } from "@/api/error"; -import { Post } from "@/model/sequelize/NewModels"; +import { Post } from "@/model/Models"; export async function tryFetchPost(request:Request, { params }: {params:{slug: string}}){ diff --git a/src/app/api/post/route.ts b/src/app/api/post/route.ts index 30d7bd3..adccadc 100644 --- a/src/app/api/post/route.ts +++ b/src/app/api/post/route.ts @@ -1,15 +1,16 @@ 'use server' import { APIError } from "@/api/error"; -import { Auth, Post, User } from "@/model/Models"; +import { Auth, Post, PostTag, Tag, User } from "@/model/Models"; import { cookies } from "next/headers"; -import { where } from "sequelize"; async function tryCreatePost(request: Request) { // Make sure the DB is ready + await PostTag.sync(); + await Tag.sync(); await Post.sync(); // Prepare data @@ -24,7 +25,7 @@ async function tryCreatePost(request: Request) { const authObject = JSON.parse(cookieJSON); // Fetch User Auth from the database - const auth = await Auth.findOne({ include: 'user', where: { token: authObject.token } }); + const auth:any = await Auth.findOne({ include: 'user', where: { token: authObject.token } }); // Sanity check the auth and associated user if (!auth || !auth.user) throw new APIError({ status: 401, responseText: "Authentication Error" }); @@ -35,6 +36,7 @@ async function tryCreatePost(request: Request) { if (!requestBody.title) throw new APIError({ status: 500, responseText: "Missing post title" }); if (!requestBody.content) throw new APIError({ status: 500, responseText: "Missing post content" }); if (!user.id) throw new APIError({ status: 500, responseText: "Missing user id" }); + if (!user.perms || !user.perms.isAdmin) throw new APIError({ status: 401, responseText: "Unauthorized" }); // Create a new Post in the database const post = await Post.create( @@ -42,8 +44,11 @@ async function tryCreatePost(request: Request) { content: requestBody.content, user_id: user.id, title: requestBody.title, - date: Date.now() - },{include: "user"}) + },{ + include: { + association: Post.associations.user + } + }).then(post=>post.reload()) // // Find the post (Unneeded but nice to check) // const foundPost = await Post.findOne({ // include: "user", @@ -52,7 +57,7 @@ async function tryCreatePost(request: Request) { // } // }) - return new Response(JSON.stringify(Post), { status: 200 }); + return new Response(JSON.stringify(post), { status: 200 }); } @@ -76,9 +81,12 @@ async function tryFetchPosts(request: Request) { await Post.sync(); const foundPosts = await Post.findAll({ - include: [{ - association: 'user', + include: [ + { + association: Post.associations.user, attributes: { exclude: ['password', 'createdAt', 'updatedAt'] } + },{ + association: Post.associations.postTags }] }); diff --git a/src/app/api/user/route.ts b/src/app/api/user/route.ts index 1e77698..2e81565 100644 --- a/src/app/api/user/route.ts +++ b/src/app/api/user/route.ts @@ -1,41 +1,48 @@ 'use server' -import { User, Auth, Post, UserPerms } from "@/model/sequelize/NewModels" + +/* ================================================================================================= + * + * Copyright 2024 Andreas Schaafsma + * Purpose: Handle API requests that fetch or permute User data + * + * ================================================================================================= */ + import { APIError } from "@/api/error"; import { UserAuth } from "@/api/user"; +import { UserPerms, User, Auth } from "@/model/Models"; // Do not alter "unused" imports, they are required to perform the nescessairy includes on the User model import { hashPassword } from "@/util/Auth"; - -async function tryRegister(request:Request){ +// Attempt to register a new User +async function attemptRegister(request:Request){ + // Sync User model User.sync(); - + // Get request body const requestBody:Partial = await request.json(); - + // Handle edgecases if(!requestBody) throw new APIError({status:500,responseText: "Request Body is Empty"}) if(!requestBody.username) throw new APIError({status:500,responseText: "No username specified"}) if(!requestBody.password) throw new APIError({status:500,responseText: "No password specified"}) - + // Try to get user from database const dbUser = await User.findOne({where:{username:requestBody.username}}); - + // If it exists we throw an error if(dbUser) throw new APIError({status:500,responseText: "Username unavailable, try another"}); - - const hash = await hashPassword(requestBody.password); + // Hash the password and create a new user in the database const user = await User.create({ username: requestBody.username, - password: hash, + password: await hashPassword(requestBody.password), perms:{ isAdmin: false } - }, { include: [{ - association: 'perms' + association: User.associations.perms }] - }) - + }).then(user=>user.reload()); + // Return the HTTP response return new Response( JSON.stringify( { @@ -52,7 +59,7 @@ async function tryRegister(request:Request){ export async function POST(request:Request){ try{ - return await tryRegister(request); + return await attemptRegister(request); } catch(e){ if (e instanceof APIError){ @@ -65,23 +72,9 @@ export async function POST(request:Request){ } } -async function tryGetUsers(request:Request){ - - const defaultScope:any = User.scope('defaultScope'); - - const mergedInclude = defaultScope.include ? [defaultScope.include] : []; - mergedInclude.push({ association: 'authtokens' }); - - // const mergedInclude = [...defaultScope.include, { association: 'authtokens' }]; - - const users = await User.findAll( - { - attributes: defaultScope.attributes, - include: mergedInclude, - } - ); - - +async function attemptGetUsers(request:Request){ + // Get users with scopes applied + const users = await User.withScope(['defaultScope','withPerms','withAuthtokens']).findAll(); return new Response( JSON.stringify( { @@ -98,7 +91,7 @@ async function tryGetUsers(request:Request){ export async function GET(request:Request){ try{ - return await tryGetUsers(request); + return await attemptGetUsers(request); } catch(e){ if (e instanceof APIError){ diff --git a/src/app/article/[...slug]/page.tsx b/src/app/article/[...slug]/page.tsx index af0b614..25017b7 100644 --- a/src/app/article/[...slug]/page.tsx +++ b/src/app/article/[...slug]/page.tsx @@ -1,21 +1,21 @@ -import Header from "@/components/header"; -import PageContainer from "@/components/page-container"; -import Navbar from "@/components/navbar"; -import Sidebar from "@/components/sidebar"; -import Article from "@/components/news/article"; -import ArticlePreview from "@/components/news/article-preview" +import Header from "@/components/shared/header"; +import PageContainer from "@/components/shared/page-container"; +import Navbar from "@/components/shared/navbar"; +import Sidebar from "@/components/shared/sidebar"; +import Article from "@/components/shared/news/article"; +import ArticlePreview from "@/components/shared/news/article-preview" + import ReactDOM from "react"; + import "/public/global.css" import "@/app/index.css" -import { Post, User } from "@/model/sequelize/NewModels"; -import { Attributes } from "sequelize"; + +import { Post } from "@/model/Post"; +import { Attributes } from "@sequelize/core"; +import { DeepPartial } from "@/util/DeepPartial"; -type DeepPartial = T extends object ? { - [P in keyof T]?: DeepPartial; -} : T; - -async function getData(slug:string):Promise> { +async function getData(slug:string):Promise> { // Get all posts from the API const res = await fetch(`http://localhost:3000/api/post/${slug}`); // The return value is *not* serialized @@ -31,7 +31,7 @@ async function getData(slug:string):Promise> { export default async function Page({ params }: {params: {slug:string}}) { const { slug } = params; - const post:DeepPartial> = await getData(slug); + const post:Attributes = await getData(slug); console.log(post); diff --git a/src/app/lib/actions.ts b/src/app/lib/actions.ts index 86faf5c..990054d 100644 --- a/src/app/lib/actions.ts +++ b/src/app/lib/actions.ts @@ -5,27 +5,30 @@ import { constructAPIUrl } from "@/util/Utils" import { cookies } from "next/headers" import { parseSetCookie } from "@/util/parseSetCookie"; import makeFetchCookie from 'fetch-cookie'; +import fetchCookie from "fetch-cookie"; type LoginReturn = { cookie?:unknown, errorMessage?:string; } -async function signIn(method:string,b:FormData):Promise +async function attemptAPILogin(method:string,b:FormData):Promise { console.log("form data:"); console.log(b); - if(!b || !b.get('input_username') || !b.get('input_password')) return null; let headers:Headers = new Headers(); - const fetchCookie = makeFetchCookie(fetch) - headers.set('Authorization', 'Basic ' + Buffer.from(b.get('input_username') + ":" + b.get('input_password')).toString('base64')); - let res = await fetchCookie(constructAPIUrl("auth"), { + const { CookieJar, Cookie } = fetchCookie.toughCookie; + const cj = new CookieJar() + const fetchKoek = makeFetchCookie(fetch, cj); + // Set Basic Auth + headers.set('Authorization', `Basic ${Buffer.from(`${b.get('input_username')}:${b.get('input_password')}`).toString('base64')}`); + let res = await fetchKoek(constructAPIUrl("auth"), { method:'POST', credentials: 'include', headers:headers, }); - + console.log(cj.store.idx['localhost']['/']); // if(res.headers.get('set-coo')) console.log(res.headers['set-cookie']) let koek = res.headers.getSetCookie(); // console.log("api koek:" + koek.map((k)=>decodeURIComponent(k))); @@ -40,11 +43,11 @@ async function signIn(method:string,b:FormData):Promise // console.log(koek); } -export async function authenticate(_currentState: unknown, formData: FormData):Promise +export async function serverAttemptAuthenticateUser(_currentState: unknown, formData: FormData):Promise { console.log("action triggered") try { - const signInStatus = await signIn('credentials', formData) + const signInStatus = await attemptAPILogin('credentials', formData) return signInStatus; } catch (error:any) { if (error) { @@ -62,10 +65,9 @@ export async function authenticate(_currentState: unknown, formData: FormData):P throw error } } -export async function koekValid(koek:string):Promise -{ - +export async function serverValidateSessionCookie(koek:string):Promise +{ const validateSession = await fetch(constructAPIUrl("auth/validate"),{ method:"POST", headers:{ diff --git a/src/app/page.tsx b/src/app/page.tsx index e549138..e74d1ff 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,14 +1,15 @@ -import Header from "@/components/header"; -import PageContainer from "@/components/page-container"; -import Navbar from "@/components/navbar"; -import Sidebar from "@/components/sidebar"; -import ArticlePreview from "@/components/news/article-preview" +import Header from "@/components/shared/header"; +import PageContainer from "@/components/shared/page-container"; +import Navbar from "@/components/shared/navbar"; +import Sidebar from "@/components/shared/sidebar"; +import ArticlePreview from "@/components/shared/news/article-preview" import ReactDOM from "react"; import "/public/global.css" import "./index.css" -import { Post, PostAttributes } from "@/model/sequelize/NewModels"; +import { Post } from "@/model/Post"; import { constructAPIUrl } from "@/util/Utils"; import Link from "next/link"; +import { Attributes } from "@sequelize/core"; type DeepPartial = T extends object ? { [P in keyof T]?: DeepPartial; @@ -18,7 +19,7 @@ export default async function Test() { const response = await fetch(constructAPIUrl('post')); - const articles:Array> = await response.json(); + const articles:Array> = await response.json(); return
@@ -32,9 +33,8 @@ export default async function Test() { */}
{articles.map((article, i) => { - console.log("Entered"); // Return the element. Also pass key - return () + return () })}
diff --git a/src/app/projects/page.tsx b/src/app/projects/page.tsx index 451f4a9..c164465 100644 --- a/src/app/projects/page.tsx +++ b/src/app/projects/page.tsx @@ -1,17 +1,30 @@ -import Header from "@/components/header"; -import PageContainer from "@/components/page-container"; -import Navbar from "@/components/navbar"; -import Sidebar from "@/components/sidebar"; -import ArticlePreview from "@/components/news/article-preview" -import ReactDOM from "react"; +// import components +import Header from "@/components/shared/header"; +import PageContainer from "@/components/shared/page-container"; +import Navbar from "@/components/shared/navbar"; +import Sidebar from "@/components/shared/sidebar"; +import ArticlePreview from "@/components/shared/news/article-preview" +// import styles import "public/global.css" import "@/app/index.css" +// import other shit +import ReactDOM, { ReactNode } from "react"; + +type Props = { + children?: ReactNode +} -export default function Page() { - return
-
- + +export default function Page(props: Props) { + + + + + return ( +
+
+

@@ -20,10 +33,10 @@ export default function Page() {
  • filter 1
  • filter 2
  • filter 3
- - - + + +
-

; +
); } \ No newline at end of file diff --git a/src/app/test/page.tsx b/src/app/test/page.tsx index 8e9bb5c..aa25358 100644 --- a/src/app/test/page.tsx +++ b/src/app/test/page.tsx @@ -1,7 +1,7 @@ import Header from "@/components/header"; -import PageContainer from "@/components/page-container"; +import PageContainer from "@/components/shared/page-container"; import Navbar from "@/components/navbar"; -import Sidebar from "@/components/sidebar"; +import Sidebar from "@/components/shared/sidebar"; import ArticlePreview from "@/components/news/article-preview" import ReactDOM from "react"; import "public/global.css" diff --git a/src/components/admin/adminPanel.tsx b/src/components/client/admin/adminPanel.tsx similarity index 90% rename from src/components/admin/adminPanel.tsx rename to src/components/client/admin/adminPanel.tsx index 1eb3959..610021f 100644 --- a/src/components/admin/adminPanel.tsx +++ b/src/components/client/admin/adminPanel.tsx @@ -1,7 +1,7 @@ 'use client' import { ReactNode, useContext } from "react"; import { AuthContext, AuthProps } from "@/providers/providers"; -import SomeServerSubComponent from "./serverContextUserTest"; +import SomeServerSubComponent from "@/components/server/admin/serverContextUserTest"; interface Props { children?: ReactNode; diff --git a/src/components/admin/clientAuthHandler.tsx b/src/components/client/admin/clientAuthHandler.tsx similarity index 100% rename from src/components/admin/clientAuthHandler.tsx rename to src/components/client/admin/clientAuthHandler.tsx diff --git a/src/components/admin/loginForm.tsx b/src/components/client/admin/loginForm.tsx similarity index 83% rename from src/components/admin/loginForm.tsx rename to src/components/client/admin/loginForm.tsx index 00103fc..39c05be 100644 --- a/src/components/admin/loginForm.tsx +++ b/src/components/client/admin/loginForm.tsx @@ -1,9 +1,8 @@ 'use client' -import { authenticate } from "@/app/lib/actions"; +import { serverAttemptAuthenticateUser } from "@/app/lib/actions"; import { AuthContext } from "@/providers/providers"; import { constructAPIUrl } from "@/util/Utils"; -import { cookies } from "next/headers"; import { createContext, useState } from "react"; import { useFormState, useFormStatus } from "react-dom"; @@ -15,11 +14,7 @@ import { useFormState, useFormStatus } from "react-dom"; export default function LoginForm(){ - const [loginResult, dispatch] = useFormState(authenticate, undefined); - - // if(loginResult?.cookie && loginResult.cookie && loginResult.cookie['auth']){ - // cookies().set('auth', loginResult.cookie['auth']) - // } + const [loginResult, dispatch] = useFormState(serverAttemptAuthenticateUser, undefined); return (
diff --git a/src/components/admin/authHandler.tsx b/src/components/server/admin/authHandler.tsx similarity index 62% rename from src/components/admin/authHandler.tsx rename to src/components/server/admin/authHandler.tsx index 97605f6..87c1027 100644 --- a/src/components/admin/authHandler.tsx +++ b/src/components/server/admin/authHandler.tsx @@ -1,13 +1,14 @@ 'use server' import { cookies } from "next/headers"; -// import { useState } from "react"; -import LoginForm from "./loginForm"; -import { koekValid } from "@/app/lib/actions"; + +import LoginForm from "@/components/client/admin/loginForm"; +import AdminPanel from "@/components/client/admin/adminPanel"; +import ClientAuthHandler from "@/components/client/admin/clientAuthHandler"; + +import { serverValidateSessionCookie } from "@/app/lib/actions"; import { constructAPIUrl } from "@/util/Utils"; -import AdminPanel from "./adminPanel"; import { ReactNode } from "react"; import { AuthContext, AuthProps } from "@/providers/providers"; -import ClientAuthHandler from "./clientAuthHandler"; interface Props { @@ -17,10 +18,9 @@ interface Props { } // We interfacing lads - export default async function AuthHandler(props: Props) { const protoKoek = await cookies().get('auth')?.value; - const koek = decodeURIComponent(protoKoek?protoKoek:""); + const koek = decodeURIComponent(protoKoek ? protoKoek: ""); console.log("koekje:" + koek) let p:AuthProps = { test:"not pog" @@ -41,7 +41,7 @@ export default async function AuthHandler(props: Props) { return (
- {!(koek && await koekValid(koek)) ? { } :
{props.children}
signed in! :D
} + {!(koek && await serverValidateSessionCookie(koek)) ? { } :
{props.children}
signed in! :D
}
); } diff --git a/src/components/admin/serverContextUserTest.tsx b/src/components/server/admin/serverContextUserTest.tsx similarity index 98% rename from src/components/admin/serverContextUserTest.tsx rename to src/components/server/admin/serverContextUserTest.tsx index 4dd9b05..e347983 100644 --- a/src/components/admin/serverContextUserTest.tsx +++ b/src/components/server/admin/serverContextUserTest.tsx @@ -8,6 +8,8 @@ interface Props { export default function SomeServerSubComponent(props:Props){ let { test, auth } = useContext(AuthContext); + + return ( {test}{JSON.stringify(auth)} ); diff --git a/src/components/bootstrap.tsx b/src/components/shared/bootstrap.tsx similarity index 100% rename from src/components/bootstrap.tsx rename to src/components/shared/bootstrap.tsx diff --git a/src/components/header.module.css b/src/components/shared/header.module.css similarity index 100% rename from src/components/header.module.css rename to src/components/shared/header.module.css diff --git a/src/components/header.tsx b/src/components/shared/header.tsx similarity index 100% rename from src/components/header.tsx rename to src/components/shared/header.tsx diff --git a/src/components/navbar.module.css b/src/components/shared/navbar.module.css similarity index 100% rename from src/components/navbar.module.css rename to src/components/shared/navbar.module.css diff --git a/src/components/navbar.tsx b/src/components/shared/navbar.tsx similarity index 100% rename from src/components/navbar.tsx rename to src/components/shared/navbar.tsx diff --git a/src/components/news/article-preview.module.css b/src/components/shared/news/article-preview.module.css similarity index 100% rename from src/components/news/article-preview.module.css rename to src/components/shared/news/article-preview.module.css diff --git a/src/components/news/article-preview.tsx b/src/components/shared/news/article-preview.tsx similarity index 89% rename from src/components/news/article-preview.tsx rename to src/components/shared/news/article-preview.tsx index 3de3b6d..c7ac6fe 100644 --- a/src/components/news/article-preview.tsx +++ b/src/components/shared/news/article-preview.tsx @@ -1,5 +1,5 @@ -import Tagbar from "@/components/news/tagbar"; -import styles from "./article-preview.module.css" +import Tagbar from "@/components/shared/news/tagbar"; +import styles from "@/components/shared/news/article-preview.module.css" import bg from "public/placeholder-square.png" import { ReactNode } from "react" diff --git a/src/components/news/article.module.css b/src/components/shared/news/article.module.css similarity index 100% rename from src/components/news/article.module.css rename to src/components/shared/news/article.module.css diff --git a/src/components/news/article.tsx b/src/components/shared/news/article.tsx similarity index 92% rename from src/components/news/article.tsx rename to src/components/shared/news/article.tsx index 6dca98c..829a832 100644 --- a/src/components/news/article.tsx +++ b/src/components/shared/news/article.tsx @@ -1,4 +1,4 @@ -import Tagbar from "@/components/news/tagbar"; +import Tagbar from "@/components/shared/news/tagbar"; import "/public/global.css" import "@/app/index.css" import styles from "./article.module.css" diff --git a/src/components/news/tagbar.module.css b/src/components/shared/news/tagbar.module.css similarity index 100% rename from src/components/news/tagbar.module.css rename to src/components/shared/news/tagbar.module.css diff --git a/src/components/news/tagbar.tsx b/src/components/shared/news/tagbar.tsx similarity index 100% rename from src/components/news/tagbar.tsx rename to src/components/shared/news/tagbar.tsx diff --git a/src/components/page-container.module.css b/src/components/shared/page-container.module.css similarity index 100% rename from src/components/page-container.module.css rename to src/components/shared/page-container.module.css diff --git a/src/components/page-container.tsx b/src/components/shared/page-container.tsx similarity index 100% rename from src/components/page-container.tsx rename to src/components/shared/page-container.tsx diff --git a/src/components/page-template.tsx b/src/components/shared/page-template.tsx similarity index 100% rename from src/components/page-template.tsx rename to src/components/shared/page-template.tsx diff --git a/src/components/sidebar.module.css b/src/components/shared/sidebar.module.css similarity index 100% rename from src/components/sidebar.module.css rename to src/components/shared/sidebar.module.css diff --git a/src/components/sidebar.tsx b/src/components/shared/sidebar.tsx similarity index 100% rename from src/components/sidebar.tsx rename to src/components/shared/sidebar.tsx diff --git a/src/model/APIKey.ts b/src/model/APIKey.ts new file mode 100644 index 0000000..55a5c88 --- /dev/null +++ b/src/model/APIKey.ts @@ -0,0 +1,42 @@ +import { Association, CreationOptional, DataTypes, HasManyGetAssociationsMixin, HasOneCreateAssociationMixin, HasOneGetAssociationMixin, InferAttributes, InferCreationAttributes, Model, NonAttribute, Sequelize } from "@sequelize/core"; +import { + PrimaryKey, + Attribute, + AutoIncrement, + NotNull, + BelongsTo, + Unique, + HasMany, + HasOne, + UpdatedAt, + CreatedAt, +} from '@sequelize/core/decorators-legacy'; + +import { SqliteDialect } from '@sequelize/sqlite3'; + + +export class APIKey extends Model, InferCreationAttributes>{ + // Attributes + @Attribute(DataTypes.INTEGER) + @PrimaryKey + @AutoIncrement + @Unique + declare id: number; + @Attribute(DataTypes.UUID) + declare key: string; + @Attribute(DataTypes.BOOLEAN) + declare isAdminKey: boolean + + // Date thingies + @CreatedAt + declare createdAt: CreationOptional; + @UpdatedAt + declare updatedAt: CreationOptional; + +} + +const sequelize = new Sequelize({ + dialect: SqliteDialect, + storage: 'db.sqlite', + models: [APIKey] +}); diff --git a/src/model/Auth.ts b/src/model/Auth.ts index 33b7fa5..1070714 100644 --- a/src/model/Auth.ts +++ b/src/model/Auth.ts @@ -1,37 +1,54 @@ -import { Association, BelongsToGetAssociationMixin, CreationOptional, DataTypes, ForeignKey, InferAttributes, InferCreationAttributes, Model, Sequelize, UUIDV4 } from "sequelize"; +import { + Sequelize, + DataTypes, + Model, + InferAttributes, + InferCreationAttributes, + CreationOptional, + sql, + BelongsToGetAssociationMixin, + Association, + NonAttribute, + } from '@sequelize/core'; + import { User } from "./User"; -const sequelize = new Sequelize({ - dialect: 'sqlite', - storage: 'db.sqlite' -}); - +import { SqliteDialect } from '@sequelize/sqlite3'; +import { Attribute, AutoIncrement, BelongsTo, Default, NotNull, PrimaryKey, Table, Unique } from "@sequelize/core/decorators-legacy"; +@Table({ + tableName: 'Auths' +}) export class Auth extends Model, InferCreationAttributes> { + + @Attribute(DataTypes.INTEGER) + @PrimaryKey + @AutoIncrement + @Unique declare id: CreationOptional; + + @Attribute(DataTypes.UUIDV4) + @Default(sql.uuidV4) declare token: CreationOptional; - declare user_id:ForeignKey; + + @Attribute(DataTypes.INTEGER) + @NotNull + declare user_id:number; + + @BelongsTo( ()=>User, { foreignKey: 'user_id', inverse: { type: 'hasMany', as: 'authtokens' } } ) + declare user?: NonAttribute + + declare getUser: BelongsToGetAssociationMixin; declare static associations: { user: Association; }; } -Auth.init({ - id: { - allowNull: false, - autoIncrement: true, - type: DataTypes.INTEGER, - primaryKey: true, - unique: true, - }, - token: { - type: DataTypes.UUID, - defaultValue: UUIDV4 - } -}, -{ - tableName: 'Auths', - sequelize // passing the `sequelize` instance is required -}); \ No newline at end of file + +const sequelize = new Sequelize({ + dialect: SqliteDialect, + storage: 'db.sqlite', + models: [Auth] +}); diff --git a/src/model/Models.ts b/src/model/Models.ts index c0f4672..0f2a399 100644 --- a/src/model/Models.ts +++ b/src/model/Models.ts @@ -1,20 +1,15 @@ -import { - Association, DataTypes, HasManyAddAssociationMixin, HasManyCountAssociationsMixin, - HasManyCreateAssociationMixin, HasManyGetAssociationsMixin, HasManyHasAssociationMixin, - HasManySetAssociationsMixin, HasManyAddAssociationsMixin, HasManyHasAssociationsMixin, - HasManyRemoveAssociationMixin, HasManyRemoveAssociationsMixin, Model, ModelDefined, Optional, - Sequelize, InferAttributes, InferCreationAttributes, CreationOptional, NonAttribute, ForeignKey, BelongsTo, BelongsToGetAssociationMixin, UUIDV4, UUID, - VirtualDataType, - HasOneGetAssociationMixin, - HasOneCreateAssociationMixin - } from 'sequelize'; - -import { UserPerms } from './UserPerms'; -import { Auth } from './Auth'; -import { Post } from './Post'; import { User } from './User'; +import { Auth } from './Auth'; +import { UserPerms } from './UserPerms'; +import { Post } from './Post'; +import { Tag } from './Tag'; +import { PostTag } from './PostTag'; +User.sync(); +Auth.sync(); +UserPerms.sync(); +PostTag.sync(); +Tag.sync(); +Post.sync(); - - -export { User, Auth, Post, UserPerms } \ No newline at end of file +export { User, Auth, UserPerms, Post, Tag, PostTag } \ No newline at end of file diff --git a/src/model/Post.ts b/src/model/Post.ts index 5a2848b..858246d 100644 --- a/src/model/Post.ts +++ b/src/model/Post.ts @@ -1,56 +1,53 @@ -import { Association, BelongsToGetAssociationMixin, DataTypes, ForeignKey, Model, NonAttribute, Sequelize } from "sequelize"; -import { User } from "./User"; +import { Association, BelongsToGetAssociationMixin, CreationOptional, DataTypes, ForeignKey, InferAttributes, InferCreationAttributes, Model, NonAttribute, Sequelize } from "@sequelize/core";import { User } from "./User"; -const sequelize = new Sequelize({ - dialect: 'sqlite', - storage: 'db.sqlite' -}); +import { SqliteDialect } from '@sequelize/sqlite3'; +import { Attribute, AutoIncrement, BelongsTo, BelongsToMany, CreatedAt, HasMany, NotNull, PrimaryKey, Unique, UpdatedAt } from "@sequelize/core/decorators-legacy"; +import { Tag } from "./Tag"; +import { PostTag } from "./PostTag"; -export type PostAttributes = { - id: number; - title: string; - content: string; - date: number; - user_id:ForeignKey; -} -export type PostCreationAttributes = { - title: string; - content: string; - date: number; - user_id:number; -} -export class Post extends Model { - declare id: number; - declare user:NonAttribute; +export class Post extends Model, InferCreationAttributes> { + + + // Attributes + @Attribute(DataTypes.INTEGER) + @PrimaryKey + @AutoIncrement + @Unique + declare id: CreationOptional; + @Attribute(DataTypes.INTEGER) + @NotNull declare user_id:ForeignKey; + @Attribute(DataTypes.STRING) + declare title:string + @Attribute(DataTypes.STRING) + declare content:string + + // Date thingies + @CreatedAt + declare createdAt: CreationOptional; + @UpdatedAt + declare updatedAt: CreationOptional; + + + + // Associatoins + + @BelongsTo(()=>User, { foreignKey: 'user_id', inverse: { type: 'hasMany', as: 'posts' } }) + declare user:NonAttribute; + + @BelongsToMany(()=>Tag, { through: { model: ()=>PostTag, unique: false}, inverse: {as: 'taggedPosts'} }) + declare postTags?:NonAttribute; + declare getUser: BelongsToGetAssociationMixin; + declare static associations: { user: Association; + postTags: Association; }; } -Post.init( - { - id: { - allowNull: false, - autoIncrement: true, - type: DataTypes.INTEGER, - primaryKey: true, - unique: true, - }, - content: { - type: DataTypes.STRING - }, - title: { - type: DataTypes.STRING - }, - date: { - type: DataTypes.DATE - }, - - }, - { - tableName: 'Posts', - sequelize // passing the `sequelize` instance is required - } -); \ No newline at end of file +const sequelize = new Sequelize({ + dialect: SqliteDialect, + storage: 'db.sqlite', + models: [Post] +}) \ No newline at end of file diff --git a/src/model/PostTag.ts b/src/model/PostTag.ts new file mode 100644 index 0000000..bab3ccf --- /dev/null +++ b/src/model/PostTag.ts @@ -0,0 +1,20 @@ +import Sequelize, { Association, DataTypes, InferAttributes, InferCreationAttributes, Model, NonAttribute } from "@sequelize/core"; +import { Attribute, AutoIncrement, NotNull, PrimaryKey, Unique } from "@sequelize/core/decorators-legacy"; +import { Post } from "./Post"; +import { Tag } from "./Tag"; +import { SqliteDialect } from "@sequelize/sqlite3"; + + +class PostTag extends Model,InferCreationAttributes> +{ + declare postId:number; + declare tagId:number; +} + +const sequelize = new Sequelize({ + dialect: SqliteDialect, + storage: 'db.sqlite', + models: [PostTag] +}) + +export { PostTag } \ No newline at end of file diff --git a/src/model/Project.ts b/src/model/Project.ts new file mode 100644 index 0000000..178e384 --- /dev/null +++ b/src/model/Project.ts @@ -0,0 +1,56 @@ +import { Association, BelongsToGetAssociationMixin, CreationOptional, DataTypes, ForeignKey, InferAttributes, InferCreationAttributes, Model, NonAttribute, Sequelize } from "@sequelize/core";import { User } from "./User"; + +import { SqliteDialect } from '@sequelize/sqlite3'; + +const sequelize = new Sequelize({ + dialect: SqliteDialect, + storage: 'db.sqlite' +}); +export type ProjectAttributes = { + id: number; + title: string; + description: string; + date: number; + user_id:ForeignKey; +} +export type ProjectCreationAttributes = { + title: string; + description: string; + date: number; + user_id:number; +} +export class Project extends Model { + declare id: number; + declare user:NonAttribute; + declare user_id:ForeignKey; + declare getUser: BelongsToGetAssociationMixin; + declare static associations: { + user: Association; + }; +} + +Project.init( + { + id: { + allowNull: false, + autoIncrement: true, + type: DataTypes.INTEGER, + primaryKey: true, + unique: true, + }, + content: { + type: DataTypes.STRING + }, + title: { + type: DataTypes.STRING + }, + date: { + type: DataTypes.DATE + }, + + }, + { + tableName: 'Projects', + sequelize // passing the `sequelize` instance is required + } +); \ No newline at end of file diff --git a/src/model/Tag.ts b/src/model/Tag.ts new file mode 100644 index 0000000..ea99f8f --- /dev/null +++ b/src/model/Tag.ts @@ -0,0 +1,28 @@ +import { Association, BelongsToGetAssociationMixin, BelongsToManyGetAssociationsMixin, DataTypes, ForeignKey, InferAttributes, InferCreationAttributes, Model, NonAttribute, Sequelize } from "@sequelize/core"; +import { Post } from "./Post"; + +import { SqliteDialect } from '@sequelize/sqlite3'; +import { Attribute, AutoIncrement, BelongsToMany, PrimaryKey, Unique } from "@sequelize/core/decorators-legacy"; + +export class Tag extends Model, InferCreationAttributes> { + @PrimaryKey + @AutoIncrement + @Attribute(DataTypes.INTEGER) + @Unique + declare id: number; + + /** Defined by {@link Post.postTags} */ + declare taggedPosts?:NonAttribute; + + declare user_id:ForeignKey; + declare getPost: BelongsToManyGetAssociationsMixin; + declare static associations: { + posts: Association; + }; +} + +const sequelize = new Sequelize({ + dialect: SqliteDialect, + storage: 'db.sqlite', + models: [Tag] +}) diff --git a/src/model/User.ts b/src/model/User.ts index 8a601c1..20a9498 100644 --- a/src/model/User.ts +++ b/src/model/User.ts @@ -1,91 +1,85 @@ -import { Association, DataTypes, HasManyGetAssociationsMixin, HasOneCreateAssociationMixin, HasOneGetAssociationMixin, InferAttributes, InferCreationAttributes, Model, NonAttribute, Sequelize } from "sequelize"; +import { Association, Attributes, CreationAttributes, CreationOptional, DataTypes, HasManyGetAssociationsMixin, HasOneCreateAssociationMixin, HasOneGetAssociationMixin, InferAttributes, InferCreationAttributes, Model, NonAttribute, Sequelize } from "@sequelize/core"; import { Post } from "./Post"; import { UserPerms } from "./UserPerms"; import { Auth } from "./Auth"; +import { + PrimaryKey, + Attribute, + AutoIncrement, + NotNull, + BelongsTo, + Unique, + HasMany, + HasOne, + UpdatedAt, + CreatedAt, +} from '@sequelize/core/decorators-legacy'; -const sequelize = new Sequelize({ - dialect: 'sqlite', - storage: 'db.sqlite' -}); +import { SqliteDialect } from '@sequelize/sqlite3'; + +type UserCreationAttributes = { + username:string; + password:string; + perms?:Partial> +} export class User extends Model, InferCreationAttributes>{ - declare id: number|null; + + @Attribute(DataTypes.INTEGER) + @PrimaryKey + @AutoIncrement + @Unique + declare id: CreationOptional; + @Attribute(DataTypes.STRING) declare username: string; + @Attribute(DataTypes.STRING) declare password: string; + + // Date thingies + + @CreatedAt + declare createdAt: CreationOptional; + @UpdatedAt + declare updatedAt: CreationOptional; + + // Associations declare getAuthTokens:HasManyGetAssociationsMixin; declare getPosts:HasManyGetAssociationsMixin; declare getPerms:HasOneGetAssociationMixin; declare createPerms:HasOneCreateAssociationMixin; - declare perms?:NonAttribute + + /** Defined by {@link Auth.user} */ + declare authtokens?:NonAttribute + /** Defined by {@link UserPerms.user} */ + declare perms?:CreationOptional>> + /** Defined by {@link Post.user} */ + declare posts?:CreationOptional + declare static associations: { perms: Association; + posts: Association + authtokens: Association; }; - + } -User.init( - { - id: { - allowNull: false, - autoIncrement: true, - type: DataTypes.INTEGER, - primaryKey: true, - unique: true, - }, - username: { - allowNull: false, - type: DataTypes.STRING, - }, - password: { - allowNull: false, - type: DataTypes.STRING, - }, - }, - { - defaultScope: { - attributes: { - exclude: ['password'], - }, - include: [{ association: 'perms' }], - }, - tableName: 'Users', - sequelize // passing the `sequelize` instance is required +const sequelize = new Sequelize({ + dialect: SqliteDialect, + storage: 'db.sqlite', + models: [User] +}); + + +User.addScope('defaultScope',{ + attributes: { + exclude: ['password', 'createdAt', 'updatedAt'], } -); - -Auth.belongsTo(User, { - foreignKey:'user_id', - targetKey:'id', - as: 'user', -}) -User.hasMany(Auth, { - sourceKey: 'id', - foreignKey: 'user_id', - as: 'authtokens' // this determines the name in `associations`! }); -Post.belongsTo(User, { - foreignKey:'user_id', - targetKey:'id', - as: 'user' -}) -User.hasMany(Post, { - sourceKey: 'id', - foreignKey: 'user_id', - as: 'posts' // this determines the name in `associations`! -}); -UserPerms.belongsTo(User, { - foreignKey:'user_id', - targetKey:'id', - as: 'user' -}) -User.hasOne(UserPerms, { - sourceKey: 'id', - foreignKey: 'user_id', - as: 'perms' + +User.addScope('withPerms',{ + include: [{association: 'perms' }] }) - -User.sync(); -Auth.sync(); -Post.sync(); -UserPerms.sync(); \ No newline at end of file +User.addScope('withAuthtokens',{ + include: [{association: 'authtokens'}] +}) \ No newline at end of file diff --git a/src/model/UserPerms.ts b/src/model/UserPerms.ts index aa3b9ca..1c718da 100644 --- a/src/model/UserPerms.ts +++ b/src/model/UserPerms.ts @@ -1,32 +1,46 @@ -import { CreationOptional, DataTypes, ForeignKey, InferAttributes, InferCreationAttributes, Model, NonAttribute, Sequelize } from "sequelize"; +import { CreationOptional, DataTypes, ForeignKey, InferAttributes, InferCreationAttributes, Model, NonAttribute, Sequelize } from "@sequelize/core"; import { User } from "./User"; +import { SqliteDialect } from '@sequelize/sqlite3'; +import { Attribute, AutoIncrement, BelongsTo, CreatedAt, PrimaryKey, Table, Unique, UpdatedAt } from "@sequelize/core/decorators-legacy"; + +@Table({ + tableName: "Perms" +}) +export class UserPerms extends Model, InferCreationAttributes> { + @Attribute(DataTypes.INTEGER) + @PrimaryKey + @AutoIncrement + @Unique + declare id: CreationOptional; + @BelongsTo(()=>User, { foreignKey: 'user_id', inverse: { as: 'perms', type: 'hasOne' } }) + declare user:NonAttribute; + @Attribute(DataTypes.INTEGER) + declare user_id:ForeignKey; + @Attribute(DataTypes.BOOLEAN) + declare isAdmin:CreationOptional; + @CreatedAt + declare createdAt: CreationOptional; + @UpdatedAt + declare updatedAt: CreationOptional; + +} + + const sequelize = new Sequelize({ - dialect: 'sqlite', - storage: 'db.sqlite' + dialect: SqliteDialect, + storage: 'db.sqlite', + models: [UserPerms], }); -export class UserPerms extends Model, InferCreationAttributes> { - declare id: CreationOptional; - declare user:NonAttribute; - declare user_id:ForeignKey; - declare isAdmin:CreationOptional; -} -UserPerms.init({ - id: { - allowNull: false, - autoIncrement: true, - type: DataTypes.INTEGER, - primaryKey: true, - unique: true, - }, - isAdmin: { - allowNull: false, - defaultValue: false, - type: DataTypes.BOOLEAN + +UserPerms.addScope('defaultScope',{ + attributes: { + exclude: ['createdAt', 'updatedAt'], + } +}); +UserPerms.addScope('withTimestamps',{ + attributes: { + include: ['createdAt', 'updatedAt'], } -}, -{ - tableName: 'Perms', - sequelize // passing the `sequelize` instance is required }); \ No newline at end of file diff --git a/src/providers/providers.tsx b/src/providers/providers.tsx index 0c32eb7..ec63481 100644 --- a/src/providers/providers.tsx +++ b/src/providers/providers.tsx @@ -1,14 +1,15 @@ 'use client' -import { Auth, User } from "@/model/sequelize/NewModels"; +import { Auth } from "@/model/Auth"; +import { User } from "@/model/User"; import { ReactNode, createContext } from "react"; -import { InferAttributes } from "sequelize/types/model"; +import { Attributes, InferAttributes } from "@sequelize/core"; export type AuthProps = { test: string; - auth?: InferAttributes - user?: InferAttributes + auth?: Attributes + user?: Attributes } let p: AuthProps = { test: "lorem", diff --git a/src/util/DeepPartial.ts b/src/util/DeepPartial.ts new file mode 100644 index 0000000..ced4d4d --- /dev/null +++ b/src/util/DeepPartial.ts @@ -0,0 +1,3 @@ +export type DeepPartial = T extends object ? { + [P in keyof T]?: DeepPartial; +} : T; diff --git a/src/util/parseSetCookie.ts b/src/util/parseSetCookie.ts index 36fdab6..d93d530 100644 --- a/src/util/parseSetCookie.ts +++ b/src/util/parseSetCookie.ts @@ -1,6 +1,7 @@ export function parseSetCookie(h: string[]) { + const penisregex = /(.*?)=(.*?)($|;|,(?! ))/gm; let aaa = h.map( - s => [...s.matchAll(/(.*?)=(.*?)($|;|,(?! ))/gm)] + s => [...s.matchAll(penisregex)] ); const dict = Object.assign({}, ...aaa[0].map((e) => { return { [e[1]]: decodeURIComponent(e[2]) }; diff --git a/tsconfig.json b/tsconfig.json index 0c7555f..1718db6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,15 +1,16 @@ { "compilerOptions": { - "target": "es5", + "target": "ES2022", "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, "strict": true, "forceConsistentCasingInFileNames": true, + "module": "NodeNext", + "moduleResolution": "NodeNext", + "experimentalDecorators": true, "noEmit": true, "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "node", "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve",