---
# System prepended metadata

title: Untitled

---

To install a new npm package
```bash=
npm install something

Start a exp-generator -g
express --view=ejs nameofproject
cd nameofproject
npm install
# mac/linux
DEBUG=myapp:* npm start
# windows
set DEBUG=myapp:* & npm start
```

How to use variable in ejs
```
<% 'Scriptlet' tag, for control-flow, no output
<%_ ‘Whitespace Slurping’ Scriptlet tag, strips all whitespace before it
<%= Outputs the value into the template (HTML escaped)
<%- Outputs the unescaress project
```bash=
npm install expressped value into the template
<%# Comment tag, no execution, no output
<%% Outputs a literal '<%'
%> Plain ending tag
-%> Trim-mode ('newline slurp') tag, trims following newline
_%> ‘Whitespace Slurping’ ending tag, removes all whitespace after it
```

HTTP Method
* OPTIONS
* GET
* HEAD
* POST
* PUT
* DELETE
* TRACE
* CONNECT

Get parameters in backend
```javascript=
req.body // post
req.query //get
req.params //path
```

Cookie
https://zh.wikipedia.org/wiki/Cookie

```javascript=
res.cookie('JWT', token); // set cookie
req.cookies.JWT // use cookie
```

JWT
https://jwt.io/
https://github.com/auth0/node-jsonwebtoken

Github
https://github.com/charlie890414/myapp