0.3.2 • Published 4 years ago

javascriptpage v0.3.2

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Java Script Page

npm.io npm.io GitHub license

It can be installed as follows:

npm install --save javascriptpage

And you can start with: Import the module, set the port, and start with the start method.

const jsp = require("javascriptpage");
jsp.port = 3333;
jsp.start();

Then, as the server starts up, a public directory and a page directory will be created.

npm.io

The page directory is the path to the page sources. All .ejs files entered here are automatically registered in the URL.
The public directory is where static files such as js and css files are stored.

Route

The automatically created index.ejs page file can be accessed as follows. npm.io In addition, if you add test.ejs, you can access "localhost:3333/test.ejs".

And static files can be accessed through the /public path. npm.io

EJS built-in object

This is a basic object that can be used on all pages. | name | description | example | | ------- | ----------- | ------------------------------ | | method | http method | 'get', 'post', 'delete', 'put' | | request | request info object | { paramter, queryParameter, ... } | | request.paramter | Query parameter if get/delete. body parameter if post/put | {...} | | request.queryParameter | URL Query parameter | {...} | | request.namedRouteParameter | URL namedRouteParameter | {...} | | request.method | Same as above | | | request.baseUrl | baseUrl | '/greet' | | request.originalUrl | originalUrl | '/search?q=something' | | request.path | router path | '/users' | | request.isHttps | https yes or no | true | | request.subdomain | subdomain | 'ferrets' | | request.hostname | hostname | 'example.com' | | request.ip | request ip | '127.0.0.1' |

With Express

This is actually based on express and ejs. So, you can use express's method as it is.

const jsp = require("javascriptpage");
jsp.port = 3333;

jsp.use((req, res, next) => {
    //...
    next();
});

jsp.get("/foo", (req, res) => res.json({ msg: "boom" }));

jsp.start();

However, it is not recommended to use. Pages are the best.

0.3.2

4 years ago

0.3.1

4 years ago

0.1.0

4 years ago

0.3.0

4 years ago

0.2.1

4 years ago

0.2.0

4 years ago

0.2.6

4 years ago

0.2.3

4 years ago

0.2.2

4 years ago

0.2.5

4 years ago

0.2.4

4 years ago

0.0.0

4 years ago