1
Fork 0
solar-conflux/typescript/translucid
Matei Adriel 6388e9cafb
typescript(translucid): added [] in keys in readme
Signed-off-by: prescientmoon <git@moonythm.dev>
2019-01-19 23:25:24 +02:00
..
.gitignore typescript(translucid): Initial commit 2019-01-19 20:41:18 +02:00
app.js typescript(translucid): first commit 2019-01-19 22:41:54 +02:00
LICENSE typescript(translucid): Initial commit 2019-01-19 20:41:18 +02:00
package-lock.json typescript(translucid): changed the readme 2019-01-19 23:23:09 +02:00
package.json typescript(translucid): changed the readme 2019-01-19 23:23:09 +02:00
QuickServer.js typescript(translucid): first commit 2019-01-19 22:41:54 +02:00
read.js typescript(translucid): first commit 2019-01-19 22:41:54 +02:00
README.md typescript(translucid): added [] in keys in readme 2019-01-19 23:25:24 +02:00
Translucid.js typescript(translucid): first commit 2019-01-19 22:41:54 +02:00

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");
    }
});