-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: added ru readme for landing (#67)
* docs: added ru readme for landing * fix: github conversation
- Loading branch information
1 parent
8d75e09
commit 8fe8981
Showing
1 changed file
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# ExpressKit | ||
|
||
`ExpressKit` — легковесная обертка для [express.js](https://expressjs.com/), которая интегрируется с [NodeKit](https://github.com/gravity-ui/nodekit), обеспечивая такие функции, как логирование запросов, поддержка трассировки, асинхронные контроллеры и middleware, а также детальное описание маршрутов. | ||
|
||
Установка: | ||
|
||
```bash | ||
npm install --save @gravity-ui/nodekit @gravity-ui/expresskit | ||
``` | ||
|
||
Основное использование: | ||
|
||
```typescript | ||
import {ExpressKit} from '@gravity-ui/expresskit'; | ||
import {NodeKit} from '@gravity-ui/nodekit'; | ||
|
||
const nodekit = new NodeKit(); | ||
|
||
const app = new ExpressKit(nodekit, { | ||
'GET /': (req, res) => { | ||
res.send('Hello World!'); | ||
}, | ||
}); | ||
|
||
app.run(); | ||
``` | ||
|
||
## CSP (политика безопасности контента) | ||
|
||
`config.ts` | ||
|
||
```typescript | ||
import type {AppConfig} from '@gravity-ui/nodekit'; | ||
import {csp} from '@gravity-ui/expresskit'; | ||
|
||
const config: Partial<AppConfig> = { | ||
expressCspEnable: true, | ||
expressCspPresets: ({getDefaultPresets}) => { | ||
return getDefaultPresets({defaultNone: true}).concat([ | ||
csp.inline(), | ||
{csp.directives.REPORT_TO: 'my-report-group'}, | ||
]); | ||
}, | ||
expressCspReportTo: [ | ||
{ | ||
group: 'my-report-group', | ||
max_age: 30 * 60, | ||
endpoints: [{ url: 'https://cspreport.com/send'}], | ||
include_subdomains: true, | ||
} | ||
] | ||
} | ||
|
||
export default config; | ||
``` |