Compare commits
2 Commits
b5008a9dc8
...
09ff76e02d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
09ff76e02d | ||
|
|
db1bbe825a |
@ -0,0 +1,46 @@
|
||||
cat ecosystem.config.cjs
|
||||
module.exports = {
|
||||
apps: [{
|
||||
name: 'vigilanza-turni',
|
||||
script: 'npm',
|
||||
args: 'start',
|
||||
env: {
|
||||
NODE_ENV: 'production',
|
||||
PORT: 5000,
|
||||
DATABASE_URL: 'postgresql://vigilanza_user:X8rWvmmeHbsUiKgSNr6dVOPBo@localhost:5432/vigilanza_turni?sslmode=disable',
|
||||
DOMAIN: 'vt.alfacom.it',
|
||||
SESSION_SECRET: 'abbaialacanadellacanna',
|
||||
ISSUER_URL: 'https://replit.com/oidc'
|
||||
}
|
||||
}]
|
||||
};
|
||||
[root@localhost vigilanza-turni]# pm2 delete vigilanza-turni
|
||||
[PM2] Applying action deleteProcessId on app [vigilanza-turni](ids: [ 0 ])
|
||||
[PM2] [vigilanza-turni](0) ✓
|
||||
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
|
||||
│ id │ name │ mode │ ↺ │ status │ cpu │ memory │
|
||||
└────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
|
||||
[root@localhost vigilanza-turni]# pm2 start ecosystem.config.cjs
|
||||
[PM2][WARN] Applications vigilanza-turni not running, starting...
|
||||
[PM2] App [vigilanza-turni] launched (1 instances)
|
||||
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
|
||||
│ id │ name │ mode │ ↺ │ status │ cpu │ memory │
|
||||
├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤
|
||||
│ 0 │ vigilanza-turni │ fork │ 0 │ online │ 0% │ 6.4mb │
|
||||
└────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
|
||||
[root@localhost vigilanza-turni]# pm2 save
|
||||
[PM2] Saving current process list...
|
||||
[PM2] Successfully saved in /root/.pm2/dump.pm2
|
||||
[root@localhost vigilanza-turni]# curl https://vt.alfacom.it/api/auto-login-admin
|
||||
{"error":"Errore server","message":"Hostname/IP does not match certificate's altnames: Host: localhost. is not in the cert's altnames: DNS:vt.alfacom.it"}[root@localhost vigilanza-turni]# cat .env
|
||||
DATABASE_URL=postgresql://vigilanza_user:X8rWvmmeHbsUiKgSNr6dVOPBo@localhost:5432/vigilanza_turni?sslmode=disable
|
||||
PGDATABASE=vigilanza_turni
|
||||
PGUSER=vigilanza_user
|
||||
PGPASSWORD=X8rWvmmeHbsUiKgSNr6dVOPBo
|
||||
PGHOST=localhost
|
||||
PGPORT=5432
|
||||
SESSION_SECRET=abbaialacanadellacanna
|
||||
NODE_ENV=production
|
||||
PORT=5000
|
||||
DOMAIN=vt.alfacom.it
|
||||
ISSUER_URL=https://replit.com/oidc
|
||||
@ -0,0 +1,159 @@
|
||||
cd /var/www/vigilanza-turni
|
||||
git pull origin main
|
||||
npm run build
|
||||
remote: Enumerating objects: 12, done.
|
||||
remote: Counting objects: 100% (12/12), done.
|
||||
remote: Compressing objects: 100% (7/7), done.
|
||||
remote: Total 7 (delta 5), reused 0 (delta 0), pack-reused 0 (from 0)
|
||||
Unpacking objects: 100% (7/7), 4.43 KiB | 756.00 KiB/s, done.
|
||||
From https://git.alfacom.it/marco/VigilanzaTurni
|
||||
* branch main -> FETCH_HEAD
|
||||
51a2eec..b5008a9 main -> origin/main
|
||||
Updating 51a2eec..b5008a9
|
||||
Fast-forward
|
||||
.replit | 4 -
|
||||
...done-remote-Counting-objects-100-19-19--1760633252233_1760633252233.txt | 140 ++++++++++++++++++++++++++++++++++
|
||||
server/localAuth.ts | 28 +++++--
|
||||
3 files changed, 163 insertions(+), 9 deletions(-)
|
||||
create mode 100644 attached_assets/Pasted-git-pull-origin-main-remote-Enumerating-objects-19-done-remote-Counting-objects-100-19-19--1760633252233_1760633252233.txt
|
||||
|
||||
> rest-express@1.0.0 build
|
||||
> vite build && esbuild server/index.ts --platform=node --packages=external --bundle --format=esm --outdir=dist
|
||||
|
||||
vite v5.4.20 building for production...
|
||||
transforming (3) src/main.tsxBrowserslist: browsers data (caniuse-lite) is 12 months old. Please run:
|
||||
npx update-browserslist-db@latest
|
||||
Why you should do it regularly: https://github.com/browserslist/update-db#readme
|
||||
transforming (4) src/App.tsx
|
||||
A PostCSS plugin did not pass the `from` option to `postcss.parse`. This may cause imported assets to be incorrectly
|
||||
transformed. If you've recently added a PostCSS plugin that raised this warning, please contact the package author to fix the issue.
|
||||
✓ 2673 modules transformed.
|
||||
../dist/public/index.html 1.49 kB │ gzip: 0.63 kB
|
||||
../dist/public/assets/index-DdJrKUWT.css 75.43 kB │ gzip: 12.17 kB
|
||||
../dist/public/assets/index-C9iY8fDP.js 590.69 kB │ gzip: 173.23 kB
|
||||
|
||||
(!) Some chunks are larger than 500 kB after minification. Consider:
|
||||
- Using dynamic import() to code-split the application
|
||||
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
|
||||
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
|
||||
✓ built in 9.07s
|
||||
|
||||
dist/index.js 62.0kb
|
||||
|
||||
⚡ Done in 15ms
|
||||
[root@localhost vigilanza-turni]# pm2 restart vigilanza-turni
|
||||
Use --update-env to update environment variables
|
||||
[PM2] Applying action restartProcessId on app [vigilanza-turni](ids: [ 0 ])
|
||||
[PM2] [vigilanza-turni](0) ✓
|
||||
┌────┬────────────────────┬──────────┬──────┬───────────┬──────────┬──────────┐
|
||||
│ id │ name │ mode │ ↺ │ status │ cpu │ memory │
|
||||
├────┼────────────────────┼──────────┼──────┼───────────┼──────────┼──────────┤
|
||||
│ 0 │ vigilanza-turni │ fork │ 4 │ online │ 0% │ 12.6mb │
|
||||
└────┴────────────────────┴──────────┴──────┴───────────┴──────────┴──────────┘
|
||||
[root@localhost vigilanza-turni]# pm2 logs vigilanza-turni --lines 50 --nostream
|
||||
[TAILING] Tailing last 50 lines for [vigilanza-turni] process (change the value with --lines option)
|
||||
/root/.pm2/logs/vigilanza-turni-error.log last 50 lines:
|
||||
0|vigilanz | _errorEmitted: true,
|
||||
0|vigilanz | _extensions: {},
|
||||
0|vigilanz | _paused: false,
|
||||
0|vigilanz | _protocol: '',
|
||||
0|vigilanz | _readyState: 3,
|
||||
0|vigilanz | _receiver: null,
|
||||
0|vigilanz | _sender: null,
|
||||
0|vigilanz | _socket: null,
|
||||
0|vigilanz | _bufferedAmount: 0,
|
||||
0|vigilanz | _isServer: false,
|
||||
0|vigilanz | _redirects: 0,
|
||||
0|vigilanz | _autoPong: true,
|
||||
0|vigilanz | _url: 'wss://localhost/v2',
|
||||
0|vigilanz | _req: null,
|
||||
0|vigilanz | [Symbol(shapeMode)]: false,
|
||||
0|vigilanz | [Symbol(kCapture)]: false
|
||||
0|vigilanz | },
|
||||
0|vigilanz | [Symbol(kType)]: 'error',
|
||||
0|vigilanz | [Symbol(kError)]: Error [ERR_TLS_CERT_ALTNAME_INVALID]: Hostname/IP does not match certificate's altnames: Host: localhost. is not in the cert's altnames: DNS:vt.alfacom.it
|
||||
0|vigilanz | at Object.checkServerIdentity (node:tls:316:12)
|
||||
0|vigilanz | at TLSSocket.onConnectSecure (node:_tls_wrap:1687:27)
|
||||
0|vigilanz | at TLSSocket.emit (node:events:524:28)
|
||||
0|vigilanz | at TLSSocket._finishInit (node:_tls_wrap:1076:8)
|
||||
0|vigilanz | at ssl.onhandshakedone (node:_tls_wrap:862:12) {
|
||||
0|vigilanz | code: 'ERR_TLS_CERT_ALTNAME_INVALID',
|
||||
0|vigilanz | reason: "Host: localhost. is not in the cert's altnames: DNS:vt.alfacom.it",
|
||||
0|vigilanz | host: 'localhost',
|
||||
0|vigilanz | cert: {
|
||||
0|vigilanz | subject: [Object: null prototype],
|
||||
0|vigilanz | issuer: [Object: null prototype],
|
||||
0|vigilanz | subjectaltname: 'DNS:vt.alfacom.it',
|
||||
0|vigilanz | infoAccess: [Object: null prototype],
|
||||
0|vigilanz | ca: false,
|
||||
0|vigilanz | bits: 256,
|
||||
0|vigilanz | pubkey: <Buffer 04 1f 47 37 77 2f 24 97 69 bf 9b 69 2c 6f f1 94 ea 66 2a 19 e8 89 2c 5b 59 ca 44 8f 3f 04 9f c9 ff f3 47 fa 2b 72 43 d9 66 11 90 31 04 31 fb 82 22 4c ... 15 more bytes>,
|
||||
0|vigilanz | asn1Curve: 'prime256v1',
|
||||
0|vigilanz | nistCurve: 'P-256',
|
||||
0|vigilanz | valid_from: 'Oct 16 07:57:48 2025 GMT',
|
||||
0|vigilanz | valid_to: 'Jan 14 07:57:47 2026 GMT',
|
||||
0|vigilanz | fingerprint: 'D0:77:49:94:D8:06:A7:C5:EC:21:74:C6:B3:F5:42:48:96:77:46:28',
|
||||
0|vigilanz | fingerprint256: '8B:D9:F6:31:F4:0A:65:53:B7:69:ED:4C:8C:B9:D5:92:91:81:56:B2:33:B5:0E:F1:8A:E3:FC:BA:EB:12:87:D0',
|
||||
0|vigilanz | fingerprint512: '9A:1A:04:0D:E2:CE:78:E3:52:9F:6E:1C:25:95:95:FF:C9:7C:62:C6:D6:98:CA:E8:59:5C:01:0A:5F:A5:C2:43:50:77:10:2E:07:CB:7B:F3:C9:DE:39:37:A5:54:86:FD:C7:0F:02:DF:F6:E7:C8:BB:BA:BE:FB:79:AE:77:76:59',
|
||||
0|vigilanz | ext_key_usage: [Array],
|
||||
0|vigilanz | serialNumber: '068FB11FEDA957005036401D5EBC8CB8BD43',
|
||||
0|vigilanz | raw: <Buffer 30 82 03 87 30 82 03 0c a0 03 02 01 02 02 12 06 8f b1 1f ed a9 57 00 50 36 40 1d 5e bc 8c b8 bd 43 30 0a 06 08 2a 86 48 ce 3d 04 03 03 30 32 31 0b 30 ... 857 more bytes>,
|
||||
0|vigilanz | issuerCertificate: [Object]
|
||||
0|vigilanz | }
|
||||
0|vigilanz | },
|
||||
0|vigilanz | [Symbol(kMessage)]: "Hostname/IP does not match certificate's altnames: Host: localhost. is not in the cert's altnames: DNS:vt.alfacom.it"
|
||||
0|vigilanz | }
|
||||
|
||||
/root/.pm2/logs/vigilanza-turni-out.log last 50 lines:
|
||||
0|vigilanz | > rest-express@1.0.0 start
|
||||
0|vigilanz | > NODE_ENV=production node dist/index.js
|
||||
0|vigilanz |
|
||||
0|vigilanz | 12:26:08 PM [express] serving on port 5000
|
||||
0|vigilanz |
|
||||
0|vigilanz | > rest-express@1.0.0 start
|
||||
0|vigilanz | > NODE_ENV=production node dist/index.js
|
||||
0|vigilanz |
|
||||
0|vigilanz | 12:31:17 PM [express] serving on port 5000
|
||||
0|vigilanz |
|
||||
0|vigilanz | > rest-express@1.0.0 start
|
||||
0|vigilanz | > NODE_ENV=production node dist/index.js
|
||||
0|vigilanz |
|
||||
0|vigilanz | 12:35:39 PM [express] serving on port 5000
|
||||
0|vigilanz |
|
||||
0|vigilanz | > rest-express@1.0.0 start
|
||||
0|vigilanz | > NODE_ENV=production node dist/index.js
|
||||
0|vigilanz |
|
||||
0|vigilanz | 12:37:02 PM [express] serving on port 5000
|
||||
0|vigilanz | 12:37:32 PM [express] GET /api/auth/user 401 in 7ms :: {"message":"Unauthorized"}
|
||||
0|vigilanz | 12:37:33 PM [express] GET /api/login 302 in 59ms
|
||||
0|vigilanz | 12:37:38 PM [express] GET /api/login 302 in 11ms
|
||||
0|vigilanz | 12:37:43 PM [express] GET /api/auth/user 401 in 7ms :: {"message":"Unauthorized"}
|
||||
0|vigilanz | 12:37:45 PM [express] GET /api/login 302 in 9ms
|
||||
0|vigilanz | 12:38:13 PM [express] GET /api/login 302 in 35ms
|
||||
0|vigilanz | 12:38:48 PM [express] GET /api/login 302 in 31ms
|
||||
0|vigilanz |
|
||||
0|vigilanz | > rest-express@1.0.0 start
|
||||
0|vigilanz | > NODE_ENV=production node dist/index.js
|
||||
0|vigilanz |
|
||||
0|vigilanz | Usando Local Auth (vt.alfacom.it)
|
||||
0|vigilanz | ✅ [LocalAuth] Sistema autenticazione locale attivato
|
||||
0|vigilanz | Email admin: admin@vt.alfacom.it
|
||||
0|vigilanz | Password admin: admin123
|
||||
0|vigilanz | Auto-login: GET /api/auto-login-admin
|
||||
0|vigilanz | 12:46:18 PM [express] serving on port 5000
|
||||
0|vigilanz | 12:46:42 PM [express] GET /api/auth/user 401 in 12ms :: {"message":"Unauthorized"}
|
||||
0|vigilanz | 12:46:43 PM [express] GET /api/login 200 in 9ms
|
||||
0|vigilanz | 12:46:43 PM [express] GET /api/auth/user 401 in 8ms :: {"message":"Unauthorized"}
|
||||
0|vigilanz | 12:46:58 PM [express] GET /api/auto-login-admin 500 in 48ms :: {"error":"Errore server"}
|
||||
0|vigilanz |
|
||||
0|vigilanz | > rest-express@1.0.0 start
|
||||
0|vigilanz | > NODE_ENV=production node dist/index.js
|
||||
0|vigilanz |
|
||||
0|vigilanz | Usando Local Auth (vt.alfacom.it)
|
||||
0|vigilanz | ✅ [LocalAuth] Sistema autenticazione locale attivato
|
||||
0|vigilanz | Email admin: admin@vt.alfacom.it
|
||||
0|vigilanz | Password admin: admin123
|
||||
0|vigilanz | Auto-login: GET /api/auto-login-admin
|
||||
0|vigilanz | 12:52:28 PM [express] serving on port 5000
|
||||
|
||||
[root@localhost vigilanza-turni]#
|
||||
217
package-lock.json
generated
217
package-lock.json
generated
@ -41,6 +41,7 @@
|
||||
"@radix-ui/react-tooltip": "^1.2.0",
|
||||
"@tanstack/react-query": "^5.60.5",
|
||||
"@types/memoizee": "^0.4.12",
|
||||
"@types/pg": "^8.15.5",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"cmdk": "^1.1.1",
|
||||
@ -60,6 +61,7 @@
|
||||
"openid-client": "^6.8.1",
|
||||
"passport": "^0.7.0",
|
||||
"passport-local": "^1.0.0",
|
||||
"pg": "^8.16.3",
|
||||
"react": "^18.3.1",
|
||||
"react-day-picker": "^8.10.1",
|
||||
"react-dom": "^18.3.1",
|
||||
@ -1409,6 +1411,74 @@
|
||||
"@types/pg": "8.11.6"
|
||||
}
|
||||
},
|
||||
"node_modules/@neondatabase/serverless/node_modules/@types/pg": {
|
||||
"version": "8.11.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/pg/-/pg-8.11.6.tgz",
|
||||
"integrity": "sha512-/2WmmBXHLsfRqzfHW7BNZ8SbYzE8OSk7i3WjFYvfgRHj7S1xj+16Je5fUKv3lVdVzk/zn9TXOqf+avFCFIE0yQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"pg-protocol": "*",
|
||||
"pg-types": "^4.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/@neondatabase/serverless/node_modules/pg-types": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-types/-/pg-types-4.1.0.tgz",
|
||||
"integrity": "sha512-o2XFanIMy/3+mThw69O8d4n1E5zsLhdO+OPqswezu7Z5ekP4hYDqlDjlmOpYMbzY2Br0ufCwJLdDIXeNVwcWFg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"pg-int8": "1.0.1",
|
||||
"pg-numeric": "1.0.2",
|
||||
"postgres-array": "~3.0.1",
|
||||
"postgres-bytea": "~3.0.0",
|
||||
"postgres-date": "~2.1.0",
|
||||
"postgres-interval": "^3.0.0",
|
||||
"postgres-range": "^1.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/@neondatabase/serverless/node_modules/postgres-array": {
|
||||
"version": "3.0.4",
|
||||
"resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-3.0.4.tgz",
|
||||
"integrity": "sha512-nAUSGfSDGOaOAEGwqsRY27GPOea7CNipJPOA7lPbdEpx5Kg3qzdP0AaWC5MlhTWV9s4hFX39nomVZ+C4tnGOJQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@neondatabase/serverless/node_modules/postgres-bytea": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-3.0.0.tgz",
|
||||
"integrity": "sha512-CNd4jim9RFPkObHSjVHlVrxoVQXz7quwNFpz7RY1okNNme49+sVyiTvTRobiLV548Hx/hb1BG+iE7h9493WzFw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"obuf": "~1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/@neondatabase/serverless/node_modules/postgres-date": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-2.1.0.tgz",
|
||||
"integrity": "sha512-K7Juri8gtgXVcDfZttFKVmhglp7epKb1K4pgrkLxehjqkrgPhfG6OO8LHLkfaqkbpjNRnra018XwAr1yQFWGcA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@neondatabase/serverless/node_modules/postgres-interval": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-3.0.0.tgz",
|
||||
"integrity": "sha512-BSNDnbyZCXSxgA+1f5UU2GmwhoI0aU5yMxRGO8CdFEcY2BQF9xm/7MqKnYoM1nJDk8nONNWDk9WeSmePFhQdlw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/@nodelib/fs.scandir": {
|
||||
"version": "2.1.5",
|
||||
"resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz",
|
||||
@ -3553,14 +3623,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@types/pg": {
|
||||
"version": "8.11.6",
|
||||
"resolved": "https://registry.npmjs.org/@types/pg/-/pg-8.11.6.tgz",
|
||||
"integrity": "sha512-/2WmmBXHLsfRqzfHW7BNZ8SbYzE8OSk7i3WjFYvfgRHj7S1xj+16Je5fUKv3lVdVzk/zn9TXOqf+avFCFIE0yQ==",
|
||||
"version": "8.15.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/pg/-/pg-8.15.5.tgz",
|
||||
"integrity": "sha512-LF7lF6zWEKxuT3/OR8wAZGzkg4ENGXFNyiV/JeOt9z5B+0ZVwbql9McqX5c/WStFq1GaGso7H1AzP/qSzmlCKQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/node": "*",
|
||||
"pg-protocol": "*",
|
||||
"pg-types": "^4.0.1"
|
||||
"pg-types": "^2.2.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/prop-types": {
|
||||
@ -6226,22 +6296,22 @@
|
||||
"integrity": "sha512-KG8UEiEVkR3wGEb4m5yZkVCzigAD+cVEJck2CzYZO37ZGJfctvVptVO192MwrtPhzONn6go8ylnOdMhKqi4nfg=="
|
||||
},
|
||||
"node_modules/pg": {
|
||||
"version": "8.13.1",
|
||||
"resolved": "https://registry.npmjs.org/pg/-/pg-8.13.1.tgz",
|
||||
"integrity": "sha512-OUir1A0rPNZlX//c7ksiu7crsGZTKSOXJPgtNiHGIlC9H0lO+NC6ZDYksSgBYY/thSWhnSRBv8w1lieNNGATNQ==",
|
||||
"version": "8.16.3",
|
||||
"resolved": "https://registry.npmjs.org/pg/-/pg-8.16.3.tgz",
|
||||
"integrity": "sha512-enxc1h0jA/aq5oSDMvqyW3q89ra6XIIDZgCX9vkMrnz5DFTw/Ny3Li2lFQ+pt3L6MCgm/5o2o8HW9hiJji+xvw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"pg-connection-string": "^2.7.0",
|
||||
"pg-pool": "^3.7.0",
|
||||
"pg-protocol": "^1.7.0",
|
||||
"pg-types": "^2.1.0",
|
||||
"pgpass": "1.x"
|
||||
"pg-connection-string": "^2.9.1",
|
||||
"pg-pool": "^3.10.1",
|
||||
"pg-protocol": "^1.10.3",
|
||||
"pg-types": "2.2.0",
|
||||
"pgpass": "1.0.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 8.0.0"
|
||||
"node": ">= 16.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"pg-cloudflare": "^1.1.1"
|
||||
"pg-cloudflare": "^1.2.7"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"pg-native": ">=3.0.1"
|
||||
@ -6253,16 +6323,16 @@
|
||||
}
|
||||
},
|
||||
"node_modules/pg-cloudflare": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.1.1.tgz",
|
||||
"integrity": "sha512-xWPagP/4B6BgFO+EKz3JONXv3YDgvkbVrGw2mTo3D6tVDQRh1e7cqVGvyR3BE+eQgAvx1XhW/iEASj4/jCWl3Q==",
|
||||
"version": "1.2.7",
|
||||
"resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.2.7.tgz",
|
||||
"integrity": "sha512-YgCtzMH0ptvZJslLM1ffsY4EuGaU0cx4XSdXLRFae8bPP4dS5xL1tNB3k2o/N64cHJpwU7dxKli/nZ2lUa5fLg==",
|
||||
"license": "MIT",
|
||||
"optional": true
|
||||
},
|
||||
"node_modules/pg-connection-string": {
|
||||
"version": "2.7.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.7.0.tgz",
|
||||
"integrity": "sha512-PI2W9mv53rXJQEOb8xNR8lH7Hr+EKa6oJa38zsK0S/ky2er16ios1wLKhZyxzD7jUReiWokc9WK5nxSnC7W1TA==",
|
||||
"version": "2.9.1",
|
||||
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.9.1.tgz",
|
||||
"integrity": "sha512-nkc6NpDcvPVpZXxrreI/FOtX3XemeLl8E0qFr6F2Lrm/I8WOnaWNhIPK2Z7OHpw7gh5XJThi6j6ppgNoaT1w4w==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/pg-int8": {
|
||||
@ -6284,39 +6354,21 @@
|
||||
}
|
||||
},
|
||||
"node_modules/pg-pool": {
|
||||
"version": "3.7.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.7.0.tgz",
|
||||
"integrity": "sha512-ZOBQForurqh4zZWjrgSwwAtzJ7QiRX0ovFkZr2klsen3Nm0aoh33Ls0fzfv3imeH/nw/O27cjdz5kzYJfeGp/g==",
|
||||
"version": "3.10.1",
|
||||
"resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.10.1.tgz",
|
||||
"integrity": "sha512-Tu8jMlcX+9d8+QVzKIvM/uJtp07PKr82IUOYEphaWcoBhIYkoHpLXN3qO59nAI11ripznDsEzEv8nUxBVWajGg==",
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"pg": ">=8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pg-protocol": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.7.0.tgz",
|
||||
"integrity": "sha512-hTK/mE36i8fDDhgDFjy6xNOG+LCorxLG3WO17tku+ij6sVHXh1jQUJ8hYAnRhNla4QVD2H8er/FOjc/+EgC6yQ==",
|
||||
"version": "1.10.3",
|
||||
"resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.10.3.tgz",
|
||||
"integrity": "sha512-6DIBgBQaTKDJyxnXaLiLR8wBpQQcGWuAESkRBX/t6OwA8YsqP+iVSiond2EDy6Y/dsGk8rh/jtax3js5NeV7JQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/pg-types": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/pg-types/-/pg-types-4.0.2.tgz",
|
||||
"integrity": "sha512-cRL3JpS3lKMGsKaWndugWQoLOCoP+Cic8oseVcbr0qhPzYD5DWXK+RZ9LY9wxRf7RQia4SCwQlXk0q6FCPrVng==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"pg-int8": "1.0.1",
|
||||
"pg-numeric": "1.0.2",
|
||||
"postgres-array": "~3.0.1",
|
||||
"postgres-bytea": "~3.0.0",
|
||||
"postgres-date": "~2.1.0",
|
||||
"postgres-interval": "^3.0.0",
|
||||
"postgres-range": "^1.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/pg/node_modules/pg-types": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz",
|
||||
"integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==",
|
||||
@ -6332,45 +6384,6 @@
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/pg/node_modules/postgres-array": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz",
|
||||
"integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/pg/node_modules/postgres-bytea": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz",
|
||||
"integrity": "sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pg/node_modules/postgres-date": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz",
|
||||
"integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pg/node_modules/postgres-interval": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz",
|
||||
"integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"xtend": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/pgpass": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz",
|
||||
@ -6560,42 +6573,42 @@
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/postgres-array": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-3.0.2.tgz",
|
||||
"integrity": "sha512-6faShkdFugNQCLwucjPcY5ARoW1SlbnrZjmGl0IrrqewpvxvhSLHimCVzqeuULCbG0fQv7Dtk1yDbG3xv7Veog==",
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz",
|
||||
"integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/postgres-bytea": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-3.0.0.tgz",
|
||||
"integrity": "sha512-CNd4jim9RFPkObHSjVHlVrxoVQXz7quwNFpz7RY1okNNme49+sVyiTvTRobiLV548Hx/hb1BG+iE7h9493WzFw==",
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.0.tgz",
|
||||
"integrity": "sha512-xy3pmLuQqRBZBXDULy7KbaitYqLcmxigw14Q5sj8QBVLqEwXfeybIKVWiqAXTlcvdvb0+xkOtDbfQMOf4lST1w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"obuf": "~1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 6"
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/postgres-date": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-2.1.0.tgz",
|
||||
"integrity": "sha512-K7Juri8gtgXVcDfZttFKVmhglp7epKb1K4pgrkLxehjqkrgPhfG6OO8LHLkfaqkbpjNRnra018XwAr1yQFWGcA==",
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz",
|
||||
"integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/postgres-interval": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-3.0.0.tgz",
|
||||
"integrity": "sha512-BSNDnbyZCXSxgA+1f5UU2GmwhoI0aU5yMxRGO8CdFEcY2BQF9xm/7MqKnYoM1nJDk8nONNWDk9WeSmePFhQdlw==",
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz",
|
||||
"integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"xtend": "^4.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/postgres-range": {
|
||||
|
||||
@ -43,6 +43,7 @@
|
||||
"@radix-ui/react-tooltip": "^1.2.0",
|
||||
"@tanstack/react-query": "^5.60.5",
|
||||
"@types/memoizee": "^0.4.12",
|
||||
"@types/pg": "^8.15.5",
|
||||
"class-variance-authority": "^0.7.1",
|
||||
"clsx": "^2.1.1",
|
||||
"cmdk": "^1.1.1",
|
||||
@ -62,6 +63,7 @@
|
||||
"openid-client": "^6.8.1",
|
||||
"passport": "^0.7.0",
|
||||
"passport-local": "^1.0.0",
|
||||
"pg": "^8.16.3",
|
||||
"react": "^18.3.1",
|
||||
"react-day-picker": "^8.10.1",
|
||||
"react-dom": "^18.3.1",
|
||||
|
||||
30
server/db.ts
30
server/db.ts
@ -1,16 +1,34 @@
|
||||
// Integration: javascript_database blueprint
|
||||
import { Pool, neonConfig } from '@neondatabase/serverless';
|
||||
import { drizzle } from 'drizzle-orm/neon-serverless';
|
||||
import { Pool as NeonPool, neonConfig } from '@neondatabase/serverless';
|
||||
import { drizzle as drizzleNeon } from 'drizzle-orm/neon-serverless';
|
||||
import { drizzle as drizzlePg } from 'drizzle-orm/node-postgres';
|
||||
import { Pool as PgPool } from 'pg';
|
||||
import ws from "ws";
|
||||
import * as schema from "@shared/schema";
|
||||
|
||||
neonConfig.webSocketConstructor = ws;
|
||||
|
||||
if (!process.env.DATABASE_URL) {
|
||||
throw new Error(
|
||||
"DATABASE_URL must be set. Did you forget to provision a database?",
|
||||
);
|
||||
}
|
||||
|
||||
export const pool = new Pool({ connectionString: process.env.DATABASE_URL });
|
||||
export const db = drizzle({ client: pool, schema });
|
||||
// Usa driver standard PostgreSQL per server locale, Neon per cloud
|
||||
const isLocalDb = process.env.DATABASE_URL.includes('localhost') ||
|
||||
process.env.DATABASE_URL.includes('127.0.0.1') ||
|
||||
process.env.DOMAIN === 'vt.alfacom.it';
|
||||
|
||||
let pool: NeonPool | PgPool;
|
||||
let db: any; // Type unification per drizzle
|
||||
|
||||
if (isLocalDb) {
|
||||
console.log("🗄️ Usando driver PostgreSQL standard (locale)");
|
||||
pool = new PgPool({ connectionString: process.env.DATABASE_URL });
|
||||
db = drizzlePg(pool, { schema });
|
||||
} else {
|
||||
console.log("🗄️ Usando driver Neon serverless (cloud)");
|
||||
neonConfig.webSocketConstructor = ws;
|
||||
pool = new NeonPool({ connectionString: process.env.DATABASE_URL });
|
||||
db = drizzleNeon({ client: pool, schema });
|
||||
}
|
||||
|
||||
export { pool, db };
|
||||
|
||||
Loading…
Reference in New Issue
Block a user