0.3.22 • Published 2 years ago

jsweb v0.3.22

Weekly downloads
11
License
MIT
Repository
github
Last release
2 years ago
  • jsWeb - Simple Web Server with Javascript

jsWeb is a program to simplify web api based on express development. After installed jsweb, just write the express request handle js file and put them to the correctly directlry. Start with command:

#+BEGIN_SRC sh

jsweb /path/to/site/home jsweb --site=/path/to/site/home --port=8888

#+END_SRC

  • Features

    • Everythings of web site in single folder.
    • Multiple port support, each port is a standalone process
    • Auto reload, Add/Modify/Delete api file doesn't need restart server
    • Async init script loaded before real api method load to prepare system like database object or connection
    • Https support
    • Virtual host support
    • Mustache template support buildin
    • Cluster support
    • Parameter URL support
    • TLS session resume support
  • Installation

#+BEGIN_SRC sh $ sudo npm install jsweb -g #+END_SRC

  • =jsweb= is not a nodejs module but a system tools to run your web.
  • Run the demos

#+BEGIN_SRC sh $ git clone https://github.com/jsplne/jsweb-demo $ jsweb jsweb-demo/static $ jsweb jsweb-demo/api-server $ jsweb jsweb-demo/vhost #+END_SRC

  • Namings

#+BEGIN_SRC sh name[(tag[;tag...])] #+END_SRC

** tags for port folder

- =https=  This is a https port

tags for root folder

- =api=   Root folder =.js= file treat as server side script, if =index.js= exists, website homepage will be the result of =index.js=

tags for inside folder

- =api=   Folder contain api script. all =.js= inside this folder will be called as api call, include subfolders.
- =param= Folder correspond URL position will be inteperate as req.params object member, folder name as the member name, URL path will be the value
- =final= Match rest of url after final tag as req.params.final

tags for api =.js= file

- GET    api will called for correspond http method, if omit, all method will called.
- POST
- PUT
- ... all valid HTTP method
  • Runtime data structure

System information share with request callback via : =req.jw=

#+BEGIN_SRC javascript req.jw = { app : // system object } #+END_SRC

  • Enable/Disable file

Set/clear file execute flag of files to enable/disable init file or web api file to be load.

  • Directory structure (single site)

See jsweb-demo

  • https certificate file generate

#+BEGIN_SRC shell cd /path/to/https-port/config $ openssl genrsa -out jsweb.key 1024 $ openssl req -new -key jsweb.key -out jsweb.ca $ openssl x509 -req -in jsweb.ca -signkey jsweb.key -out jsweb.cert #+END_SRC

  • Cluster support

Set port-config.json under the port folder with key/value: ="cluster" : true=

** port-config.json

#+BEGIN_SRC json { "bind" : "127.0.0.1", "cluster" : true, "tls" { "key" : "/path/to/key/file", default to "cert" : "/path/to/cert/file", "ca" : "/path/to/ca/file", "rejectUnauthorized" : true | false, "requestCert" : true | false } } #+END_SRC

- About parameter URL

- =api's= priority is higher than param =param= folder    -    -
- =index.js= under =param= folder will be called when url point to that folder
- =param= can set multiple level.
- =param= folder examples

  #+BEGIN_SRC sh
    /root/org(param)/user(param)/device(param)/index.js
    /root/org(param)/user(param)/device(param)/index.js
  #+END_SRC
  • About Views

    Put variables you want to reder within view to =res.locals= and =res.render(...)=

  • =req.jw= object
  • =req.jw.port.home=
  • =req.jw.port.port=
  • =req.jw.port.protocol=
  • =req.jw.port.tags=
  • =req.jw.port.config=
  • =req.jw.home=
  • =req.jw.root=
  • =req.jw.lib=
  • =req.jw.config=
  • =req.jw.hostname=
  • =/jsweb-config=

    • =debug= : true or fasle
    • =cluster= : true or fase
    • =public= : array
0.3.22

2 years ago

0.3.21

2 years ago

0.3.20

3 years ago

0.3.19

3 years ago

0.3.18

3 years ago

0.3.17

5 years ago

0.3.16

7 years ago

0.3.15

7 years ago

0.3.14

7 years ago

0.3.13

7 years ago

0.3.12

7 years ago

0.3.11

7 years ago

0.3.10

7 years ago

0.3.9

7 years ago

0.3.8

7 years ago

0.3.6

7 years ago

0.3.5

7 years ago

0.3.4

7 years ago

0.3.3

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.29

9 years ago

0.2.28

9 years ago

0.2.27

9 years ago

0.2.26

9 years ago

0.2.24

9 years ago

0.2.23

9 years ago

0.2.22

9 years ago

0.2.21

9 years ago

0.2.20

9 years ago

0.2.19

9 years ago

0.2.18

9 years ago

0.2.17

9 years ago

0.2.16

9 years ago

0.2.15

9 years ago

0.2.14

9 years ago

0.2.13

9 years ago

0.2.12

9 years ago

0.2.11

9 years ago

0.2.10

9 years ago

0.2.9

9 years ago

0.2.8

9 years ago

0.2.7

9 years ago

0.2.6

9 years ago

0.2.5

9 years ago

0.2.4

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.22

10 years ago

0.0.21

10 years ago

0.0.20

10 years ago

0.0.19

10 years ago

0.0.18

10 years ago

0.0.17

10 years ago

0.0.16

10 years ago

0.0.15

10 years ago

0.0.14

10 years ago

0.0.13

10 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago