Guardar en db

This commit is contained in:
2026-08-05 09:26:53 -05:00
parent b6f4aaa7b6
commit 519cd619ec
10 changed files with 1199 additions and 98 deletions
+8
View File
@@ -0,0 +1,8 @@
node_modules
package-lock.json
.git
.gitignore
data
*.db
Dockerfile
docker-compose.yml
+10 -2
View File
@@ -1,7 +1,15 @@
FROM nginx:alpine FROM nginx:alpine
# Copiar el frontend a la carpeta de Nginx RUN apk add --no-cache nodejs npm python3 make g++
WORKDIR /app/backend
COPY backend/package*.json ./
RUN npm install
COPY backend .
COPY frontend /usr/share/nginx/html COPY frontend /usr/share/nginx/html
COPY nginx.conf /etc/nginx/nginx.conf
# Exponer el puerto 80 del contenedor
EXPOSE 80 EXPOSE 80
CMD node /app/backend/server.js & nginx -g 'daemon off;'
+915
View File
@@ -0,0 +1,915 @@
{
"name": "backend",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "backend",
"version": "1.0.0",
"license": "ISC",
"dependencies": {
"better-sqlite3": "^13.0.3",
"cors": "^2.8.6",
"express": "^5.2.1"
}
},
"node_modules/accepts": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/accepts/-/accepts-2.0.0.tgz",
"integrity": "sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==",
"license": "MIT",
"dependencies": {
"mime-types": "^3.0.0",
"negotiator": "^1.0.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/better-sqlite3": {
"version": "13.0.3",
"resolved": "https://registry.npmjs.org/better-sqlite3/-/better-sqlite3-13.0.3.tgz",
"integrity": "sha512-RbOBxmLBG8uvFUc15X9+9SFemKcQ0WBuISBVkpuiaUB2qblC8UWlHEjdWVoZ8AdhSwmoEgsiXKfopX0CQxaACQ==",
"license": "MIT",
"dependencies": {
"node-addon-api": "^8.0.0"
},
"engines": {
"node": ">=22"
}
},
"node_modules/body-parser": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-2.3.0.tgz",
"integrity": "sha512-2cGmJupaNgg+QUwVLAucDuWuoMZ6EX9iHDRswZ5lsNYEmwPaRknMPCLZz07yTzVq/83p4o/wzbDZbBrTvGGTIw==",
"license": "MIT",
"dependencies": {
"bytes": "^3.1.2",
"content-type": "^2.0.0",
"debug": "^4.4.3",
"http-errors": "^2.0.1",
"iconv-lite": "^0.7.2",
"on-finished": "^2.4.1",
"qs": "^6.15.2",
"raw-body": "^3.0.2",
"type-is": "^2.1.0"
},
"engines": {
"node": ">=18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/body-parser/node_modules/content-type": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-2.0.0.tgz",
"integrity": "sha512-j/O/d7GcZCyNl7/hwZAb606rzqkyvaDctLmckbxLzHvFBzTJHuGEdodATcP3yIRoDrLHkIATJuvzbFlp/ki2cQ==",
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/bytes": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/call-bind-apply-helpers": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/call-bound": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
"integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"get-intrinsic": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/content-disposition": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-1.1.0.tgz",
"integrity": "sha512-5jRCH9Z/+DRP7rkvY83B+yGIGX96OYdJmzngqnw2SBSxqCFPd0w2km3s5iawpGX8krnwSGmF0FW5Nhr0Hfai3g==",
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/content-type": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie": {
"version": "0.7.2",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/cookie-signature": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.2.2.tgz",
"integrity": "sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==",
"license": "MIT",
"engines": {
"node": ">=6.6.0"
}
},
"node_modules/cors": {
"version": "2.8.6",
"resolved": "https://registry.npmjs.org/cors/-/cors-2.8.6.tgz",
"integrity": "sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==",
"license": "MIT",
"dependencies": {
"object-assign": "^4",
"vary": "^1"
},
"engines": {
"node": ">= 0.10"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/debug": {
"version": "4.4.3",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz",
"integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==",
"license": "MIT",
"dependencies": {
"ms": "^2.1.3"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.1",
"es-errors": "^1.3.0",
"gopd": "^1.2.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/ee-first": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
"license": "MIT"
},
"node_modules/encodeurl": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz",
"integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/es-define-property": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-errors": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-object-atoms": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz",
"integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/escape-html": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
"license": "MIT"
},
"node_modules/etag": {
"version": "1.8.1",
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/express": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/express/-/express-5.2.1.tgz",
"integrity": "sha512-hIS4idWWai69NezIdRt2xFVofaF4j+6INOpJlVOLDO8zXGpUVEVzIYk12UUi2JzjEzWL3IOAxcTubgz9Po0yXw==",
"license": "MIT",
"dependencies": {
"accepts": "^2.0.0",
"body-parser": "^2.2.1",
"content-disposition": "^1.0.0",
"content-type": "^1.0.5",
"cookie": "^0.7.1",
"cookie-signature": "^1.2.1",
"debug": "^4.4.0",
"depd": "^2.0.0",
"encodeurl": "^2.0.0",
"escape-html": "^1.0.3",
"etag": "^1.8.1",
"finalhandler": "^2.1.0",
"fresh": "^2.0.0",
"http-errors": "^2.0.0",
"merge-descriptors": "^2.0.0",
"mime-types": "^3.0.0",
"on-finished": "^2.4.1",
"once": "^1.4.0",
"parseurl": "^1.3.3",
"proxy-addr": "^2.0.7",
"qs": "^6.14.0",
"range-parser": "^1.2.1",
"router": "^2.2.0",
"send": "^1.1.0",
"serve-static": "^2.2.0",
"statuses": "^2.0.1",
"type-is": "^2.0.1",
"vary": "^1.1.2"
},
"engines": {
"node": ">= 18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/finalhandler": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-2.1.1.tgz",
"integrity": "sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==",
"license": "MIT",
"dependencies": {
"debug": "^4.4.0",
"encodeurl": "^2.0.0",
"escape-html": "^1.0.3",
"on-finished": "^2.4.1",
"parseurl": "^1.3.3",
"statuses": "^2.0.1"
},
"engines": {
"node": ">= 18.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/fresh": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/fresh/-/fresh-2.0.0.tgz",
"integrity": "sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-intrinsic": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"es-define-property": "^1.0.1",
"es-errors": "^1.3.0",
"es-object-atoms": "^1.1.1",
"function-bind": "^1.1.2",
"get-proto": "^1.0.1",
"gopd": "^1.2.0",
"has-symbols": "^1.1.0",
"hasown": "^2.0.2",
"math-intrinsics": "^1.1.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
"license": "MIT",
"dependencies": {
"dunder-proto": "^1.0.1",
"es-object-atoms": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/gopd": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-symbols": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/hasown": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz",
"integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==",
"license": "MIT",
"dependencies": {
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/http-errors": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",
"integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==",
"license": "MIT",
"dependencies": {
"depd": "~2.0.0",
"inherits": "~2.0.4",
"setprototypeof": "~1.2.0",
"statuses": "~2.0.2",
"toidentifier": "~1.0.1"
},
"engines": {
"node": ">= 0.8"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/iconv-lite": {
"version": "0.7.3",
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.3.tgz",
"integrity": "sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==",
"license": "MIT",
"dependencies": {
"safer-buffer": ">= 2.1.2 < 3.0.0"
},
"engines": {
"node": ">=0.10.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"license": "ISC"
},
"node_modules/ipaddr.js": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
"license": "MIT",
"engines": {
"node": ">= 0.10"
}
},
"node_modules/is-promise": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz",
"integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==",
"license": "MIT"
},
"node_modules/math-intrinsics": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/media-typer": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-1.1.1.tgz",
"integrity": "sha512-yz3xRaG20c6/BOzvYoDaGtPmGscs7YivItZEEqe6GbwNfHuxu9YNmvnEkMzKldAGY4/80pRcQRZSEnhquk9XuQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/merge-descriptors": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz",
"integrity": "sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==",
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/mime-db": {
"version": "1.54.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz",
"integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.2.tgz",
"integrity": "sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==",
"license": "MIT",
"dependencies": {
"mime-db": "^1.54.0"
},
"engines": {
"node": ">=18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
},
"node_modules/negotiator": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-1.0.0.tgz",
"integrity": "sha512-8Ofs/AUQh8MaEcrlq5xOX0CQ9ypTF5dl78mjlMNfOK08fzpgTHQRQPBxcPlEtIw0yRpws+Zo/3r+5WRby7u3Gg==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/node-addon-api": {
"version": "8.9.1",
"resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-8.9.1.tgz",
"integrity": "sha512-4eUQWVPCUUUiBjLnHS3cXWeC6ryoPUc0U3rP7IuzapoGbzMqd/r6KKO0clr0b+snQhsrueFEhCZDdK+LK7hxKg==",
"license": "MIT",
"engines": {
"node": "^18 || ^20 || >= 21"
}
},
"node_modules/object-assign": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/object-inspect": {
"version": "1.13.4",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
"integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/on-finished": {
"version": "2.4.1",
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz",
"integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==",
"license": "MIT",
"dependencies": {
"ee-first": "1.1.1"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
"license": "ISC",
"dependencies": {
"wrappy": "1"
}
},
"node_modules/parseurl": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/path-to-regexp": {
"version": "8.4.2",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.4.2.tgz",
"integrity": "sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==",
"license": "MIT",
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/proxy-addr": {
"version": "2.0.7",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz",
"integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==",
"license": "MIT",
"dependencies": {
"forwarded": "0.2.0",
"ipaddr.js": "1.9.1"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/qs": {
"version": "6.15.3",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.15.3.tgz",
"integrity": "sha512-O9gl3zCl5h5blw1KGUzQKhA5oUXSl8rwUIM5o0S3nCXMliSvy5Dzx7/DJcI+SwgICv+IneSZwhBh1oSyEHA71A==",
"license": "BSD-3-Clause",
"dependencies": {
"es-define-property": "^1.0.1",
"side-channel": "^1.1.1"
},
"engines": {
"node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/range-parser": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.3.0.tgz",
"integrity": "sha512-hek2mFQpPuI4E1BBKrSto+BU3e3x4xuarsbiwr3+lf7p44juvFMV0XFWQAP3xUyqXA4RrXLIoaSUGbSt056ZMw==",
"license": "MIT",
"engines": {
"node": ">= 0.6"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/raw-body": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-3.0.2.tgz",
"integrity": "sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==",
"license": "MIT",
"dependencies": {
"bytes": "~3.1.2",
"http-errors": "~2.0.1",
"iconv-lite": "~0.7.0",
"unpipe": "~1.0.0"
},
"engines": {
"node": ">= 0.10"
}
},
"node_modules/router": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz",
"integrity": "sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==",
"license": "MIT",
"dependencies": {
"debug": "^4.4.0",
"depd": "^2.0.0",
"is-promise": "^4.0.0",
"parseurl": "^1.3.3",
"path-to-regexp": "^8.0.0"
},
"engines": {
"node": ">= 18"
}
},
"node_modules/safer-buffer": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
"license": "MIT"
},
"node_modules/send": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/send/-/send-1.2.1.tgz",
"integrity": "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==",
"license": "MIT",
"dependencies": {
"debug": "^4.4.3",
"encodeurl": "^2.0.0",
"escape-html": "^1.0.3",
"etag": "^1.8.1",
"fresh": "^2.0.0",
"http-errors": "^2.0.1",
"mime-types": "^3.0.2",
"ms": "^2.1.3",
"on-finished": "^2.4.1",
"range-parser": "^1.2.1",
"statuses": "^2.0.2"
},
"engines": {
"node": ">= 18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/serve-static": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-2.2.1.tgz",
"integrity": "sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==",
"license": "MIT",
"dependencies": {
"encodeurl": "^2.0.0",
"escape-html": "^1.0.3",
"parseurl": "^1.3.3",
"send": "^1.2.0"
},
"engines": {
"node": ">= 18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/setprototypeof": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
"license": "ISC"
},
"node_modules/side-channel": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz",
"integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.4",
"side-channel-list": "^1.0.1",
"side-channel-map": "^1.0.1",
"side-channel-weakmap": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-list": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz",
"integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.4"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-map": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-weakmap": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3",
"side-channel-map": "^1.0.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/statuses": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
"integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/toidentifier": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
"license": "MIT",
"engines": {
"node": ">=0.6"
}
},
"node_modules/type-is": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-2.1.0.tgz",
"integrity": "sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==",
"license": "MIT",
"dependencies": {
"content-type": "^2.0.0",
"media-typer": "^1.1.0",
"mime-types": "^3.0.0"
},
"engines": {
"node": ">= 18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/type-is/node_modules/content-type": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/content-type/-/content-type-2.0.0.tgz",
"integrity": "sha512-j/O/d7GcZCyNl7/hwZAb606rzqkyvaDctLmckbxLzHvFBzTJHuGEdodATcP3yIRoDrLHkIATJuvzbFlp/ki2cQ==",
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/express"
}
},
"node_modules/unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/vary": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
"license": "ISC"
}
}
}
+13
View File
@@ -0,0 +1,13 @@
{
"name": "backend",
"version": "1.0.0",
"description": "Backend API para Sistema de Nóminas",
"main": "server.js",
"scripts": {
"start": "node server.js"
},
"dependencies": {
"better-sqlite3": "^13.0.3",
"express": "^5.2.1"
}
}
+130
View File
@@ -0,0 +1,130 @@
const express = require('express');
const Database = require('better-sqlite3');
const path = require('path');
const app = express();
const PORT = 3000;
const DATA_DIR = '/app/data';
app.use(express.json());
const dbTrabajadores = new Database(path.join(DATA_DIR, 'trabajadores.db'));
const dbDatos = new Database(path.join(DATA_DIR, 'datos.db'));
const dbHistorial = new Database(path.join(DATA_DIR, 'historial.db'));
// ==================== TRABAJADORES ====================
app.get('/api/trabajadores', (req, res) => {
try {
const rows = dbTrabajadores.prepare('SELECT * FROM trabajadores ORDER BY nombre').all();
res.json(rows);
} catch (err) {
res.status(500).json({ error: err.message });
}
});
app.post('/api/trabajadores', (req, res) => {
try {
const { id, nombre, apellidos, puesto, salario_mensual, fecha_ingreso, seguridad_social, activo } = req.body;
dbTrabajadores.prepare(
'INSERT INTO trabajadores (id, nombre, apellidos, puesto, salario_mensual, fecha_ingreso, seguridad_social, activo) VALUES (?, ?, ?, ?, ?, ?, ?, ?)'
).run(id, nombre, apellidos, puesto, salario_mensual, fecha_ingreso, seguridad_social, activo);
res.json({ message: 'Trabajador creado' });
} catch (err) {
res.status(500).json({ error: err.message });
}
});
app.put('/api/trabajadores/:id', (req, res) => {
try {
const idOriginal = req.params.id;
const { id, nombre, apellidos, puesto, salario_mensual, fecha_ingreso, seguridad_social, activo } = req.body;
dbTrabajadores.prepare(
'UPDATE trabajadores SET id = ?, nombre = ?, apellidos = ?, puesto = ?, salario_mensual = ?, fecha_ingreso = ?, seguridad_social = ?, activo = ? WHERE id = ?'
).run(id, nombre, apellidos, puesto, salario_mensual, fecha_ingreso, seguridad_social, activo, idOriginal);
res.json({ message: 'Trabajador actualizado' });
} catch (err) {
res.status(500).json({ error: err.message });
}
});
app.delete('/api/trabajadores/:id', (req, res) => {
try {
dbTrabajadores.prepare('DELETE FROM trabajadores WHERE id = ?').run(req.params.id);
res.json({ message: 'Trabajador eliminado' });
} catch (err) {
res.status(500).json({ error: err.message });
}
});
// ==================== CONFIGURACIONES ====================
app.get('/api/configuracion', (req, res) => {
try {
const row = dbDatos.prepare('SELECT * FROM parametros_nomina ORDER BY id DESC LIMIT 1').get();
res.json(row || {});
} catch (err) {
res.status(500).json({ error: err.message });
}
});
app.post('/api/configuracion', (req, res) => {
try {
const {
nombre_empresa,
salario_minimo,
auxilio_transporte,
horas_semanales,
horas_mensuales,
dia_inicio_mes,
dia_fin_mes,
tiempo_almuerzo,
valor_hora_ordinaria,
valor_hora_extra,
valor_hora_extra_nocturna
} = req.body;
const count = dbDatos.prepare('SELECT COUNT(*) as total FROM parametros_nomina').get().total;
if (count === 0) {
dbDatos.prepare(
'INSERT INTO parametros_nomina (nombre_empresa, salario_minimo, auxilio_transporte, horas_semanales, horas_mensuales, dia_inicio_mes, dia_fin_mes, tiempo_almuerzo, valor_hora_ordinaria, valor_hora_extra, valor_hora_extra_nocturna) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)'
).run(nombre_empresa, salario_minimo, auxilio_transporte, horas_semanales, horas_mensuales, dia_inicio_mes, dia_fin_mes, tiempo_almuerzo, valor_hora_ordinaria, valor_hora_extra, valor_hora_extra_nocturna);
} else {
dbDatos.prepare(
'UPDATE parametros_nomina SET nombre_empresa = ?, salario_minimo = ?, auxilio_transporte = ?, horas_semanales = ?, horas_mensuales = ?, dia_inicio_mes = ?, dia_fin_mes = ?, tiempo_almuerzo = ?, valor_hora_ordinaria = ?, valor_hora_extra = ?, valor_hora_extra_nocturna = ?'
).run(nombre_empresa, salario_minimo, auxilio_transporte, horas_semanales, horas_mensuales, dia_inicio_mes, dia_fin_mes, tiempo_almuerzo, valor_hora_ordinaria, valor_hora_extra, valor_hora_extra_nocturna);
}
res.json({ message: 'Configuración guardada' });
} catch (err) {
res.status(500).json({ error: err.message });
}
});
// ==================== HISTORIAL ====================
app.get('/api/historial', (req, res) => {
try {
const rows = dbHistorial.prepare('SELECT * FROM registros_historial ORDER BY fecha DESC').all();
res.json(rows);
} catch (err) {
res.status(500).json({ error: err.message });
}
});
app.post('/api/historial', (req, res) => {
try {
const { fecha, trabajador, inicio_dia, fin_dia, tiempo_almuerzo } = req.body;
dbHistorial.prepare(
'INSERT INTO registros_historial (fecha, trabajador, inicio_dia, fin_dia, tiempo_almuerzo) VALUES (?, ?, ?, ?, ?)'
).run(fecha, trabajador, inicio_dia, fin_dia, tiempo_almuerzo);
res.json({ message: 'Registro guardado' });
} catch (err) {
res.status(500).json({ error: err.message });
}
});
app.listen(PORT, () => {
console.log(`Backend corriendo en http://localhost:${PORT}`);
});
+2
View File
@@ -4,4 +4,6 @@ services:
container_name: nominas-app container_name: nominas-app
ports: ports:
- "9005:80" - "9005:80"
volumes:
- ./data:/app/data
restart: unless-stopped restart: unless-stopped
+1 -1
View File
@@ -305,6 +305,7 @@ body {
.form-group input[type="number"] { .form-group input[type="number"] {
-moz-appearance: textfield; -moz-appearance: textfield;
appearance: textfield;
} }
.form-group input, .form-group input,
@@ -354,7 +355,6 @@ input[readonly] {
color: #7f8c8d; color: #7f8c8d;
} }
.form-group input[readonly] + label,
.form-group label.readonly-label { .form-group label.readonly-label {
color: #95a5a6; color: #95a5a6;
cursor: not-allowed; cursor: not-allowed;
+6 -22
View File
@@ -8,17 +8,12 @@
</head> </head>
<body> <body>
<div class="app-layout"> <div class="app-layout">
<!-- // SIDEBAR (MENU LATERAL) -->
<aside class="sidebar"> <aside class="sidebar">
<div class="logo"> <div class="logo">
<h2>Sistema de Nóminas</h2> <h2>Sistema de Nóminas</h2>
</div> </div>
<nav class="menu"> <nav class="menu">
<button class="menu-btn active" data-section="seguimiento"> <button class="menu-btn active" data-section="trabajadores">
<span class="icon"></span>
Seguimiento
</button>
<button class="menu-btn" data-section="trabajadores">
<span class="icon">👷</span> <span class="icon">👷</span>
Trabajadores Trabajadores
</button> </button>
@@ -46,20 +41,13 @@
</button> </button>
</div> </div>
</aside> </aside>
<!-- // CIERRE DE SIDEBAR (MENU LATERAL) -->
<!-- // INICIO DEL MAIN (CONTENIDO) -->
<main class="main-content"> <main class="main-content">
<!--N INICIO DE LOS TRABAJADORES -->
<header class="top-bar"> <header class="top-bar">
<h1 id="section-title">Trabajadores</h1> <h1 id="section-title">Trabajadores</h1>
</header> </header>
<section id="seguimiento" class="section active"> <section id="trabajadores" class="section active">
<p>Seguimiento de nóminas y empleados.</p>
</section>
<section id="trabajadores" class="section">
<div class="section-actions"> <div class="section-actions">
<button id="btn-nuevo-trabajador" class="btn btn-primary">+ Nuevo trabajador</button> <button id="btn-nuevo-trabajador" class="btn btn-primary">+ Nuevo trabajador</button>
</div> </div>
@@ -142,7 +130,6 @@
</div> </div>
</div> </div>
</section> </section>
<!--N CIERRE DE TRABAJADORES -->
<section id="nominas" class="section"> <section id="nominas" class="section">
<p>Gestión de nóminas.</p> <p>Gestión de nóminas.</p>
@@ -152,7 +139,6 @@
<p>Gestión de liquidaciones.</p> <p>Gestión de liquidaciones.</p>
</section> </section>
<!--N INICIO DE CONFIGURACIONES -->
<section id="configuraciones" class="section"> <section id="configuraciones" class="section">
<div class="config-card"> <div class="config-card">
<div class="config-header"> <div class="config-header">
@@ -213,17 +199,15 @@
</form> </form>
</div> </div>
</section> </section>
<!--N FIN DE CONFIGURACIONES -->
<section id="licencia" class="section">
<p>Información de licencia.</p>
</section>
<section id="historial" class="section"> <section id="historial" class="section">
<p>Historial de cambios y movimientos.</p> <p>Historial de cambios y movimientos.</p>
</section> </section>
<section id="licencia" class="section">
<p>Información de licencia.</p>
</section>
</main> </main>
<!--// FIN DEL MAIN (CONTENIDO) -->
</div> </div>
<script src="js/app.js"></script> <script src="js/app.js"></script>
+82 -68
View File
@@ -1,17 +1,15 @@
//// PASAR DE UN BOTON A OTRO BOTON
document.addEventListener('DOMContentLoaded', function () { document.addEventListener('DOMContentLoaded', function () {
const menuButtons = document.querySelectorAll('.menu-btn'); const menuButtons = document.querySelectorAll('.menu-btn');
const sections = document.querySelectorAll('.section'); const sections = document.querySelectorAll('.section');
const sectionTitle = document.getElementById('section-title'); const sectionTitle = document.getElementById('section-title');
const titles = { const titles = {
seguimiento: 'Seguimiento',
trabajadores: 'Trabajadores', trabajadores: 'Trabajadores',
nominas: 'Nóminas', nominas: 'Nóminas',
liquidaciones: 'Liquidaciones', liquidaciones: 'Liquidaciones',
configuraciones: 'Configuraciones', configuraciones: 'Configuraciones',
licencia: 'Licencia', historial: 'Historial',
historial: 'Historial' licencia: 'Licencia'
}; };
menuButtons.forEach(button => { menuButtons.forEach(button => {
@@ -28,8 +26,7 @@ document.addEventListener('DOMContentLoaded', function () {
}); });
}); });
//// MODULO DE TRABAJADORES let trabajadores = [];
const trabajadores = [];
let editandoId = null; let editandoId = null;
const modalTrabajador = document.getElementById('modal-trabajador'); const modalTrabajador = document.getElementById('modal-trabajador');
@@ -42,27 +39,7 @@ document.addEventListener('DOMContentLoaded', function () {
const chkSmv = document.getElementById('chk-smv'); const chkSmv = document.getElementById('chk-smv');
const inputSalario = document.getElementById('trabajador-salario'); const inputSalario = document.getElementById('trabajador-salario');
let configuracionGlobal = { let configuracionGlobal = {};
id: null,
nombre_empresa: '',
salario_minimo: '',
auxilio_transporte: '',
horas_semanales: '',
horas_mensuales: '',
dia_inicio_mes: '',
dia_fin_mes: '',
tiempo_almuerzo: '',
valor_hora_ordinaria: '',
valor_hora_extra: '',
valor_hora_extra_nocturna: ''
};
function formatearPesos(valor) {
const partes = Number(valor).toFixed(2).split('.');
const entera = partes[0].replace(/\B(?=(\d{3})+(?!\d))/g, '.');
const decimal = ',' + partes[1];
return entera + decimal;
}
function formatearPesosSinDecimales(valor) { function formatearPesosSinDecimales(valor) {
const numero = Number(valor); const numero = Number(valor);
@@ -100,7 +77,7 @@ document.addEventListener('DOMContentLoaded', function () {
<td>${t.id}</td> <td>${t.id}</td>
<td>${t.nombre} ${t.apellidos}</td> <td>${t.nombre} ${t.apellidos}</td>
<td>${t.puesto || '-'}</td> <td>${t.puesto || '-'}</td>
<td>${t.salario_mensual ? formatearPesos(Number(t.salario_mensual)) : '-'}</td> <td>${t.salario_mensual ? formatearPesosSinDecimales(Number(t.salario_mensual)) : '-'}</td>
<td> <td>
<span class="badge ${t.activo == 1 ? 'badge-active' : 'badge-inactive'}"> <span class="badge ${t.activo == 1 ? 'badge-active' : 'badge-inactive'}">
${t.activo == 1 ? 'Activo' : 'Inactivo'} ${t.activo == 1 ? 'Activo' : 'Inactivo'}
@@ -119,7 +96,17 @@ document.addEventListener('DOMContentLoaded', function () {
}); });
} }
function guardarTrabajador(e) { async function cargarTrabajadores() {
try {
const resp = await fetch(`${API_URL}/trabajadores`);
trabajadores = await resp.json();
renderTabla();
} catch (err) {
console.error('Error cargando trabajadores:', err);
}
}
async function guardarTrabajador(e) {
e.preventDefault(); e.preventDefault();
const datos = { const datos = {
@@ -133,22 +120,37 @@ document.addEventListener('DOMContentLoaded', function () {
activo: document.getElementById('trabajador-activo').value activo: document.getElementById('trabajador-activo').value
}; };
try {
if (editandoId !== null) { if (editandoId !== null) {
const index = trabajadores.findIndex(t => t.id === editandoId); await fetch(`${API_URL}/trabajadores/${editandoId}`, {
if (index !== -1) { method: 'PUT',
trabajadores[index] = { ...datos, idOriginal: editandoId }; headers: { 'Content-Type': 'application/json' },
} body: JSON.stringify(datos)
});
} else { } else {
const existe = trabajadores.some(t => t.id === datos.id); await fetch(`${API_URL}/trabajadores`, {
if (existe) { method: 'POST',
alert('Ya existe un trabajador con ese documento de identidad.'); headers: { 'Content-Type': 'application/json' },
return; body: JSON.stringify(datos)
});
}
cerrarModal();
await cargarTrabajadores();
} catch (err) {
alert('Error al guardar trabajador');
console.error(err);
} }
trabajadores.push(datos);
} }
cerrarModal(); async function eliminarTrabajador(id) {
renderTabla(); if (!confirm('¿Estás seguro de eliminar este trabajador?')) return;
try {
await fetch(`${API_URL}/trabajadores/${id}`, { method: 'DELETE' });
await cargarTrabajadores();
} catch (err) {
alert('Error al eliminar trabajador');
console.error(err);
}
} }
function cargarEdicion(id) { function cargarEdicion(id) {
@@ -166,16 +168,10 @@ document.addEventListener('DOMContentLoaded', function () {
document.getElementById('trabajador-seguridad').value = t.seguridad_social; document.getElementById('trabajador-seguridad').value = t.seguridad_social;
document.getElementById('trabajador-activo').value = t.activo; document.getElementById('trabajador-activo').value = t.activo;
abrirModal('editar'); if (chkSmv) chkSmv.checked = false;
} if (inputSalario) inputSalario.disabled = false;
function eliminarTrabajador(id) { abrirModal('editar');
if (!confirm('¿Estás seguro de eliminar este trabajador?')) return;
const index = trabajadores.findIndex(t => t.id === id);
if (index !== -1) {
trabajadores.splice(index, 1);
renderTabla();
}
} }
btnNuevoTrabajador.addEventListener('click', () => abrirModal('nuevo')); btnNuevoTrabajador.addEventListener('click', () => abrirModal('nuevo'));
@@ -200,11 +196,10 @@ document.addEventListener('DOMContentLoaded', function () {
}); });
} }
renderTabla(); cargarTrabajadores();
// --- Módulo de Configuraciones --- // --- Módulo de Configuraciones ---
const formConfiguraciones = document.getElementById('form-configuraciones'); const formConfiguraciones = document.getElementById('form-configuraciones');
const btnGuardarConfiguraciones = document.getElementById('btn-guardar-configuraciones');
const cfgMensaje = document.getElementById('cfg-mensaje'); const cfgMensaje = document.getElementById('cfg-mensaje');
const camposPesosSinDecimales = [ const camposPesosSinDecimales = [
@@ -215,9 +210,7 @@ document.addEventListener('DOMContentLoaded', function () {
const inputHorasSemanales = document.getElementById('cfg-horas-semanales'); const inputHorasSemanales = document.getElementById('cfg-horas-semanales');
const inputHorasMensuales = document.getElementById('cfg-horas-mensuales'); const inputHorasMensuales = document.getElementById('cfg-horas-mensuales');
const inputDiaInicio = document.getElementById('cfg-dia-inicio');
const inputDiaFin = document.getElementById('cfg-dia-fin');
const inputTiempoAlmuerzo = document.getElementById('cfg-tiempo-almuerzo');
const inputHoraOrdinaria = document.getElementById('cfg-hora-ordinaria'); const inputHoraOrdinaria = document.getElementById('cfg-hora-ordinaria');
const inputHoraExtra = document.getElementById('cfg-hora-extra'); const inputHoraExtra = document.getElementById('cfg-hora-extra');
const inputHoraExtraNocturna = document.getElementById('cfg-hora-extra-nocturna'); const inputHoraExtraNocturna = document.getElementById('cfg-hora-extra-nocturna');
@@ -245,24 +238,36 @@ document.addEventListener('DOMContentLoaded', function () {
} }
} }
async function cargarConfiguracion() {
try {
const resp = await fetch(`${API_URL}/configuracion`);
const data = await resp.json();
if (data && Object.keys(data).length > 0) {
configuracionGlobal = data;
cargarConfiguracionEnFormulario();
}
} catch (err) {
console.error('Error cargando configuración:', err);
}
}
function cargarConfiguracionEnFormulario() { function cargarConfiguracionEnFormulario() {
document.getElementById('cfg-nombre-empresa').value = configuracionGlobal.nombre_empresa; document.getElementById('cfg-nombre-empresa').value = configuracionGlobal.nombre_empresa || '';
document.getElementById('cfg-salario-minimo').value = configuracionGlobal.salario_minimo ? formatearPesosSinDecimales(configuracionGlobal.salario_minimo) : ''; document.getElementById('cfg-salario-minimo').value = configuracionGlobal.salario_minimo ? formatearPesosSinDecimales(configuracionGlobal.salario_minimo) : '';
document.getElementById('cfg-auxilio-transporte').value = configuracionGlobal.auxilio_transporte ? formatearPesosSinDecimales(configuracionGlobal.auxilio_transporte) : ''; document.getElementById('cfg-auxilio-transporte').value = configuracionGlobal.auxilio_transporte ? formatearPesosSinDecimales(configuracionGlobal.auxilio_transporte) : '';
document.getElementById('cfg-horas-semanales').value = configuracionGlobal.horas_semanales; document.getElementById('cfg-horas-semanales').value = configuracionGlobal.horas_semanales || '';
document.getElementById('cfg-horas-mensuales').value = configuracionGlobal.horas_mensuales; document.getElementById('cfg-horas-mensuales').value = configuracionGlobal.horas_mensuales || '';
document.getElementById('cfg-dia-inicio').value = configuracionGlobal.dia_inicio_mes; document.getElementById('cfg-dia-inicio').value = configuracionGlobal.dia_inicio_mes || '';
document.getElementById('cfg-dia-fin').value = configuracionGlobal.dia_fin_mes; document.getElementById('cfg-dia-fin').value = configuracionGlobal.dia_fin_mes || '';
document.getElementById('cfg-tiempo-almuerzo').value = configuracionGlobal.tiempo_almuerzo; document.getElementById('cfg-tiempo-almuerzo').value = configuracionGlobal.tiempo_almuerzo || '';
document.getElementById('cfg-hora-ordinaria').value = configuracionGlobal.valor_hora_ordinaria ? formatearPesosSinDecimales(configuracionGlobal.valor_hora_ordinaria) : ''; document.getElementById('cfg-hora-ordinaria').value = configuracionGlobal.valor_hora_ordinaria ? formatearPesosSinDecimales(configuracionGlobal.valor_hora_ordinaria) : '';
calcularCamposDependientes(); calcularCamposDependientes();
} }
function guardarConfiguracion(e) { async function guardarConfiguracion(e) {
e.preventDefault(); e.preventDefault();
configuracionGlobal = { const datos = {
id: configuracionGlobal.id || 1,
nombre_empresa: document.getElementById('cfg-nombre-empresa').value.trim(), nombre_empresa: document.getElementById('cfg-nombre-empresa').value.trim(),
salario_minimo: limpiarFormatoPesos(document.getElementById('cfg-salario-minimo').value), salario_minimo: limpiarFormatoPesos(document.getElementById('cfg-salario-minimo').value),
auxilio_transporte: limpiarFormatoPesos(document.getElementById('cfg-auxilio-transporte').value), auxilio_transporte: limpiarFormatoPesos(document.getElementById('cfg-auxilio-transporte').value),
@@ -276,12 +281,21 @@ document.addEventListener('DOMContentLoaded', function () {
valor_hora_extra_nocturna: limpiarFormatoPesos(document.getElementById('cfg-hora-extra-nocturna').value) valor_hora_extra_nocturna: limpiarFormatoPesos(document.getElementById('cfg-hora-extra-nocturna').value)
}; };
cargarConfiguracionEnFormulario(); try {
await fetch(`${API_URL}/configuracion`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(datos)
});
await cargarConfiguracion();
if (cfgMensaje) { if (cfgMensaje) {
cfgMensaje.textContent = 'Configuración guardada correctamente.'; cfgMensaje.textContent = 'Configuración guardada correctamente.';
setTimeout(() => { cfgMensaje.textContent = ''; }, 3000); setTimeout(() => { cfgMensaje.textContent = ''; }, 3000);
} }
} catch (err) {
alert('Error al guardar configuración');
console.error(err);
}
} }
if (formConfiguraciones) { if (formConfiguraciones) {
@@ -293,12 +307,12 @@ document.addEventListener('DOMContentLoaded', function () {
}); });
inputHorasSemanales.addEventListener('input', calcularCamposDependientes); inputHorasSemanales.addEventListener('input', calcularCamposDependientes);
inputHoraOrdinaria.addEventListener('blur', function () { inputHoraOrdinaria.addEventListener('blur', () => {
aplicarFormatoPesosSinDecimales(this); aplicarFormatoPesosSinDecimales(inputHoraOrdinaria);
calcularCamposDependientes(); calcularCamposDependientes();
}); });
formConfiguraciones.addEventListener('submit', guardarConfiguracion); formConfiguraciones.addEventListener('submit', guardarConfiguracion);
cargarConfiguracionEnFormulario(); cargarConfiguracion();
} }
}); });
+27
View File
@@ -0,0 +1,27 @@
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html;
try_files $uri $uri/ /index.html;
}
location /api/ {
proxy_pass http://localhost:3000/;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}