1.0.1 • Published 2 years ago

@aylias/quickserve v1.0.1

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

QuickServe wraps the express functions into a simpler to use format, allowing you to use less lines of code to achieve the same result.

const qs = require('@aylias/quickserve')

const server = new qs(8055); // Create an instance of quickserve with the desired port

// Use get and post methods like normal
server.get('/', (req, res) => {
    res.writeHeader(200, { "Content-Type": "text/html" });
    res.write("<h1>You used a normal get method</h1>");
    res.end();
})

server.post('/', (req, res) => {
    res.writeHeader(200, { "Content-Type": "text/html" });
    res.write(`<h1>Your name is ${req.body.name}</h1>`);
    req.end();
})


// Automatically get and serve files of type html, css, json, and javascript
server.getHTML('/main', './main.html');
server.getCSS('/main.css', './main.css');
server.getJSON('/stats', './stats.json');
server.getJS('/main.js', './main.js');

server.serve();