typescript(translucid): changed the readme
Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
parent
a098fe038e
commit
1b388a05d1
|
@ -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");
|
||||
}
|
||||
});
|
||||
```
|
||||
|
|
5
typescript/translucid/package-lock.json
generated
5
typescript/translucid/package-lock.json
generated
|
@ -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",
|
||||
|
|
|
@ -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": {}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue