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
|
# Translucid
|
||||||
A simple node library to bind files to requests
|
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,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"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": {
|
"accepts": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz",
|
||||||
|
|
|
@ -7,17 +7,17 @@
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "github",
|
||||||
"url": "a"
|
"url": "https://github.com/Mateiadrielrafael/Translucid"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"translucid"
|
"translucid",
|
||||||
|
"express",
|
||||||
|
"server"
|
||||||
],
|
],
|
||||||
"author": "Matei Adriel",
|
"author": "Matei Adriel",
|
||||||
"license": "ISC",
|
"license": "Apache License 2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/node": "^10.12.18",
|
|
||||||
"express": "^4.16.4"
|
"express": "^4.16.4"
|
||||||
},
|
}
|
||||||
"devDependencies": {}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue