A minimal web framework designed to be lightweight, multi-threaded, and async, implemented in Typescript
- Since Ash.ts uses the Zweit build system, make sure to have it
- Clone the repo and cd into the folder
- run
zweit.py make.zw
to build the framework orzweit.py make.zw -all
to build every file one by one
port: the port which the server listens to
protocol: http/https
pool_sz: the size of the pool, the number of threads
exts: object representing extensions and their content type header
there are currently three ways to configure Ash:
By specifying a JSON file to the Config class you can load configuration from a JSON file:
const Config = require('ash').Config;
var my_conf = new Config();
my_conf.readJSON("path/to/the/file");
By setting enviroment variables you can load the configuration with the readENV function:
const Config = require('ash').Config;
var my_conf = new Config();
my_conf.readENV();
Or you can just use variables declared in your code instead:
const Config = require('ash').Config;
var my_conf = new Config();
const port = 8080;
const protocol = "http";
const pool_sz = 6;
const exts = {
".html": "text/html",
".css": "text/css"
};
my_conf.readVARS(port, protocol, pool_sz, exts)
You can use the profiler to store configuration and use them later, for example:
const Ash = require('ash');
var Profiler = new Ash.Profiler();
const my_server = new Ash.asherver(Profiler.getProfile('dev'));
//<configuration + server initialization>
my_server.router.route('/', function(request, response) {
response.write('Hello, World!');
response.end();
});
to serve static files, put them in the ./resources
directory. and make sure it's respective extension is in your config exts
Thanks to Prokop Schield for doing some refactoring when i was just starting in typescript