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": {} + } }