ray-serve
Version:
A server development library for ray-net and ray-userland. ExpressJS based!
1 lines • 1.3 kB
JavaScript
;const express=require("express"),dns=require("dns"),os=require("os"),fs=require("ray-fs"),taken=require("ray-taken"),core=require("ray-core"),rayserveAuthors="Ray Voice and Anna Voice",rayserveVersion="v2.2.3";module.exports={value:0,app:express(),port:4e3,latency:0,hostname:"localhost",showPort:(e,t)=>{console.log(`Server is listening at ${e}:${t}`)},serveJSON:function(){var e=taken.take(arguments).getNodeNames().value[0];const s=taken.take(arguments).getObjArgs().value[0];var t=taken.take(arguments).getFuncArgs().value[0];const r=taken.take(arguments).getFuncArgs().value[1];return core.funcAnime(t),void 0===e&&core.lastWords("NodeName invalid! (/home, /about)"),this.app.get(e,(e,t)=>{core.sendJSON(t,s,this.latency,r)}),this},serveFile:function(e,s){var t=taken.take(arguments).getFuncArgs().value[0];const r=taken.take(arguments).getFuncArgs().value[1];return core.funcAnime(t),this.app.get(e,(e,t)=>{core.sendFile(t,s,this.latency,r)}),this},showRoot:function(e,t){return this.serveJSON("/",{Server:e,Version:t}),this},listen:function(e){e=core.argAssign(e,()=>{this.showPort(this.hostname,this.port)});this.app.listen(this.port,e)},getIPV4:function(r){return dns.lookup(os.hostname(),(e,t,s)=>{r(e,t,s)}),this},static:function(e){return this.app.use(express.static(e)),this}};