Nodejs-Web-Server
How to use
Nodejs-Web-Server is a wrapper around express.js, handlebars and jsonwebtoken.
Every app.listen method looks basically like this:
app
To specify the Port add PORT to the .env file together with the port number.
PORT=Port_number
Methods
-
GET
-
POST
-
STATIC
-
API
GET
app;
callbacks:
-
req
-
res
POST
app;
callbacks:
-
body
-
req
-
res
STATIC
app;
parameters
- path to static file in static directory (root)
API
app;
If the provided JWT-token is not valid, all callbacks will be null.
The JWT-secret is stored in an .env file under the tag SECRET:
SECRET=this_is_a_secret
callbacks:
-
decoded jwt token
-
body
-
req
-
res
Templating
nodejs-web-server also has a built-in templating engine built around handlebars. to use it, just type:
let template = app;
I would recommend this in use together with the GET method.
app;
Required Directories
all directories have to be in the app's root path
-
static (only required if you use static function)
-
views (only required if you use the templating engine)
MySQL-Query
To use the built in MySQL-Driver use
appdb
To use multiple SQL-Statements use
appdb
For more information visit nodejs-mysql-driver.