From ce69700645981d7581641f1bd35bb6ae07f7bbc4 Mon Sep 17 00:00:00 2001 From: Harry Chen Date: Sun, 4 Feb 2024 16:37:14 +0800 Subject: [PATCH] docs: update serverless session --- site/docs/cookie_session.md | 39 ++++++++++++++++++- .../current/cookie_session.md | 39 ++++++++++++++++++- .../current/extensions/sequelize.md | 29 ++++++++++++++ 3 files changed, 103 insertions(+), 4 deletions(-) diff --git a/site/docs/cookie_session.md b/site/docs/cookie_session.md index 37eaa74d465d..eed13937f699 100644 --- a/site/docs/cookie_session.md +++ b/site/docs/cookie_session.md @@ -12,8 +12,8 @@ Cookie 在 Web 应用中经常承担标识请求方身份的功能,所以 Web ## 适用范围 -* @midwayjs/web 下(即 egg)内置的是 egg 自带的 Cookie,未提供替换能力,不适用本文档 -* @midwayjs/express 下(即 express)内置的是 express 自带的 Cookie 库,未提供替换能力,不适用本文档 +* `@midwayjs/web` 下(即 egg)内置的是 egg 自带的 Cookie,未提供替换能力,不适用本文档 +* `@midwayjs/express` 下(即 express)内置的是 express 自带的 Cookie 库,未提供替换能力,不适用本文档 @@ -230,6 +230,41 @@ export default { +## 函数下的 Session + +在函数弹性容器的场景下,默认未内置 Session 模块,如果需要可以手动添加。 + +```json +{ + "dependencies": { + "@midwayjs/session": "^3.0.0", + // ... + }, +} +``` + +在 configuration 中引入组件。 + +```typescript +// src/configuration.ts +import { Configuration } from '@midwayjs/core'; +import * as faas from '@midwayjs/faas'; +import * as session from '@midwayjs/session'; + +@Configuration({ + imports: [ + faas, + session, + // ... + ] +}) +export class MainConfiguration { + // ... +} +``` + + + ## Session 示例 ### 修改用户 Session 失效时间 diff --git a/site/i18n/en/docusaurus-plugin-content-docs/current/cookie_session.md b/site/i18n/en/docusaurus-plugin-content-docs/current/cookie_session.md index 98653e3ddb21..2f894b6008c6 100644 --- a/site/i18n/en/docusaurus-plugin-content-docs/current/cookie_session.md +++ b/site/i18n/en/docusaurus-plugin-content-docs/current/cookie_session.md @@ -12,8 +12,8 @@ Cookie often assume the function of identifying the requestor's identity in Web ## Scope of application -* The built-in cookie under @midwayjs/web (i.e. egg) is the cookie that comes with egg. It does not provide replacement capabilities and is not applicable to this document. -* The built-in cookie library under @midwayjs/express (i.e. express) is the cookie library that comes with express. It does not provide replacement capabilities and is not applicable to this document. +* The built-in cookie under `@midwayjs/web` (i.e. egg) is the cookie that comes with egg. It does not provide replacement capabilities and is not applicable to this document. +* The built-in cookie library under `@midwayjs/express` (i.e. express) is the cookie library that comes with express. It does not provide replacement capabilities and is not applicable to this document. @@ -230,6 +230,41 @@ It can be seen that these parameters are cookie parameters except `key`. `key` r +## Session in Serverless + +In the scenario of a function elastic container, the Session module is not built-in by default. You can add it manually if necessary. + +```json +{ + "dependencies": { + "@midwayjs/session": "^3.0.0", + // ... + }, +} +``` + +Introduce components in configuration. + +```typescript +// src/configuration.ts +import { Configuration } from '@midwayjs/core'; +import * as faas from '@midwayjs/faas'; +import * as session from '@midwayjs/session'; + +@Configuration({ + imports: [ + faas, + session, + // ... + ] +}) +export class MainConfiguration { + // ... +} +``` + + + ## Session example ### Modify user Session expiration time diff --git a/site/i18n/en/docusaurus-plugin-content-docs/current/extensions/sequelize.md b/site/i18n/en/docusaurus-plugin-content-docs/current/extensions/sequelize.md index 35a8c797a719..11571fcb8386 100644 --- a/site/i18n/en/docusaurus-plugin-content-docs/current/extensions/sequelize.md +++ b/site/i18n/en/docusaurus-plugin-content-docs/current/extensions/sequelize.md @@ -712,6 +712,35 @@ If you encounter something more complex, you can use the [raw query method](http +### 4. TS2612 error + +If your model reports a TS2612 error, such as: + +``` +src/entity/AesTenantConfigInfo.ts:29:6 - error TS2612: Property 'id' will overwrite the base property in 'Model'. If this is intentional, add an initializer. Otherwise, add a 'declare' modifier or remove the redundant declaration. + +29 id?: number; + ~~ +``` + +It can be assigned a null value. + +```typescript +import { Table, Column } from 'sequelize-typescript'; + +@Table +export class User extends Model { + @Column({ + primaryKey: true, + autoIncrement: true, + type: DataType.BIGINT, + }) + id?: number = undefined; +} +``` + + + ## Other - The above document is translated from sequelize-typescript. For more API, please refer to the [English document](<(https://github.com/sequelize/sequelize-typescrip)>).