1
Fork 0

typescript(fourjs): first commit

Signed-off-by: prescientmoon <git@moonythm.dev>
This commit is contained in:
Matei Adriel 2019-01-17 15:53:12 +02:00 committed by prescientmoon
parent 7dce9eb842
commit c19818b95b
Signed by: prescientmoon
SSH key fingerprint: SHA256:UUF9JT2s8Xfyv76b8ZuVL7XrmimH4o49p4b+iexbVH4
15 changed files with 736 additions and 0 deletions
typescript/fourjs/server

View file

@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const read_1 = require("../read");
class ShaderSender {
constructor(app, dir) {
this.app = app;
this.dir = dir;
}
async listen(data) {
for (let i in data) {
const text = await read_1.read(`./${data[i]}`);
this.app.get(`/${i}`, (req, res) => {
res.json({ text });
});
}
}
}
exports.ShaderSender = ShaderSender;

View file

@ -0,0 +1,14 @@
import {read} from "../read"
class ShaderSender{
constructor(public app,public dir:String){}
async listen(data:any){
for (let i in data){
const text = await read(`./${data[i]}`);
this.app.get(`/${i}`,(req,res) => {
res.json({text});
});
}
}
}
export {ShaderSender};

View file

@ -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;

View file

@ -0,0 +1,12 @@
const fs = require('fs');
function read(url:string):Promise<string>{
return new Promise((resolve,reject) => {
fs.readFile(`./${url}`,"utf8",(err,data) => {
if (err) reject(err);
resolve(data);
});
});
}
export {read};