majidai
A simple and light web framework for nodejs with less then 50KB.
It does not install extra packages.
"majidai" is a configuration centralized webframework.
It supports http,https and http2 protocol by default.
See here for Detail - https://dakc.github.io/majidai.html
※日本語の場合は、Qiitaの記事を参考にしてください。
1. Installation
npm install majidai
2. Run
const majidai = ;const server = ;serverstart;
open browser and access to http://your_ip_address
It should show following page.
3. Serve static files
"majidai" is a configuration centralized framework. Below is a example for serving static files. Please refer to comments for each parameter to know about their function.
const majidai = ; // configurationconst config = isDebug: true // it will show the access log and error log on console directoryIndex: "index.html" // default page to display when directory is accessed directoryTraversal: true // it will list all the files if no directoryIndex was found (Default: false) http: port: 80 // default port to listen request documentRoot: '/var/www/html' // files below this directory will be accessible through web ; // pass above configuration while creating instanceconst server = config;serverstart;
Put "index.html" below "documentRoot" and access to http://your_ip_address/
Sample
This sample shows the way to handle data sent by client. Refer to comments for detail information.
// import majidaiconst majidai = ; // create instanceconst server = isDebug: true; // define POST routing at '/home'// param enclosed between {} can be accessed as GET parameterserver; // start serverserverstart;
4. Docker
try with docker
docker run -it --rm -p 80:80 dakc/majidai npx /data/server.js
Open Browser and access to access to http://your_ip_address
See here for complete Documentaion
Release information
Sept 6th, 2020
- ver 2.1.2
- added "isDebug" property to config. By default it is set to off. If this property is set "true" then, majidai will show access log and error log on console.
const config = isDebug: false
July 27th, 2020
- ver 2.1.0
- added support for streaming audio and video
- added directory traversal feature. By default it is set to off. We can set on by passing following parameter
const config = directoryTraversal: true
July 24th, 2020
- ver 2.0.0
- added support for https including http2 protocol. Below will be the configuration for creating https server.
const config = https: listen:true // listen to https server http2:true // activate http2 pfx: "/path/to/certificate_pkcs12.pfx" // path to certificate at pkcs12 format passphrase: "if_password_was_set" // password if set while creating certificate
- removed multipart/form-data support by default
June 21st, 2020
- ver 2.0.0-alpha
- removed cookie,session,logging functions
- added stdout & stderr event emitter
- merged "data" object to nodejs native request object
- merged "respond" object to nodejs native response object
- changed "customRouting" to "listen" for server propery
- changed "plainText" to "plain" for respond propery
Oct 24th, 2019
- added customRouting property which will help to listen multiple http methods for single route. The first argument should be an object having following format
method: 'GET' 'POST' // array of http METHODS routing:'/dashboard' // path