Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- express() methods - app.use(method())
- 1) express.json() : json format a data get korar jonno
- 2) express.raw() : stream or buffer format a data get korar jonno
- 3) express.text() : text format a data get korar jonno
- 4) express.urlencoded() : form data hisebe data get krtay hole
- 5) express.static() : static kunu file theke data read korar jonno , example : test.tx or test.html file
- 6) express.route() : routing ar jonno
- Application properties :
- 1) app.locals : app ar under a local variable declare ar jonno
- 2) app.mounthpath : mountpath janar jonno , parent path ta janar jonno use hoy
- Events
- 1) mount : The mount event is fired on a sub-app, when it is mounted on a parent app.
- Mehotds :
- 1) app.all() : jaykunu method a hit korlay URL ar sathe millay call hobhe, post ,get ,path any type of method ,
- it's like global method
- 2) app.delete : kunu kichu delete korar jonno use hoy
- 3) app.disable() : express ar kunu setting k disable krtay use hoy , like case sensitive routing
- 4) app.enable() : express ar kunu setting k enable krtay use hoy , like case sensitive routing
- 5) app.enabled('') : kunu setting enable ki na check kortay use hoy , true or false return more ai method
- 6) app.disabled('') : kunu setting disable ki na check kortay use hoy , true or false return more ai method
- 7) app.set() : app.set diye kun value set krlay app.get() diye access kora jabe
- 8) app.get() : data get korar jonno use hoy
- 9) app.listen() : server start korar jonno
- 10) app.Method() : Routes an HTTP request, where METHOD is the HTTP method of the request, such as GET, PUT, POST, and so on, in lowercase. Thus, the actual methods are app.get(), app.post(), app.put(), and so on.
- 11) app.param() : Add callback triggers to route parameters,a kind of middleware of request
- 12 app.path() : Returns the canonical path of the app, a string.
- 13) app.post() : kunu kichu post korar jonno
- 14 ) app.put() : for update any data
- 15 ) app.use() :
- 16) app.route() : Returns an instance of a single route, which you can then use to handle HTTP verbs with optional middleware. Use app.route() to avoid duplicate route names (and thus typo errors).
- 17) app.engine() : model view controller ar jonno use hoy
- Request Object
- 1) req.baseUrl() : router ar baseUrl ta pawa jabe , j route a achi ai router base ta return korbay
- 2) req.originalUrl () : original URL ta kokono change hobhe an
- 3) req.url() : URL ta change hobhe sub URL a gele
- 4) req.path() : path ta pawa jabe without query parameter
- 5) req.hostname() : local a run krlay localhost hobhe hostname
- 6) req.method() : kun method a request kora hoise ai method ar name ta capital letter a pawa jabe
- 7) req.protocol : j protocol a hit kora hoise ,example : HTTP,https
- 8) req.params() : request ar parameter ar value pawa jabe
- 9) req.query() : request ar query object ta return more
- 10 ) req.body() : request ar body data ta object ar maddomay return korbay , format ta bole ditay hobhe , like json hole : app.use(express.json());
- 11) req.cookies() : cookies ar data pawa jabe
- 12) req.secure() : request ta secure ki na check korbay . HTTP hole false and https dile true asbay
- 13) req.app() : different file a app use krtay chailay req.app() diye kora jabe
- 14) req.route : routing ar detail return krbay
- 15) req.accepts(value) : kun format a client data accept kore check korar jonno use hoy . example : req.accepts('html')
- , req.accepts('application/json')
- 16) req.get(value) : kunu header ar value ber korar jonno use hoy
- Response Object
- properties :
- 1) res.app : app ar reference ta return kore
- 2) res.headerSent : response send kora hoye gele true hobhe otherwise false hobhe
- 3) res.locals : local variable , kun page render korar somoy data patanur jonno use hoy
- Method :
- 4) res.cookie(name,value) : cookie set hobhe
- 5) res.clearCookie() : cookie clear ar jonno
- 6) res.end() : response k end kore dey .(data chara send kortay hole res.end() , data send kortay hole res.send()
- 7) res.send() : HTTP request sent kore with data
- 8) res.json({ user: 'tobi' }) : json a response fatanur jonno
- 9) res.status() : status set korar jonno (client ar kache send hobhe , aita sudu status code set krbay )
- 10 ) res.sendStatus() : status code ta set hoye data hisebe client ar kache chole jabe
- 11) res.render() : render specific kunu view k render kore
- 12) res.format() : client j format a data require krtayse oi format a data ready kore dibe , single response function diye amra client ar requirement content type wise data send krtay parbo
- 13) res.location() : ekta URL send korbay , tokon client bujbay oi URL a redirect krtay hobhe
- 14) res.redirect() : directly redirect kore dibe client k
- 15) res.get() : HTTP header ar name return krbay
- 16) res.set() : header set krtay parbo
- MIDDLEWARE
- 1) middleware ekta function
- 2) execute any code
- 3) can change req res object
- 4) can end request response cycle
- 5) call next middleware by next()
- 6) throw and catch errors
- Types of middleware :
- 1) Application-level middleware
- 2) Router-level middleware
- 3) Error-handling middleware
- 4) Built-in middleware. example : app.use(express.json())
- 5) Third-party middleware example : app.use(cookieParser())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement