Skip to content

Commit c930c61

Browse files
committed
Docs v1.0.4
Documentation update for v1.0.4
1 parent 9873f17 commit c930c61

6 files changed

Lines changed: 260 additions & 40 deletions

File tree

docs/source/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# The short X.Y version
2727
version = ''
2828
# The full version, including alpha/beta/rc tags
29-
release = '1.0.2'
29+
release = '1.0.4'
3030

3131

3232
# -- General configuration ---------------------------------------------------

docs/source/cookies.rst

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ Usage
4949

5050
.. code:: javascript
5151
52-
secureCookie.framework(response, "foo", "bar");
52+
const secureCookie = new blockade.SecureCookie();
53+
secureCookie.framework(response, "foo", "bar");
5354
5455
*Default Set-Cookie HTTP response header:*
5556

@@ -67,29 +68,26 @@ options:
6768

6869
- ``name`` - set the cookie name *(string, No default value)*
6970
- ``value`` - set the cookie value *(string, No default value)*
70-
- ``path`` - set the Path attribute, e.g. ``path=“/secure`` *(string,
71+
- ``path`` - set the Path attribute, e.g. ``path=“/blockade`` *(string,
7172
default=“/”)*
7273
- ``secure`` - set the Secure flag *(bool, default=True)*
7374
- ``httpOnly`` - set the HttpOnly flag *(bool, default=True)*
7475
- ``sameSite`` - set the SameSite attribute,
75-
e.g. ``SameSite.LAX`` *(bool / enum, options:*
76-
``blockade.SameSite.Strict``, ``blockade.SameSite.Lax`` *or*
77-
``False``, *default=blockade.SameSite.Lax)*
76+
e.g. ``{value: "Strict" }``, ``{value: "Lax" }`` *or*
77+
``False`` *default={value: "Lax" }*
7878
- ``expires`` - set the Expires attribute with the cookie expiration in
7979
hours, e.g. ``expires=1`` *(number / bool, default=False)*
8080

8181

82-
.. _example-3:
83-
8482
**Example:**
8583

8684
.. code:: javascript
8785
88-
const blockade = require("blockade");
86+
const blockade = require("blockade");
8987
90-
const secureCookie = new blockade.SecureCookie({
91-
expires: 1,
92-
sameSite: blockade.SameSite.Strict
93-
});
88+
const secureCookie = new blockade.SecureCookie({
89+
sameSite: { value: "Strict" },
90+
expires: 1
91+
});
9492
95-
secureCookie.framework(response, "foo", "bar");
93+
secureCookie.framework(response, "foo", "bar");

docs/source/frameworks.rst

Lines changed: 222 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Cookies
6565
Coookies
6666
~~~~~~~~
6767

68-
``ecureCookie.adonis(response, "foo", "bar")``
68+
``ecureCookie.adonis(response, name, value)``
6969

7070

7171
**Example:**
@@ -138,6 +138,56 @@ Cookies
138138
139139
. . .
140140
141+
Fastify
142+
--------
143+
144+
Headers
145+
~~~~~~~~
146+
147+
``secureHeaders.fastify(reply)``
148+
149+
150+
**Example:**
151+
152+
.. code:: javascript
153+
154+
const fastify = require("fastify")();
155+
156+
const blockade = require("blockade");
157+
const secureHeaders = new blockade.SecureHeaders();
158+
159+
. . .
160+
161+
fastify.addHook("preHandler", async (request, reply) => {
162+
secureHeaders.fastify(reply);
163+
});
164+
165+
. . .
166+
167+
Cookies
168+
~~~~~~~~
169+
170+
``secureCookie.fastify(reply, name, value)``
171+
172+
173+
**Example:**
174+
175+
.. code:: javascript
176+
177+
const fastify = require("fastify")();
178+
179+
const blockade = require("blockade");
180+
const secureCookie = new blockade.SecureCookie();
181+
182+
. . .
183+
184+
fastify.get("/", function(request, reply) {
185+
secureCookie.fastify(reply, "foo", "bar");
186+
reply.send({ blockade: true });
187+
});
188+
189+
. . .
190+
141191
hapi
142192
------
143193

@@ -308,7 +358,7 @@ Headers
308358
Cookies
309359
~~~~~~~~
310360

311-
``secureCookie.nest(res, 'foo', 'bar')``
361+
``secureCookie.nest(res, name, value)``
312362

313363

314364
**Example:**
@@ -331,6 +381,124 @@ Cookies
331381
}
332382
}
333383
384+
Polka
385+
--------
386+
387+
Headers
388+
~~~~~~~
389+
390+
``secureHeaders.polka(res)``
391+
392+
393+
**Example:**
394+
395+
.. code:: javascript
396+
397+
const polka = require("polka");
398+
const blockade = require("blockade");
399+
const secureHeaders = new blockade.SecureHeaders();
400+
401+
function headers(req, res, next) {
402+
secureHeaders.polka(res);
403+
next();
404+
}
405+
406+
polka()
407+
.use(headers)
408+
.get("/", (req, res) => {
409+
res.end(`Blockade`);
410+
})
411+
.listen(3000, err => {
412+
if (err) throw err;
413+
console.log(`> Running on localhost:3000`);
414+
});
415+
416+
417+
418+
Cookies
419+
~~~~~~~~
420+
421+
``secureCookie.polka(res, name, value)``
422+
423+
424+
**Example:**
425+
426+
.. code:: javascript
427+
428+
const polka = require("polka");
429+
const blockade = require("blockade");
430+
const secureCookie = new blockade.SecureCookie();
431+
432+
polka()
433+
.get("/", (req, res) => {
434+
secureCookie.polka(res, "foo", "bar");
435+
res.end(`Blockade`);
436+
})
437+
.listen(3000, err => {
438+
if (err) throw err;
439+
console.log(`> Running on localhost:3000`);
440+
});
441+
442+
443+
restify
444+
--------
445+
446+
Headers
447+
~~~~~~~
448+
449+
``secureHeaders.restify(res)``
450+
451+
452+
**Example:**
453+
454+
.. code:: javascript
455+
456+
var restify = require("restify");
457+
const blockade = require("blockade");
458+
const secureHeaders = new blockade.SecureHeaders();
459+
460+
function respond(req, res, next) {
461+
res.send("Blockade");
462+
next();
463+
}
464+
465+
function headers(req, res, next) {
466+
secureHeaders.restify(res);
467+
next();
468+
}
469+
470+
. . .
471+
472+
var server = restify.createServer();
473+
server.pre(headers);
474+
server.get("/", respond);
475+
476+
Cookies
477+
~~~~~~~~
478+
479+
``secureCookie.restify(res, name, value)``
480+
481+
482+
**Example:**
483+
484+
.. code:: javascript
485+
486+
var restify = require("restify");
487+
const blockade = require("blockade");
488+
const secureCookie = new blockade.SecureCookie();
489+
490+
function respond(req, res, next) {
491+
secureCookie.restify(res, "foo", "bar");
492+
res.send("Blockade");
493+
next();
494+
}
495+
496+
. . .
497+
498+
var server = restify.createServer();
499+
server.get("/", respond);
500+
501+
334502
Sails
335503
--------
336504

@@ -363,7 +531,7 @@ Headers
363531
Cookies
364532
~~~~~~~~
365533

366-
``secureCookie.sails(res, "foo", "bar")``
534+
``secureCookie.sails(res, name, value)``
367535

368536

369537
**Example:**
@@ -378,4 +546,54 @@ Cookies
378546
secureCookie.sails(res, "foo", "bar");
379547
return res.send("Blockade");
380548
}
381-
};
549+
};
550+
551+
552+
Total.js
553+
---------
554+
555+
Headers
556+
~~~~~~~
557+
558+
``secureHeaders.total(response)``
559+
560+
561+
**Example:**
562+
563+
.. code:: javascript
564+
565+
const blockade = require("blockade");
566+
const secureHeaders = new blockade.SecureHeaders();
567+
568+
exports.install = function() {
569+
ROUTE("/", view_index);
570+
};
571+
572+
function view_index() {
573+
var response = this;
574+
secureHeaders.total(response);
575+
response.view("index");
576+
}
577+
578+
Cookies
579+
~~~~~~~~
580+
581+
``secureCookie.total(response, name, value)``
582+
583+
584+
**Example:**
585+
586+
.. code:: javascript
587+
588+
const blockade = require("blockade");
589+
const secureCookie = new blockade.SecureCookie();
590+
591+
exports.install = function() {
592+
ROUTE("/", view_index);
593+
};
594+
595+
function view_index() {
596+
var response = this;
597+
secureCookie.total(response, "foo", "bar");
598+
response.view("index");
599+
}

docs/source/headers.rst

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ Additional information
8181
Usage
8282
^^^^^^^
8383

84-
``secureHeaders.framework(response)``
84+
.. code:: javascript
85+
86+
const secureHeaders = new blockade.SecureHeaders();
87+
secureHeaders.framework(response);
88+
8589
8690
**Default HTTP response headers:**
8791

@@ -99,26 +103,18 @@ Usage
99103
Options
100104
^^^^^^^^
101105

102-
You can toggle the setting of headers with default values by passing an object with ``true`` or ``false`` and override default values by passing a string or policy to the following options:
103-
104-
- ``server`` - set the Server header, e.g. ``Server=“Blockade”``
105-
*(string / bool / Policy, default=False)*
106-
- ``hsts`` - set the Strict-Transport-Security header *(string / bool /
107-
Policy, default=True)*
108-
- ``xfo`` - set the X-Frame-Options header *(string / bool /
109-
Policy, default=True)*
110-
- ``xxp`` - set the X-XSS-Protection header *(string / bool /
111-
Policy, default=True)*
112-
- ``content`` - set the X-Content-Type-Options header *(string / bool /
113-
Policy, default=True)*
114-
- ``csp`` - set the Content-Security-Policy *(string / bool /
115-
Policy, default=False)* \*
116-
- ``referrer`` - set the Referrer-Policy header *(string / bool /
117-
Policy, default=True)*
118-
- ``cache`` - set the Cache-control and Pragma headers *(string / bool
119-
/ Policy, default=True)*
120-
- ``feature`` - set the Feature-Policy header *(SecurePolicies / string
121-
/ bool / Policy, default=False)*
106+
You can toggle the setting of headers with default values by passing an object with ``new blockade.Header().default()`` or ``new blockade.Header().notSet()`` and override default values by passing ``new blockade.Header().set("custom")`` or policy to the following options:
107+
108+
- ``server`` - set the Server header, e.g. ``new blockade.Server().set("Blockade")``
109+
- (default= ``default=Server().notSet()`` )
110+
- ``hsts`` - set the Strict-Transport-Security header - (default= ``HSTS().default()`` )
111+
- ``xfo`` - set the X-Frame-Options header - (default= ``XFO().default()`` )
112+
- ``xxp`` - set the X-XSS-Protection header - (default= ``XXP().default()`` )
113+
- ``content`` - set the X-Content-Type-Options header - (default= ``Content().default()`` )
114+
- ``csp`` - set the Content-Security-Policy - (default= ``CSP().notSet()`` )
115+
- ``referrer`` - set the Referrer-Policy header - (default= ``Referrer().default()`` )
116+
- ``cache`` - set the Cache-control and Pragma headers - (default= ``Cache().default()`` )
117+
- ``feature`` - set the Feature-Policy header - (default= ``Feature().notSet()`` )
122118

123119

124120
**Example:**

docs/source/index.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,20 @@ Blockade
1010

1111
Blockade ⚓️ is a lightweight package that adds optional security headers and cookie attributes for Node.js web frameworks.
1212

13+
Security HTTP headers and cookie attributes help enhance the security of your web application by enabling built-in browser security mechanisms.
14+
1315
Supported Node.js web frameworks:
1416
----------------------------------
1517

16-
`AdonisJs <https://adonisjs.com>`__
18+
`AdonisJs <https://adonisjs.com>`__,
1719
`Express <https://expressjs.com>`__,
20+
`Fastify <https://www.fastify.io>`__,
1821
`hapi <https://hapijs.com>`__,
1922
`Koa <https://koajs.com>`__,
2023
`Meteor <https://www.meteor.com>`__,
2124
`Nest <https://nestjs.com>`__,
25+
`Polka <https://github.com/lukeed/polka>`__,
26+
`restify <http://restify.com>`__,
2227
`Sails <https://sailsjs.com>`__,
2328
`Total.js <https://www.totaljs.com>`__
2429

0 commit comments

Comments
 (0)