From 507091e37fd1affd179ce593b960aa5007280e61 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sat, 19 Jan 2019 20:41:18 +0200 Subject: [PATCH 01/75] typescript(translucid): Initial commit Signed-off-by: prescientmoon --- typescript/translucid/.gitignore | 61 ++++++++++ typescript/translucid/LICENSE | 201 +++++++++++++++++++++++++++++++ typescript/translucid/README.md | 2 + 3 files changed, 264 insertions(+) create mode 100644 typescript/translucid/.gitignore create mode 100644 typescript/translucid/LICENSE create mode 100644 typescript/translucid/README.md diff --git a/typescript/translucid/.gitignore b/typescript/translucid/.gitignore new file mode 100644 index 0000000..ad46b30 --- /dev/null +++ b/typescript/translucid/.gitignore @@ -0,0 +1,61 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env + +# next.js build output +.next diff --git a/typescript/translucid/LICENSE b/typescript/translucid/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/typescript/translucid/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/typescript/translucid/README.md b/typescript/translucid/README.md new file mode 100644 index 0000000..d8451c4 --- /dev/null +++ b/typescript/translucid/README.md @@ -0,0 +1,2 @@ +# Translucid +A simple node library to bind files to requests From 62b1390b181f83a47a4235a22bbed966fb90ecc4 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sat, 19 Jan 2019 22:41:54 +0200 Subject: [PATCH 02/75] typescript(translucid): first commit Signed-off-by: prescientmoon --- typescript/translucid/QuickServer.js | 19 ++ typescript/translucid/Translucid.js | 47 +++ typescript/translucid/app.js | 8 + typescript/translucid/index.html | 12 + typescript/translucid/package-lock.json | 363 ++++++++++++++++++++++++ typescript/translucid/package.json | 23 ++ typescript/translucid/read.js | 13 + typescript/translucid/test.js | 13 + 8 files changed, 498 insertions(+) create mode 100644 typescript/translucid/QuickServer.js create mode 100644 typescript/translucid/Translucid.js create mode 100644 typescript/translucid/app.js create mode 100644 typescript/translucid/index.html create mode 100644 typescript/translucid/package-lock.json create mode 100644 typescript/translucid/package.json create mode 100644 typescript/translucid/read.js create mode 100644 typescript/translucid/test.js diff --git a/typescript/translucid/QuickServer.js b/typescript/translucid/QuickServer.js new file mode 100644 index 0000000..e5c574b --- /dev/null +++ b/typescript/translucid/QuickServer.js @@ -0,0 +1,19 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const express = require('express'); +const http = require('http'); +const Translucid_1 = require("./Translucid"); +function QuickServer(port) { + const app = express(); + const server = http.Server(app); + const translucid = new Translucid_1.Translucid(app); + return { + express, app, http, server, translucid, + connect: new Promise((resolve, reject) => { + server.listen(port, () => { + resolve("Connected"); + }); + }) + }; +} +exports.QuickServer = QuickServer; diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js new file mode 100644 index 0000000..ae7a416 --- /dev/null +++ b/typescript/translucid/Translucid.js @@ -0,0 +1,47 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const read_1 = require("./read"); +function containsAny(array, keys) { + for (let i = 0; i < keys.length; i++) { + if (array.indexOf(keys[i]) != -1) + return true; + } + return false; +} +class Translucid { + constructor(app) { + this.app = app; + this.midleware = []; + } + use(obj) { + this.midleware.push(obj); + } + bind(path = "/", filepath = "", text = false, classes = []) { + this.app.get(path, async (req, res) => { + if (!text) { + res.sendFile(`${__dirname}/${filepath}`); + } + else { + const readResults = await read_1.read(filepath); + const toRun = []; + for (let i of this.midleware) { + if (containsAny(classes, i.keys)) { + toRun.push(i.run); + } + } + const decorated = []; + const expressArgs = [req, res]; + for (let i = 0; i < toRun.length; i++) { + decorated.push((prev) => { + toRun[i](prev, ...expressArgs, decorated[i + 1]); + }); + } + decorated.push((prev) => { + res.send(prev + "
Sent from the last iteration"); + }); + decorated[0](readResults); + } + }); + } +} +exports.Translucid = Translucid; diff --git a/typescript/translucid/app.js b/typescript/translucid/app.js new file mode 100644 index 0000000..51454a9 --- /dev/null +++ b/typescript/translucid/app.js @@ -0,0 +1,8 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const read_1 = require("./read"); +exports.read = read_1.read; +const Translucid_js_1 = require("./Translucid.js"); +exports.Translucid = Translucid_js_1.Translucid; +const QuickServer_js_1 = require("./QuickServer.js"); +exports.QuickServer = QuickServer_js_1.QuickServer; diff --git a/typescript/translucid/index.html b/typescript/translucid/index.html new file mode 100644 index 0000000..6396993 --- /dev/null +++ b/typescript/translucid/index.html @@ -0,0 +1,12 @@ + + + + + + + Document + + + Hello World! + + diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json new file mode 100644 index 0000000..042d0be --- /dev/null +++ b/typescript/translucid/package-lock.json @@ -0,0 +1,363 @@ +{ + "name": "translucid", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@types/node": { + "version": "10.12.18", + "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", + "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==" + }, + "accepts": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", + "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", + "requires": { + "mime-types": "~2.1.18", + "negotiator": "0.6.1" + } + }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" + }, + "body-parser": { + "version": "1.18.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", + "integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=", + "requires": { + "bytes": "3.0.0", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "~1.1.2", + "http-errors": "~1.6.3", + "iconv-lite": "0.4.23", + "on-finished": "~2.3.0", + "qs": "6.5.2", + "raw-body": "2.3.3", + "type-is": "~1.6.16" + } + }, + "bytes": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.0.0.tgz", + "integrity": "sha1-0ygVQE1olpn4Wk6k+odV3ROpYEg=" + }, + "content-disposition": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.2.tgz", + "integrity": "sha1-DPaLud318r55YcOoUXjLhdunjLQ=" + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, + "cookie": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.3.1.tgz", + "integrity": "sha1-5+Ch+e9DtMi6klxcWpboBtFoc7s=" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "depd": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", + "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" + }, + "destroy": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", + "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" + }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" + }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" + }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" + }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" + }, + "express": { + "version": "4.16.4", + "resolved": "https://registry.npmjs.org/express/-/express-4.16.4.tgz", + "integrity": "sha512-j12Uuyb4FMrd/qQAm6uCHAkPtO8FDTRJZBDd5D2KOL2eLaz1yUNdUB/NOIyq0iU4q4cFarsUCrnFDPBcnksuOg==", + "requires": { + "accepts": "~1.3.5", + "array-flatten": "1.1.1", + "body-parser": "1.18.3", + "content-disposition": "0.5.2", + "content-type": "~1.0.4", + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "~1.1.2", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.1.1", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.4", + "qs": "6.5.2", + "range-parser": "~1.2.0", + "safe-buffer": "5.1.2", + "send": "0.16.2", + "serve-static": "1.13.2", + "setprototypeof": "1.1.0", + "statuses": "~1.4.0", + "type-is": "~1.6.16", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + } + }, + "finalhandler": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.1.tgz", + "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", + "requires": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "~2.3.0", + "parseurl": "~1.3.2", + "statuses": "~1.4.0", + "unpipe": "~1.0.0" + } + }, + "forwarded": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", + "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" + }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" + }, + "http-errors": { + "version": "1.6.3", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", + "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", + "requires": { + "depd": "~1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": ">= 1.4.0 < 2" + } + }, + "iconv-lite": { + "version": "0.4.23", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.23.tgz", + "integrity": "sha512-neyTUVFtahjf0mB3dZT77u+8O0QB89jFdnBkd5P1JgYPbPaia3gXXOVL2fq8VyU2gMMD7SaN7QukTB/pmXYvDA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" + }, + "ipaddr.js": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.8.0.tgz", + "integrity": "sha1-6qM9bd16zo9/b+DJygRA5wZzix4=" + }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" + }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" + }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" + }, + "mime": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.4.1.tgz", + "integrity": "sha512-KI1+qOZu5DcW6wayYHSzR/tXKCDC5Om4s1z2QJjDULzLcmf3DvzS7oluY4HCTrc+9FiKmWUgeNLg7W3uIQvxtQ==" + }, + "mime-db": { + "version": "1.37.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz", + "integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg==" + }, + "mime-types": { + "version": "2.1.21", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz", + "integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==", + "requires": { + "mime-db": "~1.37.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + }, + "negotiator": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.1.tgz", + "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=" + }, + "on-finished": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", + "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", + "requires": { + "ee-first": "1.1.1" + } + }, + "parseurl": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.2.tgz", + "integrity": "sha1-/CidTtiZMRlGDBViUyYs3I3mW/M=" + }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" + }, + "proxy-addr": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.4.tgz", + "integrity": "sha512-5erio2h9jp5CHGwcybmxmVqHmnCBZeewlfJ0pex+UW7Qny7OOZXTtH56TGNyBizkgiOwhJtMKrVzDTeKcySZwA==", + "requires": { + "forwarded": "~0.1.2", + "ipaddr.js": "1.8.0" + } + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + }, + "range-parser": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz", + "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" + }, + "raw-body": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", + "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", + "requires": { + "bytes": "3.0.0", + "http-errors": "1.6.3", + "iconv-lite": "0.4.23", + "unpipe": "1.0.0" + } + }, + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + }, + "safer-buffer": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", + "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" + }, + "send": { + "version": "0.16.2", + "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", + "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", + "requires": { + "debug": "2.6.9", + "depd": "~1.1.2", + "destroy": "~1.0.4", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "~1.6.2", + "mime": "1.4.1", + "ms": "2.0.0", + "on-finished": "~2.3.0", + "range-parser": "~1.2.0", + "statuses": "~1.4.0" + } + }, + "serve-static": { + "version": "1.13.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", + "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", + "requires": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.2", + "send": "0.16.2" + } + }, + "setprototypeof": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.0.tgz", + "integrity": "sha512-BvE/TwpZX4FXExxOxZyRGQQv651MSwmWKZGqvmPcRIjDqWub67kTKuIMx43cZZrS/cBBzwBcNDWoFxt2XEFIpQ==" + }, + "statuses": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.4.0.tgz", + "integrity": "sha512-zhSCtt8v2NDrRlPQpCNtw/heZLtfUDqxBM1udqikb/Hbk52LK4nQSwr10u77iopCW5LsyHpuXS0GnEc48mLeew==" + }, + "type-is": { + "version": "1.6.16", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", + "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.18" + } + }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + } + } +} diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json new file mode 100644 index 0000000..54f63dd --- /dev/null +++ b/typescript/translucid/package.json @@ -0,0 +1,23 @@ +{ + "name": "translucid", + "version": "1.0.0", + "description": "A simple node library to bind files to requests", + "main": "app.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "a" + }, + "keywords": [ + "translucid" + ], + "author": "Matei Adriel", + "license": "ISC", + "dependencies": { + "@types/node": "^10.12.18", + "express": "^4.16.4" + }, + "devDependencies": {} +} diff --git a/typescript/translucid/read.js b/typescript/translucid/read.js new file mode 100644 index 0000000..303dc15 --- /dev/null +++ b/typescript/translucid/read.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const fs = require('fs'); +function read(url) { + return new Promise((resolve, reject) => { + fs.readFile(`./${url}`, "utf8", (err, data) => { + if (err) + reject(err); + resolve(data); + }); + }); +} +exports.read = read; diff --git a/typescript/translucid/test.js b/typescript/translucid/test.js new file mode 100644 index 0000000..dc459f2 --- /dev/null +++ b/typescript/translucid/test.js @@ -0,0 +1,13 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const app_1 = require("./app"); +const { app, translucid } = app_1.QuickServer(8000); +translucid.bind("/", "index.html"); +translucid.bind("/test", "read.js", true, ["class"]); +translucid.use({ + name: "wow, a midleware", + run: (prev, req, res, next) => { + next("sent by a midleware"); + }, + keys: ["class"] +}); From 4c45df126cbc99e9ab7e7f600304e7ea9df1e964 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sat, 19 Jan 2019 22:49:47 +0200 Subject: [PATCH 03/75] typescript(translucid): added all Signed-off-by: prescientmoon --- typescript/translucid/QuickServer.ts | 26 +++++++++++++ typescript/translucid/Translucid.ts | 58 ++++++++++++++++++++++++++++ typescript/translucid/app.ts | 5 +++ typescript/translucid/test.ts | 12 ++++++ 4 files changed, 101 insertions(+) create mode 100644 typescript/translucid/QuickServer.ts create mode 100644 typescript/translucid/Translucid.ts create mode 100644 typescript/translucid/app.ts create mode 100644 typescript/translucid/test.ts diff --git a/typescript/translucid/QuickServer.ts b/typescript/translucid/QuickServer.ts new file mode 100644 index 0000000..33b7652 --- /dev/null +++ b/typescript/translucid/QuickServer.ts @@ -0,0 +1,26 @@ +const express = require('express'); +const http = require('http'); + +import {Translucid} from "./Translucid"; + +interface Server{ + app:any, + server:any, + connect:Promise +} + +function QuickServer(port:number):any{ + const app = express(); + const server = http.Server(app); + const translucid = new Translucid(app); + return { + express,app,http,server,translucid, + connect:new Promise((resolve,reject) => { + server.listen(port,() => { + resolve("Connected"); + }); + }) + } +} + +export {QuickServer}; diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts new file mode 100644 index 0000000..e6578a4 --- /dev/null +++ b/typescript/translucid/Translucid.ts @@ -0,0 +1,58 @@ +import {read} from "./read"; + +interface Midleware{ + name:string; + run:Function; + keys:Array; +} + +function containsAny(array:Array,keys:Array):boolean{ + for (let i = 0;i < keys.length;i++){ + if (array.indexOf(keys[i]) != -1) return true; + } + return false; +} + +class Translucid{ + midleware:Array = []; + constructor(public app){ + } + use(obj:Midleware):void{ + this.midleware.push(obj); + } + bind(path:string="/",filepath:string="", + text:boolean=false,classes:Array=[]):void{ + this.app.get(path,async (req,res) => { + if (!text){ + res.sendFile(`${__dirname}/${filepath}`); + } + else{ + const readResults = await read(filepath); + + const toRun = []; + for (let i of this.midleware){ + if (containsAny(classes,i.keys)){ + toRun.push(i.run); + } + } + const decorated = []; + + const expressArgs = [req,res]; + + for (let i = 0;i < toRun.length;i++){ + decorated.push((prev) => { + toRun[i](prev,...expressArgs,decorated[i + 1]); + }); + } + + decorated.push((prev) => { + res.send(prev + "
Sent from the last iteration"); + }); + + decorated[0](readResults); + } + }); + } +} + +export {Translucid}; diff --git a/typescript/translucid/app.ts b/typescript/translucid/app.ts new file mode 100644 index 0000000..06a7e9d --- /dev/null +++ b/typescript/translucid/app.ts @@ -0,0 +1,5 @@ +import {read} from "./read"; +import {Translucid} from "./Translucid.js"; +import {QuickServer} from "./QuickServer.js" + +export {read,Translucid,QuickServer}; diff --git a/typescript/translucid/test.ts b/typescript/translucid/test.ts new file mode 100644 index 0000000..8d5b0a0 --- /dev/null +++ b/typescript/translucid/test.ts @@ -0,0 +1,12 @@ +import {QuickServer,Translucid} from "./app"; + +const {app,translucid} = QuickServer(8000); +translucid.bind("/","index.html"); +translucid.bind("/test","read.js",true,["class"]); +translucid.use({ + name:"wow, a midleware", + run:(prev,req,res,next) => { + next("sent by a midleware"); + }, + keys:["class"] +}); From 196b6ba241fd171ddaef30635d065cb76254b6df Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sat, 19 Jan 2019 22:58:24 +0200 Subject: [PATCH 04/75] typescript(translucid): deleted ts files Signed-off-by: prescientmoon --- typescript/translucid/QuickServer.ts | 26 ------------- typescript/translucid/Translucid.ts | 58 ---------------------------- typescript/translucid/app.ts | 5 --- typescript/translucid/test.ts | 12 ------ 4 files changed, 101 deletions(-) delete mode 100644 typescript/translucid/QuickServer.ts delete mode 100644 typescript/translucid/Translucid.ts delete mode 100644 typescript/translucid/app.ts delete mode 100644 typescript/translucid/test.ts diff --git a/typescript/translucid/QuickServer.ts b/typescript/translucid/QuickServer.ts deleted file mode 100644 index 33b7652..0000000 --- a/typescript/translucid/QuickServer.ts +++ /dev/null @@ -1,26 +0,0 @@ -const express = require('express'); -const http = require('http'); - -import {Translucid} from "./Translucid"; - -interface Server{ - app:any, - server:any, - connect:Promise -} - -function QuickServer(port:number):any{ - const app = express(); - const server = http.Server(app); - const translucid = new Translucid(app); - return { - express,app,http,server,translucid, - connect:new Promise((resolve,reject) => { - server.listen(port,() => { - resolve("Connected"); - }); - }) - } -} - -export {QuickServer}; diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts deleted file mode 100644 index e6578a4..0000000 --- a/typescript/translucid/Translucid.ts +++ /dev/null @@ -1,58 +0,0 @@ -import {read} from "./read"; - -interface Midleware{ - name:string; - run:Function; - keys:Array; -} - -function containsAny(array:Array,keys:Array):boolean{ - for (let i = 0;i < keys.length;i++){ - if (array.indexOf(keys[i]) != -1) return true; - } - return false; -} - -class Translucid{ - midleware:Array = []; - constructor(public app){ - } - use(obj:Midleware):void{ - this.midleware.push(obj); - } - bind(path:string="/",filepath:string="", - text:boolean=false,classes:Array=[]):void{ - this.app.get(path,async (req,res) => { - if (!text){ - res.sendFile(`${__dirname}/${filepath}`); - } - else{ - const readResults = await read(filepath); - - const toRun = []; - for (let i of this.midleware){ - if (containsAny(classes,i.keys)){ - toRun.push(i.run); - } - } - const decorated = []; - - const expressArgs = [req,res]; - - for (let i = 0;i < toRun.length;i++){ - decorated.push((prev) => { - toRun[i](prev,...expressArgs,decorated[i + 1]); - }); - } - - decorated.push((prev) => { - res.send(prev + "
Sent from the last iteration"); - }); - - decorated[0](readResults); - } - }); - } -} - -export {Translucid}; diff --git a/typescript/translucid/app.ts b/typescript/translucid/app.ts deleted file mode 100644 index 06a7e9d..0000000 --- a/typescript/translucid/app.ts +++ /dev/null @@ -1,5 +0,0 @@ -import {read} from "./read"; -import {Translucid} from "./Translucid.js"; -import {QuickServer} from "./QuickServer.js" - -export {read,Translucid,QuickServer}; diff --git a/typescript/translucid/test.ts b/typescript/translucid/test.ts deleted file mode 100644 index 8d5b0a0..0000000 --- a/typescript/translucid/test.ts +++ /dev/null @@ -1,12 +0,0 @@ -import {QuickServer,Translucid} from "./app"; - -const {app,translucid} = QuickServer(8000); -translucid.bind("/","index.html"); -translucid.bind("/test","read.js",true,["class"]); -translucid.use({ - name:"wow, a midleware", - run:(prev,req,res,next) => { - next("sent by a midleware"); - }, - keys:["class"] -}); From a098fe038ed5a980260b4ea46088edf16a21a97d Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sat, 19 Jan 2019 23:01:04 +0200 Subject: [PATCH 05/75] typescript(translucid): old files Signed-off-by: prescientmoon --- typescript/translucid/index.html | 12 ------------ typescript/translucid/test.js | 13 ------------- 2 files changed, 25 deletions(-) delete mode 100644 typescript/translucid/index.html delete mode 100644 typescript/translucid/test.js diff --git a/typescript/translucid/index.html b/typescript/translucid/index.html deleted file mode 100644 index 6396993..0000000 --- a/typescript/translucid/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - Document - - - Hello World! - - diff --git a/typescript/translucid/test.js b/typescript/translucid/test.js deleted file mode 100644 index dc459f2..0000000 --- a/typescript/translucid/test.js +++ /dev/null @@ -1,13 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const app_1 = require("./app"); -const { app, translucid } = app_1.QuickServer(8000); -translucid.bind("/", "index.html"); -translucid.bind("/test", "read.js", true, ["class"]); -translucid.use({ - name: "wow, a midleware", - run: (prev, req, res, next) => { - next("sent by a midleware"); - }, - keys: ["class"] -}); From 1b388a05d171cae56e2803dc397fc83a7374bbb3 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sat, 19 Jan 2019 23:23:09 +0200 Subject: [PATCH 06/75] typescript(translucid): changed the readme Signed-off-by: prescientmoon --- typescript/translucid/README.md | 44 +++++++++++++++++++++++++ typescript/translucid/package-lock.json | 5 --- typescript/translucid/package.json | 14 ++++---- 3 files changed, 51 insertions(+), 12 deletions(-) diff --git a/typescript/translucid/README.md b/typescript/translucid/README.md index d8451c4..d64c6d9 100644 --- a/typescript/translucid/README.md +++ b/typescript/translucid/README.md @@ -1,2 +1,46 @@ # Translucid A simple node library to bind files to requests + +# Get started: + +First you need to insall the package: +``` +npm install translucid --save +``` + +Then, you need to include it in your project: +``` +const trans = require("translucid"); +``` + +To init your first server, call .QuickServer(port): +``` +trans.QuickServer(8000); +``` + +The .QuickServer methode return many useful objects: +``` +const {app,server,connect,translucid} = trans.QuickServer(8000); +``` +Connect is a promise that resolves when the server starts listening to the port: +``` +connect.then(() => { + console.log("Listening on port 8000!"); +}); +``` +The translucid object can be used to make files bindings: +``` +translucid.bind("/","client/index.html",true//use midleware,["myId"]); +``` +Then you can add midlewares like this: +``` +translucid.use({ + name:"my midleware", + keys:"myid", + run:(prev,req,res,next) => { + //prev is the data that is going to be sent to the client + //(it might for example be the index.html file); + next(prev+"string added by a midleware"); + } +}); +``` diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index 042d0be..e9ccbd8 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -4,11 +4,6 @@ "lockfileVersion": 1, "requires": true, "dependencies": { - "@types/node": { - "version": "10.12.18", - "resolved": "https://registry.npmjs.org/@types/node/-/node-10.12.18.tgz", - "integrity": "sha512-fh+pAqt4xRzPfqA6eh3Z2y6fyZavRIumvjhaCL753+TVkGKGhpPeyrJG2JftD0T9q4GF00KjefsQ+PQNDdWQaQ==" - }, "accepts": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index 54f63dd..79be118 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -7,17 +7,17 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { - "type": "git", - "url": "a" + "type": "github", + "url": "https://github.com/Mateiadrielrafael/Translucid" }, "keywords": [ - "translucid" + "translucid", + "express", + "server" ], "author": "Matei Adriel", - "license": "ISC", + "license": "Apache License 2.0", "dependencies": { - "@types/node": "^10.12.18", "express": "^4.16.4" - }, - "devDependencies": {} + } } From 6388e9cafbf99314caf869b8b240bc1ca1b8f04b Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sat, 19 Jan 2019 23:25:24 +0200 Subject: [PATCH 07/75] typescript(translucid): added [] in keys in readme Signed-off-by: prescientmoon --- typescript/translucid/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/translucid/README.md b/typescript/translucid/README.md index d64c6d9..b8bb366 100644 --- a/typescript/translucid/README.md +++ b/typescript/translucid/README.md @@ -36,7 +36,7 @@ Then you can add midlewares like this: ``` translucid.use({ name:"my midleware", - keys:"myid", + keys:["myid"], run:(prev,req,res,next) => { //prev is the data that is going to be sent to the client //(it might for example be the index.html file); From e3b8c17c562703020c3b5a6f37f3215b8847bb79 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sat, 19 Jan 2019 23:32:08 +0200 Subject: [PATCH 08/75] typescript(translucid): fixed typos Signed-off-by: prescientmoon --- typescript/translucid/README.md | 14 +++++++------- typescript/translucid/package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/typescript/translucid/README.md b/typescript/translucid/README.md index b8bb366..3df9376 100644 --- a/typescript/translucid/README.md +++ b/typescript/translucid/README.md @@ -1,9 +1,9 @@ # Translucid -A simple node library to bind files to requests +A simple node.js library to bind files to requests # Get started: -First you need to insall the package: +First you need to install the package: ``` npm install translucid --save ``` @@ -13,26 +13,26 @@ Then, you need to include it in your project: const trans = require("translucid"); ``` -To init your first server, call .QuickServer(port): +To create your first server, call ".QuickServer(port)": ``` trans.QuickServer(8000); ``` -The .QuickServer methode return many useful objects: +The ".QuickServer" method return many useful objects: ``` const {app,server,connect,translucid} = trans.QuickServer(8000); ``` -Connect is a promise that resolves when the server starts listening to the port: +"Connect" is a promise that resolves when the server starts listening to the port: ``` connect.then(() => { console.log("Listening on port 8000!"); }); ``` -The translucid object can be used to make files bindings: +The translucid object can be used to make file bindings: ``` translucid.bind("/","client/index.html",true//use midleware,["myId"]); ``` -Then you can add midlewares like this: +Then you can add midleware like this: ``` translucid.use({ name:"my midleware", diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index 79be118..0deeb43 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -4,7 +4,7 @@ "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "test": "echo \"-1/12\" && exit 1" }, "repository": { "type": "github", From 57b52f72d3bc1fecf9feb66ebbe1eca119e9b6a5 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sat, 19 Jan 2019 23:34:32 +0200 Subject: [PATCH 09/75] typescript(translucid): fixed middleware typo Signed-off-by: prescientmoon --- typescript/translucid/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/typescript/translucid/README.md b/typescript/translucid/README.md index 3df9376..6aba50f 100644 --- a/typescript/translucid/README.md +++ b/typescript/translucid/README.md @@ -30,17 +30,17 @@ connect.then(() => { ``` The translucid object can be used to make file bindings: ``` -translucid.bind("/","client/index.html",true//use midleware,["myId"]); +translucid.bind("/","client/index.html",true,["myId"]); ``` -Then you can add midleware like this: +Then you can add middleware like this: ``` translucid.use({ - name:"my midleware", + name:"my middleware", keys:["myid"], run:(prev,req,res,next) => { //prev is the data that is going to be sent to the client //(it might for example be the index.html file); - next(prev+"string added by a midleware"); + next(`${prev}
string added by a middleware`); } }); ``` From 5ba5303467b24ff925792161fded3191c73ad6f2 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sat, 19 Jan 2019 23:35:04 +0200 Subject: [PATCH 10/75] typescript(translucid): 1.0.1 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index e9ccbd8..b1bc548 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index 0deeb43..b758f79 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.0", + "version": "1.0.1", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 33b24d79f52a2ffc5de32736c06780ef60685659 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sat, 19 Jan 2019 23:38:16 +0200 Subject: [PATCH 11/75] typescript(translucid): fixed critical bug Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index ae7a416..89416ab 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -37,7 +37,7 @@ class Translucid { }); } decorated.push((prev) => { - res.send(prev + "
Sent from the last iteration"); + res.send(prev); }); decorated[0](readResults); } From 5c5dfac46d07716c9d484c22adaeb18dd070835f Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sat, 19 Jan 2019 23:38:40 +0200 Subject: [PATCH 12/75] typescript(translucid): 1.0.2 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index b1bc548..aa1af74 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.1", + "version": "1.0.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index b758f79..575a7e0 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.1", + "version": "1.0.2", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From dd2f058a4a51ba478c43327eca69126808da3b97 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 12:35:39 +0200 Subject: [PATCH 13/75] typescript(translucid): oof Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 89416ab..840a785 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -19,7 +19,7 @@ class Translucid { bind(path = "/", filepath = "", text = false, classes = []) { this.app.get(path, async (req, res) => { if (!text) { - res.sendFile(`${__dirname}/${filepath}`); + res.sendFile(`${__dirname}/../../${filepath}`); } else { const readResults = await read_1.read(filepath); From 46fdc8a70a7b4b62f67e4e985332846c9a13fbb6 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 12:36:18 +0200 Subject: [PATCH 14/75] typescript(translucid): 1.0.3 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index aa1af74..0e8c5c7 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.2", + "version": "1.0.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index 575a7e0..b1bfc31 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.2", + "version": "1.0.3", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 43a47711488f75b6f12e592a864fd361a003e5ba Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 12:40:25 +0200 Subject: [PATCH 15/75] typescript(translucid): fixed bugs Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 2 +- typescript/translucid/read.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 840a785..89416ab 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -19,7 +19,7 @@ class Translucid { bind(path = "/", filepath = "", text = false, classes = []) { this.app.get(path, async (req, res) => { if (!text) { - res.sendFile(`${__dirname}/../../${filepath}`); + res.sendFile(`${__dirname}/${filepath}`); } else { const readResults = await read_1.read(filepath); diff --git a/typescript/translucid/read.js b/typescript/translucid/read.js index 303dc15..76644a7 100644 --- a/typescript/translucid/read.js +++ b/typescript/translucid/read.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const fs = require('fs'); function read(url) { return new Promise((resolve, reject) => { - fs.readFile(`./${url}`, "utf8", (err, data) => { + fs.readFile(`${__dirname}/${url}`, "utf8", (err, data) => { if (err) reject(err); resolve(data); From d0fbe7b5e9198b2c4226309761eeac2c778c7310 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 12:40:43 +0200 Subject: [PATCH 16/75] typescript(translucid): 1.0.4 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index 0e8c5c7..aed7586 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.3", + "version": "1.0.4", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index b1bfc31..e6b0929 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.3", + "version": "1.0.4", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From ed416caf0868375921b9c01e7d3dc8afd6b1d9d5 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 12:45:23 +0200 Subject: [PATCH 17/75] typescript(translucid): idk anymore Signed-off-by: prescientmoon --- typescript/translucid/read.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/translucid/read.js b/typescript/translucid/read.js index 76644a7..25b2ce2 100644 --- a/typescript/translucid/read.js +++ b/typescript/translucid/read.js @@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const fs = require('fs'); function read(url) { return new Promise((resolve, reject) => { - fs.readFile(`${__dirname}/${url}`, "utf8", (err, data) => { + fs.readFile(`${__dirname}/../../${url}`, "utf8", (err, data) => { if (err) reject(err); resolve(data); From ac9dfc4c0b0b09b8ba811c264f01232104d2b9e1 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 12:45:48 +0200 Subject: [PATCH 18/75] typescript(translucid): 1.0.5 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index aed7586..a3be246 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.4", + "version": "1.0.5", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index e6b0929..92fbdb7 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.4", + "version": "1.0.5", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From b915bd8eda95c195edf278506eabc439abd18cd7 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 12:49:14 +0200 Subject: [PATCH 19/75] typescript(translucid): fixed path Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 89416ab..840a785 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -19,7 +19,7 @@ class Translucid { bind(path = "/", filepath = "", text = false, classes = []) { this.app.get(path, async (req, res) => { if (!text) { - res.sendFile(`${__dirname}/${filepath}`); + res.sendFile(`${__dirname}/../../${filepath}`); } else { const readResults = await read_1.read(filepath); From 7bf47c368a0e3c6c2230fafa99a8e91254a464e9 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 12:49:31 +0200 Subject: [PATCH 20/75] typescript(translucid): 1.0.6 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index a3be246..c33046a 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.5", + "version": "1.0.6", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index 92fbdb7..dfdf5bd 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.5", + "version": "1.0.6", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 3f4adad4aeed1dc4022767178b6303fb4e83a5a6 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 12:53:57 +0200 Subject: [PATCH 21/75] typescript(translucid): deprecated false Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 840a785..469d941 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -19,7 +19,7 @@ class Translucid { bind(path = "/", filepath = "", text = false, classes = []) { this.app.get(path, async (req, res) => { if (!text) { - res.sendFile(`${__dirname}/../../${filepath}`); + console.error("Blocking reading acces s deprecated, and would be remove in the next version."); } else { const readResults = await read_1.read(filepath); From 39afed78dc516fc69385020ba22b04724d3dfa40 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 12:54:21 +0200 Subject: [PATCH 22/75] typescript(translucid): 1.0.7 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index c33046a..24d1307 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.6", + "version": "1.0.7", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index dfdf5bd..762c956 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.6", + "version": "1.0.7", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 62bf58898e96f4545e833d6773ee8d0b40addb6c Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 12:57:11 +0200 Subject: [PATCH 23/75] typescript(translucid): deprecations Signed-off-by: prescientmoon --- typescript/translucid/README.md | 2 +- typescript/translucid/Translucid.js | 35 +++++++++++++---------------- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/typescript/translucid/README.md b/typescript/translucid/README.md index 6aba50f..12fa6b4 100644 --- a/typescript/translucid/README.md +++ b/typescript/translucid/README.md @@ -30,7 +30,7 @@ connect.then(() => { ``` The translucid object can be used to make file bindings: ``` -translucid.bind("/","client/index.html",true,["myId"]); +translucid.bind("/","client/index.html",["myId"]); ``` Then you can add middleware like this: ``` diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 469d941..3f464ec 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -16,31 +16,26 @@ class Translucid { use(obj) { this.midleware.push(obj); } - bind(path = "/", filepath = "", text = false, classes = []) { + bind(path = "/", filepath = "", classes = []) { this.app.get(path, async (req, res) => { - if (!text) { - console.error("Blocking reading acces s deprecated, and would be remove in the next version."); + const readResults = await read_1.read(filepath); + const toRun = []; + for (let i of this.midleware) { + if (containsAny(classes, i.keys)) { + toRun.push(i.run); + } } - else { - const readResults = await read_1.read(filepath); - const toRun = []; - for (let i of this.midleware) { - if (containsAny(classes, i.keys)) { - toRun.push(i.run); - } - } - const decorated = []; - const expressArgs = [req, res]; - for (let i = 0; i < toRun.length; i++) { - decorated.push((prev) => { - toRun[i](prev, ...expressArgs, decorated[i + 1]); - }); - } + const decorated = []; + const expressArgs = [req, res]; + for (let i = 0; i < toRun.length; i++) { decorated.push((prev) => { - res.send(prev); + toRun[i](prev, ...expressArgs, decorated[i + 1]); }); - decorated[0](readResults); } + decorated.push((prev) => { + res.send(prev); + }); + decorated[0](readResults); }); } } From 09eccccf97f1af6aa537cec0f06044b4f1500de8 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 12:57:49 +0200 Subject: [PATCH 24/75] typescript(translucid): 1.0.8 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index 24d1307..a1b6390 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.7", + "version": "1.0.8", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index 762c956..4753043 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.7", + "version": "1.0.8", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 5d08b794bf36280f6f3c7c65f17da266aaef1030 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 13:02:48 +0200 Subject: [PATCH 25/75] typescript(translucid): public Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 3f464ec..0b61ea4 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -16,6 +16,9 @@ class Translucid { use(obj) { this.midleware.push(obj); } + public(path = "") { + this.app.use(`${__dirname}/../../${path}`, express.static(`${__dirname}/../../${path}`)); + } bind(path = "/", filepath = "", classes = []) { this.app.get(path, async (req, res) => { const readResults = await read_1.read(filepath); From 90957e1772e5e96299319f99c9e6bf5a12c734c9 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 13:03:42 +0200 Subject: [PATCH 26/75] typescript(translucid): 0.0.9 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index a1b6390..da19902 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.8", + "version": "0.0.9", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index 4753043..7807b97 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.8", + "version": "0.0.9", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 908a69c9855a20848929e335ca9351ce42fb7fe8 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 13:04:58 +0200 Subject: [PATCH 27/75] typescript(translucid): 1.0.9 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index da19902..752b056 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "0.0.9", + "version": "1.0.9", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index 7807b97..df35b67 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "0.0.9", + "version": "1.0.9", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From efa99a1f08b7d52e9dc380892391bb65d559a6dd Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 13:06:55 +0200 Subject: [PATCH 28/75] typescript(translucid): fixed express bug Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 1 + 1 file changed, 1 insertion(+) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 0b61ea4..0e9279b 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -1,5 +1,6 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +const express = require('express'); const read_1 = require("./read"); function containsAny(array, keys) { for (let i = 0; i < keys.length; i++) { From aea0646dc83406df39f7cd91052b79d22ffadddb Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 13:07:17 +0200 Subject: [PATCH 29/75] typescript(translucid): 1.0.10 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index 752b056..3e52e6e 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.9", + "version": "1.0.10", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index df35b67..4977228 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.9", + "version": "1.0.10", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 96bc542e76741a04d8863c78f612478e3e1d242b Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 13:09:45 +0200 Subject: [PATCH 30/75] typescript(translucid): fixed express static file path without __dirname Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 0e9279b..18f2dca 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -18,7 +18,7 @@ class Translucid { this.midleware.push(obj); } public(path = "") { - this.app.use(`${__dirname}/../../${path}`, express.static(`${__dirname}/../../${path}`)); + this.app.use(`/${path}`, express.static(`/${path}`)); } bind(path = "/", filepath = "", classes = []) { this.app.get(path, async (req, res) => { From 933e964ff00f2f004e68ce8b69a21f21913f091d Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 13:10:10 +0200 Subject: [PATCH 31/75] typescript(translucid): 1.0.11 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index 3e52e6e..f8c9a1b 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.10", + "version": "1.0.11", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index 4977228..b3fe093 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.10", + "version": "1.0.11", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 23dd6e580d67abcc0d22ab1168eceb16e65ed132 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 13:13:08 +0200 Subject: [PATCH 32/75] typescript(translucid): fixed res path of public Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 18f2dca..188ca5e 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -18,7 +18,7 @@ class Translucid { this.midleware.push(obj); } public(path = "") { - this.app.use(`/${path}`, express.static(`/${path}`)); + this.app.use(`/${path}`, express.static(`${__dirname}/../../${path}`)); } bind(path = "/", filepath = "", classes = []) { this.app.get(path, async (req, res) => { From f95c98d2f4b5acf1691a1138d7502b566284b48b Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Sun, 20 Jan 2019 13:13:32 +0200 Subject: [PATCH 33/75] typescript(translucid): 1.0.12 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index f8c9a1b..a879b84 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.11", + "version": "1.0.12", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index b3fe093..eda5014 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.11", + "version": "1.0.12", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 43f997013de4859c1810f6b03677c9aeaa9f87a5 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 20:26:18 +0200 Subject: [PATCH 34/75] typescript(translucid): typescipited Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 15 +++++-- typescript/translucid/Translucid.ts | 62 +++++++++++++++++++++++++++++ typescript/translucid/tsconfig.json | 9 +++++ 3 files changed, 82 insertions(+), 4 deletions(-) create mode 100644 typescript/translucid/Translucid.ts create mode 100644 typescript/translucid/tsconfig.json diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 188ca5e..1e6eb78 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -12,19 +12,27 @@ function containsAny(array, keys) { class Translucid { constructor(app) { this.app = app; - this.midleware = []; + this.middleware = []; } use(obj) { - this.midleware.push(obj); + this.middleware.push(obj); } public(path = "") { this.app.use(`/${path}`, express.static(`${__dirname}/../../${path}`)); } + async bindJSON(path) { + const json = await read_1.read(path); + const object = JSON.parse(json); + for (let i in object) { + const classes = object.classes || []; + this.bind(object[i].path, object[i].file, classes); + } + } bind(path = "/", filepath = "", classes = []) { this.app.get(path, async (req, res) => { const readResults = await read_1.read(filepath); const toRun = []; - for (let i of this.midleware) { + for (let i of this.middleware) { if (containsAny(classes, i.keys)) { toRun.push(i.run); } @@ -43,4 +51,3 @@ class Translucid { }); } } -exports.Translucid = Translucid; diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts new file mode 100644 index 0000000..2bc3ec6 --- /dev/null +++ b/typescript/translucid/Translucid.ts @@ -0,0 +1,62 @@ +const express = require('express'); +import {read} from "./read"; + +interface Middleware{ + name:string; + keys:Array; + run:Function; +} + +function containsAny(array:Array, keys:Array):boolean{ + for (let i = 0; i < keys.length; i++) { + if (array.indexOf(keys[i]) != -1) + return true; + } + return false; +} +class Translucid { + middleware:Array = []; + + constructor(public app) {} + use(obj:Middleware):void{ + this.middleware.push(obj); + } + public(path:string = ""):void{ + this.app.use(`/${path}`, express.static(`${__dirname}/../../${path}`)); + } + async bindJSON(path:string):Promise{ + const json = await read(path); + const object = JSON.parse(json); + + for (let i in object){ + const classes = object.classes || []; + this.bind(object[i].path,object[i].file,classes); + } + } + bind(path:string = "/", filepath:string = "", classes:Array = []):void{ + this.app.get(path, async (req, res)=> { + const readResults = await read(filepath); + const toRun:Array = []; + + for (let i of this.middleware){ + if (containsAny(classes, i.keys)) { + toRun.push(i.run); + } + } + + const decorated:Array = []; + const expressArgs = [req, res]; + + for (let i = 0; i < toRun.length; i++) { + decorated.push((prev:any):void => { + toRun[i](prev, ...expressArgs, decorated[i + 1]); + }); + } + decorated.push((prev:any):void => { + res.send(prev); + }); + + decorated[0](readResults); + }); + } +} diff --git a/typescript/translucid/tsconfig.json b/typescript/translucid/tsconfig.json new file mode 100644 index 0000000..4a38e41 --- /dev/null +++ b/typescript/translucid/tsconfig.json @@ -0,0 +1,9 @@ +{ + "compilerOptions":{ + "target":"esnext", + "watch":true, + "lib":["es2017"], + "module": "commonjs" + }, + "exclude": ["node_modules", "**/__tests__/*"] +} From a80dda078b1cb1c5d3d27d50af9b43c4c0b6df8e Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 20:27:26 +0200 Subject: [PATCH 35/75] typescript(translucid): 1.0.13 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index a879b84..e921a6f 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.12", + "version": "1.0.13", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index eda5014..d6fbe2d 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.12", + "version": "1.0.13", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 2a955d675f6f2e075cc2025bdfc593f4d3336442 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 20:45:32 +0200 Subject: [PATCH 36/75] typescript(translucid): unknown bug Signed-off-by: prescientmoon --- typescript/translucid/QuickServer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typescript/translucid/QuickServer.js b/typescript/translucid/QuickServer.js index e5c574b..5ab474f 100644 --- a/typescript/translucid/QuickServer.js +++ b/typescript/translucid/QuickServer.js @@ -2,7 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const express = require('express'); const http = require('http'); -const Translucid_1 = require("./Translucid"); +const Translucid_1 = require("./Translucid.js"); function QuickServer(port) { const app = express(); const server = http.Server(app); From 4427e45702bc8f790b3350d362a7628daa1be1cd Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 20:45:57 +0200 Subject: [PATCH 37/75] typescript(translucid): 1.0.14 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index e921a6f..d744669 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.13", + "version": "1.0.14", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index d6fbe2d..2f39f67 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.13", + "version": "1.0.14", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 656e41473c305fe72bb338d90892656f6681e2d3 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 20:49:50 +0200 Subject: [PATCH 38/75] typescript(translucid): fixed the bug Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 1 + typescript/translucid/Translucid.ts | 1 + typescript/translucid/test.js | 4 ++++ typescript/translucid/test.ts | 3 +++ 4 files changed, 9 insertions(+) create mode 100644 typescript/translucid/test.js create mode 100644 typescript/translucid/test.ts diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 1e6eb78..064f4cf 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -51,3 +51,4 @@ class Translucid { }); } } +exports.Translucid = Translucid; diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts index 2bc3ec6..dfcd98a 100644 --- a/typescript/translucid/Translucid.ts +++ b/typescript/translucid/Translucid.ts @@ -60,3 +60,4 @@ class Translucid { }); } } +export {Translucid}; diff --git a/typescript/translucid/test.js b/typescript/translucid/test.js new file mode 100644 index 0000000..402b2b2 --- /dev/null +++ b/typescript/translucid/test.js @@ -0,0 +1,4 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +const app_js_1 = require("./app.js"); +const { app, http, translucid } = app_js_1.QuickServer(8000); diff --git a/typescript/translucid/test.ts b/typescript/translucid/test.ts new file mode 100644 index 0000000..89940f3 --- /dev/null +++ b/typescript/translucid/test.ts @@ -0,0 +1,3 @@ +import {QuickServer} from "./app.js"; + +const {app,http,translucid} = QuickServer(8000); From 1e028a4567de3a4e9dad4a76e930043831f996e2 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 20:49:58 +0200 Subject: [PATCH 39/75] typescript(translucid): 1.0.15 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index d744669..8d837fe 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.14", + "version": "1.0.15", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index 2f39f67..a78ea42 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.14", + "version": "1.0.15", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 2d3fcc12b7f4afc3a4902835efe548b6f040630c Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 21:01:26 +0200 Subject: [PATCH 40/75] typescript(translucid): oof Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 2 +- typescript/translucid/Translucid.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 064f4cf..50c3605 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -24,7 +24,7 @@ class Translucid { const json = await read_1.read(path); const object = JSON.parse(json); for (let i in object) { - const classes = object.classes || []; + const classes = object[i].classes || []; this.bind(object[i].path, object[i].file, classes); } } diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts index dfcd98a..6471697 100644 --- a/typescript/translucid/Translucid.ts +++ b/typescript/translucid/Translucid.ts @@ -29,7 +29,7 @@ class Translucid { const object = JSON.parse(json); for (let i in object){ - const classes = object.classes || []; + const classes = object[i].classes || []; this.bind(object[i].path,object[i].file,classes); } } From ec31174b1be15ce080da1b1b77d5fccc671322e4 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 21:01:50 +0200 Subject: [PATCH 41/75] typescript(translucid): 1.0.16 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index 8d837fe..8bde1f1 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.15", + "version": "1.0.16", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index a78ea42..f0438d3 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.15", + "version": "1.0.16", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 3379d14686498fc0d0526889f47ab122238ff204 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 21:04:23 +0200 Subject: [PATCH 42/75] typescript(translucid): i hate this bug Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 1 + typescript/translucid/Translucid.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 50c3605..82b5d86 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -26,6 +26,7 @@ class Translucid { for (let i in object) { const classes = object[i].classes || []; this.bind(object[i].path, object[i].file, classes); + console.log(`Binded room with name ${object[i].file} and path ${object[i].filepath} with classes ${classes}`); } } bind(path = "/", filepath = "", classes = []) { diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts index 6471697..e658359 100644 --- a/typescript/translucid/Translucid.ts +++ b/typescript/translucid/Translucid.ts @@ -31,6 +31,7 @@ class Translucid { for (let i in object){ const classes = object[i].classes || []; this.bind(object[i].path,object[i].file,classes); + console.log(`Binded room with name ${object[i].file} and path ${object[i].filepath} with classes ${classes}`) } } bind(path:string = "/", filepath:string = "", classes:Array = []):void{ From 0000de95cfbfacd5d9946e392af58c8a639e175e Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 21:04:40 +0200 Subject: [PATCH 43/75] typescript(translucid): 1.0.17 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index 8bde1f1..8bf0162 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.16", + "version": "1.0.17", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index f0438d3..e68e7a9 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.16", + "version": "1.0.17", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 00abe6ef083ab2b22d8f9eaadcd9eb418344a5b0 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 21:06:48 +0200 Subject: [PATCH 44/75] typescript(translucid): hate it even more (jk) Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 4 ++-- typescript/translucid/Translucid.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 82b5d86..322148c 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -25,8 +25,8 @@ class Translucid { const object = JSON.parse(json); for (let i in object) { const classes = object[i].classes || []; - this.bind(object[i].path, object[i].file, classes); - console.log(`Binded room with name ${object[i].file} and path ${object[i].filepath} with classes ${classes}`); + this.bind(i, object[i].file, classes); + console.log(`Binded room with name ${i} and path ${object[i].path} with classes ${classes}`); } } bind(path = "/", filepath = "", classes = []) { diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts index e658359..95eb0d4 100644 --- a/typescript/translucid/Translucid.ts +++ b/typescript/translucid/Translucid.ts @@ -30,8 +30,8 @@ class Translucid { for (let i in object){ const classes = object[i].classes || []; - this.bind(object[i].path,object[i].file,classes); - console.log(`Binded room with name ${object[i].file} and path ${object[i].filepath} with classes ${classes}`) + this.bind(i,object[i].file,classes); + console.log(`Binded room with name ${i} and path ${object[i].path} with classes ${classes}`) } } bind(path:string = "/", filepath:string = "", classes:Array = []):void{ From 0d810410417a42e60ba165f6f2131643e7428084 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 21:06:56 +0200 Subject: [PATCH 45/75] typescript(translucid): 1.0.18 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index 8bf0162..d52bca7 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.17", + "version": "1.0.18", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index e68e7a9..1e7a4f7 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.17", + "version": "1.0.18", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 150648e4b3d229494a5c52c227abb81e32f16c81 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 21:11:05 +0200 Subject: [PATCH 46/75] typescript(translucid): testing automated update Signed-off-by: prescientmoon --- typescript/translucid/.gitignore | 2 ++ typescript/translucid/Translucid.js | 2 +- typescript/translucid/Translucid.ts | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/.gitignore b/typescript/translucid/.gitignore index ad46b30..daf2ca9 100644 --- a/typescript/translucid/.gitignore +++ b/typescript/translucid/.gitignore @@ -1,3 +1,5 @@ +update.bat + # Logs logs *.log diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 322148c..2f8e50b 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -26,7 +26,7 @@ class Translucid { for (let i in object) { const classes = object[i].classes || []; this.bind(i, object[i].file, classes); - console.log(`Binded room with name ${i} and path ${object[i].path} with classes ${classes}`); + console.log(`Binded room with name ${i} and path ${object[i].file} with classes ${classes}`); } } bind(path = "/", filepath = "", classes = []) { diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts index 95eb0d4..b5d3819 100644 --- a/typescript/translucid/Translucid.ts +++ b/typescript/translucid/Translucid.ts @@ -31,7 +31,7 @@ class Translucid { for (let i in object){ const classes = object[i].classes || []; this.bind(i,object[i].file,classes); - console.log(`Binded room with name ${i} and path ${object[i].path} with classes ${classes}`) + console.log(`Binded room with name ${i} and path ${object[i].file} with classes ${classes}`) } } bind(path:string = "/", filepath:string = "", classes:Array = []):void{ From c45c79791c53bc33e8a25653314c21ffc1ab2eeb Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 21:11:07 +0200 Subject: [PATCH 47/75] typescript(translucid): 1.0.19 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index d52bca7..55fdb7d 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.18", + "version": "1.0.19", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index 1e7a4f7..de62818 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.18", + "version": "1.0.19", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 1a457d4ec77001c2cabe2b0f52c70e8a3383c2a0 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 21:17:00 +0200 Subject: [PATCH 48/75] typescript(translucid): 1.0.20 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index 55fdb7d..061092c 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.19", + "version": "1.0.20", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index de62818..940b3ec 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.19", + "version": "1.0.20", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 542d2d1e9ad9b8169fa955cc415fccd3cd134c65 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 21:18:03 +0200 Subject: [PATCH 49/75] typescript(translucid): testing automated update Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 1 + typescript/translucid/Translucid.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 2f8e50b..557784a 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -26,6 +26,7 @@ class Translucid { for (let i in object) { const classes = object[i].classes || []; this.bind(i, object[i].file, classes); + //gotta comment this later console.log(`Binded room with name ${i} and path ${object[i].file} with classes ${classes}`); } } diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts index b5d3819..8d0a6a3 100644 --- a/typescript/translucid/Translucid.ts +++ b/typescript/translucid/Translucid.ts @@ -31,6 +31,7 @@ class Translucid { for (let i in object){ const classes = object[i].classes || []; this.bind(i,object[i].file,classes); + //gotta comment this later console.log(`Binded room with name ${i} and path ${object[i].file} with classes ${classes}`) } } From d51f2eba4b725ace611f61e6e891c20823f637da Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 21:18:10 +0200 Subject: [PATCH 50/75] typescript(translucid): 1.0.21 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index 061092c..a2d04e5 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.20", + "version": "1.0.21", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index 940b3ec..65bdd70 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.20", + "version": "1.0.21", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From e4ca1e7e50cb7223e4af193eafe3523e8935b7d0 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 21:46:26 +0200 Subject: [PATCH 51/75] typescript(translucid): hopefully... Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 1 + typescript/translucid/Translucid.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 557784a..6ec9710 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -47,6 +47,7 @@ class Translucid { }); } decorated.push((prev) => { + res.contentType(`${__dirname}/../../${filepath}`); res.send(prev); }); decorated[0](readResults); diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts index 8d0a6a3..235737d 100644 --- a/typescript/translucid/Translucid.ts +++ b/typescript/translucid/Translucid.ts @@ -55,6 +55,7 @@ class Translucid { }); } decorated.push((prev:any):void => { + res.contentType(`${__dirname}/../../${filepath}`); res.send(prev); }); From 13fe6be102caa9f6b750a3751a4d344b3c718910 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 21:46:49 +0200 Subject: [PATCH 52/75] typescript(translucid): 1.0.22 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index a2d04e5..eaa8657 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.21", + "version": "1.0.22", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index 65bdd70..06bc627 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.21", + "version": "1.0.22", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From c8bd42b7696d20d72f6d4ad17b19beab89373262 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 21:51:07 +0200 Subject: [PATCH 53/75] typescript(translucid): logged Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 7 ++++--- typescript/translucid/Translucid.ts | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 6ec9710..1435d81 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -27,7 +27,7 @@ class Translucid { const classes = object[i].classes || []; this.bind(i, object[i].file, classes); //gotta comment this later - console.log(`Binded room with name ${i} and path ${object[i].file} with classes ${classes}`); + // console.log(`Binded room with name ${i} and path ${object[i].file} with classes ${classes}`) } } bind(path = "/", filepath = "", classes = []) { @@ -46,8 +46,9 @@ class Translucid { toRun[i](prev, ...expressArgs, decorated[i + 1]); }); } - decorated.push((prev) => { - res.contentType(`${__dirname}/../../${filepath}`); + decorated.push((prev, req, res) => { + console.log(`${__dirname}/../../${filepath}`); + // res.contentType(`${__dirname}/../../${filepath}`); res.send(prev); }); decorated[0](readResults); diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts index 235737d..2cf173f 100644 --- a/typescript/translucid/Translucid.ts +++ b/typescript/translucid/Translucid.ts @@ -32,7 +32,7 @@ class Translucid { const classes = object[i].classes || []; this.bind(i,object[i].file,classes); //gotta comment this later - console.log(`Binded room with name ${i} and path ${object[i].file} with classes ${classes}`) + // console.log(`Binded room with name ${i} and path ${object[i].file} with classes ${classes}`) } } bind(path:string = "/", filepath:string = "", classes:Array = []):void{ @@ -54,8 +54,9 @@ class Translucid { toRun[i](prev, ...expressArgs, decorated[i + 1]); }); } - decorated.push((prev:any):void => { - res.contentType(`${__dirname}/../../${filepath}`); + decorated.push((prev:any,req,res):void => { + console.log(`${__dirname}/../../${filepath}`); + // res.contentType(`${__dirname}/../../${filepath}`); res.send(prev); }); From f9bef432e3a0c4e86e21619ee860c7a23e68b367 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 21:51:22 +0200 Subject: [PATCH 54/75] typescript(translucid): 1.0.23 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index eaa8657..814eb76 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.22", + "version": "1.0.23", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index 06bc627..ffd983b 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.22", + "version": "1.0.23", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 1feb795761da5d40393cbf93e9138354a60c2f33 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 21:54:03 +0200 Subject: [PATCH 55/75] typescript(translucid): noooooooooo Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 2 +- typescript/translucid/Translucid.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 1435d81..36cf994 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -46,7 +46,7 @@ class Translucid { toRun[i](prev, ...expressArgs, decorated[i + 1]); }); } - decorated.push((prev, req, res) => { + decorated.push((prev) => { console.log(`${__dirname}/../../${filepath}`); // res.contentType(`${__dirname}/../../${filepath}`); res.send(prev); diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts index 2cf173f..10be791 100644 --- a/typescript/translucid/Translucid.ts +++ b/typescript/translucid/Translucid.ts @@ -54,7 +54,7 @@ class Translucid { toRun[i](prev, ...expressArgs, decorated[i + 1]); }); } - decorated.push((prev:any,req,res):void => { + decorated.push((prev:any):void => { console.log(`${__dirname}/../../${filepath}`); // res.contentType(`${__dirname}/../../${filepath}`); res.send(prev); From 49594865ea809223df441c87a509d1fcbd83a6f5 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 21:54:51 +0200 Subject: [PATCH 56/75] typescript(translucid): nnnnnnnnoooooooooooo Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 4 ++-- typescript/translucid/Translucid.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 36cf994..26b4b56 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -47,8 +47,8 @@ class Translucid { }); } decorated.push((prev) => { - console.log(`${__dirname}/../../${filepath}`); - // res.contentType(`${__dirname}/../../${filepath}`); + // console.log(`${__dirname}/../../${filepath}`); + res.contentType(`${__dirname}/../../${filepath}`); res.send(prev); }); decorated[0](readResults); diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts index 10be791..9a408c8 100644 --- a/typescript/translucid/Translucid.ts +++ b/typescript/translucid/Translucid.ts @@ -55,8 +55,8 @@ class Translucid { }); } decorated.push((prev:any):void => { - console.log(`${__dirname}/../../${filepath}`); - // res.contentType(`${__dirname}/../../${filepath}`); + // console.log(`${__dirname}/../../${filepath}`); + res.contentType(`${__dirname}/../../${filepath}`); res.send(prev); }); From 220c6667a3458f79c7c8e2aca4350295ea26b550 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 21:55:04 +0200 Subject: [PATCH 57/75] typescript(translucid): 1.0.24 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index 814eb76..119c4a0 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.23", + "version": "1.0.24", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index ffd983b..1fccb2a 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.23", + "version": "1.0.24", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 6349cd444228ba3f8ea139ffb063baa96f4f0bca Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 22:14:51 +0200 Subject: [PATCH 58/75] typescript(translucid): i think i fixed it Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 11 ++++++----- typescript/translucid/Translucid.ts | 11 ++++++----- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 26b4b56..85d6479 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -30,7 +30,7 @@ class Translucid { // console.log(`Binded room with name ${i} and path ${object[i].file} with classes ${classes}`) } } - bind(path = "/", filepath = "", classes = []) { + bind(path = "/", filepath = "", classes = [], sendFiles = false) { this.app.get(path, async (req, res) => { const readResults = await read_1.read(filepath); const toRun = []; @@ -47,11 +47,12 @@ class Translucid { }); } decorated.push((prev) => { - // console.log(`${__dirname}/../../${filepath}`); - res.contentType(`${__dirname}/../../${filepath}`); - res.send(prev); + if (!sendFiles) + res.send(prev); + else + res.sendFile(prev); }); - decorated[0](readResults); + decorated[0](sendfiles ? readResults : `${__dirname}/../../${filepath}`); }); } } diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts index 9a408c8..de706fd 100644 --- a/typescript/translucid/Translucid.ts +++ b/typescript/translucid/Translucid.ts @@ -35,7 +35,7 @@ class Translucid { // console.log(`Binded room with name ${i} and path ${object[i].file} with classes ${classes}`) } } - bind(path:string = "/", filepath:string = "", classes:Array = []):void{ + bind(path:string = "/", filepath:string = "", classes:Array = [],sendFiles:boolean=false):void{ this.app.get(path, async (req, res)=> { const readResults = await read(filepath); const toRun:Array = []; @@ -55,12 +55,13 @@ class Translucid { }); } decorated.push((prev:any):void => { - // console.log(`${__dirname}/../../${filepath}`); - res.contentType(`${__dirname}/../../${filepath}`); - res.send(prev); + if (!sendFiles) + res.send(prev); + else + res.sendFile(prev); }); - decorated[0](readResults); + decorated[0](sendfiles?readResults:`${__dirname}/../../${filepath}`); }); } } From 53351b93c90bea22eb2284aa6427c308160961f5 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 22:15:02 +0200 Subject: [PATCH 59/75] typescript(translucid): 1.0.25 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index 119c4a0..3994f15 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.24", + "version": "1.0.25", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index 1fccb2a..809b968 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.24", + "version": "1.0.25", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 9afe56a0387414899c3bb2b72066b05c8239f8ae Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 22:18:43 +0200 Subject: [PATCH 60/75] typescript(translucid): added sendFiles option to json Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 9 +++++---- typescript/translucid/Translucid.ts | 8 ++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 85d6479..1bb5750 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -25,12 +25,13 @@ class Translucid { const object = JSON.parse(json); for (let i in object) { const classes = object[i].classes || []; - this.bind(i, object[i].file, classes); - //gotta comment this later - // console.log(`Binded room with name ${i} and path ${object[i].file} with classes ${classes}`) + const sendAsFiles = object[i].sendFiles; + if (sendFiles != false) + sendFiles = true; + this.bind(i, object[i].file, classes, sendFiles); } } - bind(path = "/", filepath = "", classes = [], sendFiles = false) { + bind(path = "/", filepath = "", classes = [], sendFiles = true) { this.app.get(path, async (req, res) => { const readResults = await read_1.read(filepath); const toRun = []; diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts index de706fd..3fee2a9 100644 --- a/typescript/translucid/Translucid.ts +++ b/typescript/translucid/Translucid.ts @@ -30,12 +30,12 @@ class Translucid { for (let i in object){ const classes = object[i].classes || []; - this.bind(i,object[i].file,classes); - //gotta comment this later - // console.log(`Binded room with name ${i} and path ${object[i].file} with classes ${classes}`) + const sendAsFiles = object[i].sendFiles; + if (sendFiles != false) sendFiles = true; + this.bind(i,object[i].file,classes,sendFiles); } } - bind(path:string = "/", filepath:string = "", classes:Array = [],sendFiles:boolean=false):void{ + bind(path:string = "/", filepath:string = "", classes:Array = [],sendFiles:boolean=true):void{ this.app.get(path, async (req, res)=> { const readResults = await read(filepath); const toRun:Array = []; From 4357da589aec0fd381f479d889e388b6e7cd8b05 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 22:18:59 +0200 Subject: [PATCH 61/75] typescript(translucid): 1.0.26 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index 3994f15..56a8465 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.25", + "version": "1.0.26", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index 809b968..ba809a0 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.25", + "version": "1.0.26", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 190a9f8e12ed8501f3ee796282008b462856ba51 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 22:21:31 +0200 Subject: [PATCH 62/75] typescript(translucid): fixed undefined Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 2 +- typescript/translucid/Translucid.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 1bb5750..5ea99d6 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -25,7 +25,7 @@ class Translucid { const object = JSON.parse(json); for (let i in object) { const classes = object[i].classes || []; - const sendAsFiles = object[i].sendFiles; + const sendFiles = object[i].sendFiles; if (sendFiles != false) sendFiles = true; this.bind(i, object[i].file, classes, sendFiles); diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts index 3fee2a9..2cb5110 100644 --- a/typescript/translucid/Translucid.ts +++ b/typescript/translucid/Translucid.ts @@ -30,7 +30,7 @@ class Translucid { for (let i in object){ const classes = object[i].classes || []; - const sendAsFiles = object[i].sendFiles; + const sendFiles = object[i].sendFiles; if (sendFiles != false) sendFiles = true; this.bind(i,object[i].file,classes,sendFiles); } From 19a261729f796cba15a7f371b0cea2e51b0658f6 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 22:21:39 +0200 Subject: [PATCH 63/75] typescript(translucid): 1.0.27 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index 56a8465..822e7ec 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.26", + "version": "1.0.27", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index ba809a0..f9565a5 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.26", + "version": "1.0.27", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 6efde2655e24efdaf8ab0b4d0c364f0ed4bed656 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 22:23:50 +0200 Subject: [PATCH 64/75] typescript(translucid): Fixed 'UnhandledPromiseRejectionWarning: TypeError: Assignment to constant variable.' Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 2 +- typescript/translucid/Translucid.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 5ea99d6..c58be4a 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -25,7 +25,7 @@ class Translucid { const object = JSON.parse(json); for (let i in object) { const classes = object[i].classes || []; - const sendFiles = object[i].sendFiles; + let sendFiles = object[i].sendFiles; if (sendFiles != false) sendFiles = true; this.bind(i, object[i].file, classes, sendFiles); diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts index 2cb5110..2221a41 100644 --- a/typescript/translucid/Translucid.ts +++ b/typescript/translucid/Translucid.ts @@ -30,7 +30,7 @@ class Translucid { for (let i in object){ const classes = object[i].classes || []; - const sendFiles = object[i].sendFiles; + let sendFiles = object[i].sendFiles; if (sendFiles != false) sendFiles = true; this.bind(i,object[i].file,classes,sendFiles); } From ccc239c393b612e6548471dcd708d9ed904a99d2 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 22:24:09 +0200 Subject: [PATCH 65/75] typescript(translucid): 1.0.28 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index 822e7ec..81c7a3a 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.27", + "version": "1.0.28", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index f9565a5..71b5612 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.27", + "version": "1.0.28", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 1cdc900c5526f99110a842a7dab95e1f07c91dab Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 22:26:54 +0200 Subject: [PATCH 66/75] typescript(translucid): Fixed: 'UnhandledPromiseRejectionWar typescript(translucid): ning: ReferenceError: sendfiles is not defined' Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 2 +- typescript/translucid/Translucid.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index c58be4a..25d4b35 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -53,7 +53,7 @@ class Translucid { else res.sendFile(prev); }); - decorated[0](sendfiles ? readResults : `${__dirname}/../../${filepath}`); + decorated[0](sendFiles ? readResults : `${__dirname}/../../${filepath}`); }); } } diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts index 2221a41..211f729 100644 --- a/typescript/translucid/Translucid.ts +++ b/typescript/translucid/Translucid.ts @@ -61,7 +61,7 @@ class Translucid { res.sendFile(prev); }); - decorated[0](sendfiles?readResults:`${__dirname}/../../${filepath}`); + decorated[0](sendFiles?readResults:`${__dirname}/../../${filepath}`); }); } } From 1ff1cff2f7722e2438ffca3b985340e4d8991fc6 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 22:27:03 +0200 Subject: [PATCH 67/75] typescript(translucid): 1.0.29 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index 81c7a3a..dc12efc 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.28", + "version": "1.0.29", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index 71b5612..6b28149 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.28", + "version": "1.0.29", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 052fe299beb645af51e6391958610d0fd62ed579 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 22:28:55 +0200 Subject: [PATCH 68/75] typescript(translucid): fixed wrong order in ternary operator Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 2 +- typescript/translucid/Translucid.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 25d4b35..a725411 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -53,7 +53,7 @@ class Translucid { else res.sendFile(prev); }); - decorated[0](sendFiles ? readResults : `${__dirname}/../../${filepath}`); + decorated[0]((!sendFiles) ? readResults : `${__dirname}/../../${filepath}`); }); } } diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts index 211f729..667d9c9 100644 --- a/typescript/translucid/Translucid.ts +++ b/typescript/translucid/Translucid.ts @@ -61,7 +61,7 @@ class Translucid { res.sendFile(prev); }); - decorated[0](sendFiles?readResults:`${__dirname}/../../${filepath}`); + decorated[0]((!sendFiles)?readResults:`${__dirname}/../../${filepath}`); }); } } From 76430ff69161277e1debdd618cfc383742dd22e6 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 22:29:23 +0200 Subject: [PATCH 69/75] typescript(translucid): 1.0.30 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index dc12efc..b4b3585 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.29", + "version": "1.0.30", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index 6b28149..ae0b257 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.29", + "version": "1.0.30", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 2f229fb449bfaca508651129dfe16d703aa6f6d9 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 22:35:44 +0200 Subject: [PATCH 70/75] typescript(translucid): fixed forbbiden sendFile Signed-off-by: prescientmoon --- typescript/translucid/Translucid.js | 4 +++- typescript/translucid/Translucid.ts | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index a725411..164c70a 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -1,7 +1,9 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const express = require('express'); +const path = require('path'); const read_1 = require("./read"); +const dir = path.dirname(require.main.filename); function containsAny(array, keys) { for (let i = 0; i < keys.length; i++) { if (array.indexOf(keys[i]) != -1) @@ -53,7 +55,7 @@ class Translucid { else res.sendFile(prev); }); - decorated[0]((!sendFiles) ? readResults : `${__dirname}/../../${filepath}`); + decorated[0]((!sendFiles) ? readResults : `${dir}/${filepath}`); }); } } diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts index 667d9c9..81a9baf 100644 --- a/typescript/translucid/Translucid.ts +++ b/typescript/translucid/Translucid.ts @@ -1,6 +1,9 @@ const express = require('express'); +const path = require('path'); import {read} from "./read"; +const dir = path.dirname(require.main.filename); + interface Middleware{ name:string; keys:Array; @@ -61,7 +64,7 @@ class Translucid { res.sendFile(prev); }); - decorated[0]((!sendFiles)?readResults:`${__dirname}/../../${filepath}`); + decorated[0]((!sendFiles)?readResults:`${dir}/${filepath}`); }); } } From 8d274609bbdddb793591e29ca34e4171049bbe4a Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Tue, 22 Jan 2019 22:35:53 +0200 Subject: [PATCH 71/75] typescript(translucid): 1.0.31 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index b4b3585..c65cc76 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.30", + "version": "1.0.31", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index ae0b257..49caf83 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.30", + "version": "1.0.31", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From 56a27a039847dae2b7296c1d654f58b3b3c1f9f6 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Mon, 28 Jan 2019 20:01:16 +0200 Subject: [PATCH 72/75] typescript(translucid): updated docs Signed-off-by: prescientmoon --- typescript/translucid/README.md | 46 +++++++++++++++++++++++------ typescript/translucid/Translucid.js | 2 +- typescript/translucid/Translucid.ts | 2 +- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/typescript/translucid/README.md b/typescript/translucid/README.md index 12fa6b4..1a68e39 100644 --- a/typescript/translucid/README.md +++ b/typescript/translucid/README.md @@ -22,12 +22,6 @@ The ".QuickServer" method return many useful objects: ``` const {app,server,connect,translucid} = trans.QuickServer(8000); ``` -"Connect" is a promise that resolves when the server starts listening to the port: -``` -connect.then(() => { - console.log("Listening on port 8000!"); -}); -``` The translucid object can be used to make file bindings: ``` translucid.bind("/","client/index.html",["myId"]); @@ -38,9 +32,43 @@ translucid.use({ name:"my middleware", keys:["myid"], run:(prev,req,res,next) => { - //prev is the data that is going to be sent to the client - //(it might for example be the index.html file); - next(`${prev}
string added by a middleware`); + next(`${prev}
string added by a middleware`);//passing the argument is optional } }); ``` + + +You can make a folder public like this: +``` +translucid.public(`client`); +``` + +You can read bindings from a file: +``` +translucid.bindJSON(`data/files.json`); +``` +And in files.json: +``` +{ + "/articles":{ + "file":"client/articles.html", + "classes":["*"] + }, + "/":{ + "file":"client/start.html", + "classes":["*"] + }, + "/start":{ + "file":"client/start.html", + "classes":["*"] + } +} +``` + +The QuickServer returns: * translucid => the basic translucid object + * express => the express module + * http => the http module + * server => instance of http.Server() + * connect => a promise that resolves when the server is listening to the specified port + +Other utilities in translucid: * read => read a file diff --git a/typescript/translucid/Translucid.js b/typescript/translucid/Translucid.js index 164c70a..f0da46e 100644 --- a/typescript/translucid/Translucid.js +++ b/typescript/translucid/Translucid.js @@ -45,7 +45,7 @@ class Translucid { const decorated = []; const expressArgs = [req, res]; for (let i = 0; i < toRun.length; i++) { - decorated.push((prev) => { + decorated.push((prev = (!sendFiles) ? readResults : `${dir}/${filepath}`) => { toRun[i](prev, ...expressArgs, decorated[i + 1]); }); } diff --git a/typescript/translucid/Translucid.ts b/typescript/translucid/Translucid.ts index 81a9baf..2aba128 100644 --- a/typescript/translucid/Translucid.ts +++ b/typescript/translucid/Translucid.ts @@ -53,7 +53,7 @@ class Translucid { const expressArgs = [req, res]; for (let i = 0; i < toRun.length; i++) { - decorated.push((prev:any):void => { + decorated.push((prev:any=(!sendFiles)?readResults:`${dir}/${filepath}`):void => { toRun[i](prev, ...expressArgs, decorated[i + 1]); }); } From 647489611921e15cbac065b9d77a186ca53f12ab Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Mon, 28 Jan 2019 20:02:27 +0200 Subject: [PATCH 73/75] typescript(translucid): 1.1.0 Signed-off-by: prescientmoon --- typescript/translucid/package-lock.json | 2 +- typescript/translucid/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/typescript/translucid/package-lock.json b/typescript/translucid/package-lock.json index c65cc76..e89ab50 100644 --- a/typescript/translucid/package-lock.json +++ b/typescript/translucid/package-lock.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.31", + "version": "1.1.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/typescript/translucid/package.json b/typescript/translucid/package.json index 49caf83..2800682 100644 --- a/typescript/translucid/package.json +++ b/typescript/translucid/package.json @@ -1,6 +1,6 @@ { "name": "translucid", - "version": "1.0.31", + "version": "1.1.0", "description": "A simple node library to bind files to requests", "main": "app.js", "scripts": { From aab92b9cb0eec4bbc831ba6d983043491cbd1684 Mon Sep 17 00:00:00 2001 From: Matei Adriel Date: Mon, 28 Jan 2019 20:05:35 +0200 Subject: [PATCH 74/75] typescript(translucid): hopefully fixed markup Signed-off-by: prescientmoon --- typescript/translucid/README.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/typescript/translucid/README.md b/typescript/translucid/README.md index 1a68e39..7465ab7 100644 --- a/typescript/translucid/README.md +++ b/typescript/translucid/README.md @@ -65,10 +65,12 @@ And in files.json: } ``` -The QuickServer returns: * translucid => the basic translucid object - * express => the express module - * http => the http module - * server => instance of http.Server() - * connect => a promise that resolves when the server is listening to the specified port +The QuickServer returns: +* translucid => the basic translucid object +* express => the express module +* http => the http module +* server => instance of http.Server() +* connect => a promise that resolves when the server is listening to the specified port -Other utilities in translucid: * read => read a file +Other utilities in translucid: +* read => read a file From 92daf986fab888a952b39b0346899c745d74d1dd Mon Sep 17 00:00:00 2001 From: prescientmoon Date: Tue, 28 May 2024 01:55:02 +0200 Subject: [PATCH 75/75] typescript(translucid): Added movement notice to readme [skip-ci] Signed-off-by: prescientmoon --- typescript/translucid/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/typescript/translucid/README.md b/typescript/translucid/README.md index 7465ab7..fdfb850 100644 --- a/typescript/translucid/README.md +++ b/typescript/translucid/README.md @@ -1,3 +1,4 @@ +# 🚧 This repo has been moved to [prescientmoon/Translucid](https://github.com/prescientmoon/Translucid) 🚧 # Translucid A simple node.js library to bind files to requests