serverless-simple-middleware 0.0.62 → 0.0.63

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,99 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="AutoImportSettings">
4
+ <option name="autoReloadType" value="SELECTIVE" />
5
+ </component>
6
+ <component name="ChangeListManager">
7
+ <list default="true" id="d3e8841d-4c1b-4775-9eaf-7a7f45125ca6" name="Changes" comment="" />
8
+ <option name="SHOW_DIALOG" value="false" />
9
+ <option name="HIGHLIGHT_CONFLICTS" value="true" />
10
+ <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
11
+ <option name="LAST_RESOLUTION" value="IGNORE" />
12
+ </component>
13
+ <component name="Git.Settings">
14
+ <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
15
+ </component>
16
+ <component name="GitHubPullRequestSearchHistory">{
17
+ &quot;lastFilter&quot;: {
18
+ &quot;state&quot;: &quot;OPEN&quot;,
19
+ &quot;assignee&quot;: &quot;mintae-v6x&quot;
20
+ }
21
+ }</component>
22
+ <component name="GithubPullRequestsUISettings">{
23
+ &quot;selectedUrlAndAccountId&quot;: {
24
+ &quot;url&quot;: &quot;git@github.com:v6x/serverless-simple-middleware.git&quot;,
25
+ &quot;accountId&quot;: &quot;651af4d7-dc5b-4c87-ad25-95bb095bbdab&quot;
26
+ }
27
+ }</component>
28
+ <component name="ProjectColorInfo">{
29
+ &quot;customColor&quot;: &quot;&quot;,
30
+ &quot;associatedIndex&quot;: 0
31
+ }</component>
32
+ <component name="ProjectId" id="2wLO998bpCyv1XeFcGkak71tJ00" />
33
+ <component name="ProjectViewState">
34
+ <option name="hideEmptyMiddlePackages" value="true" />
35
+ <option name="showLibraryContents" value="true" />
36
+ </component>
37
+ <component name="PropertiesComponent"><![CDATA[{
38
+ "keyToString": {
39
+ "RunOnceActivity.ShowReadmeOnStart": "true",
40
+ "node.js.detected.package.eslint": "true",
41
+ "node.js.detected.package.tslint": "true",
42
+ "node.js.selected.package.eslint": "(autodetect)",
43
+ "node.js.selected.package.tslint": "(autodetect)",
44
+ "nodejs_package_manager_path": "yarn",
45
+ "ts.external.directory.path": "C:\\Users\\MintaeHwang\\Projects\\serverless-simple-middleware\\node_modules\\typescript\\lib",
46
+ "vue.rearranger.settings.migration": "true"
47
+ }
48
+ }]]></component>
49
+ <component name="SharedIndexes">
50
+ <attachedChunks>
51
+ <set>
52
+ <option value="bundled-js-predefined-1d06a55b98c1-0b3e54e931b4-JavaScript-WS-241.18034.50" />
53
+ </set>
54
+ </attachedChunks>
55
+ </component>
56
+ <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
57
+ <component name="TaskManager">
58
+ <task active="true" id="Default" summary="Default task">
59
+ <changelist id="d3e8841d-4c1b-4775-9eaf-7a7f45125ca6" name="Changes" comment="" />
60
+ <created>1745817233391</created>
61
+ <option name="number" value="Default" />
62
+ <option name="presentableId" value="Default" />
63
+ <updated>1745817233391</updated>
64
+ <workItem from="1745817234628" duration="4410000" />
65
+ <workItem from="1746006740077" duration="129000" />
66
+ <workItem from="1749703698039" duration="5259000" />
67
+ <workItem from="1749721908491" duration="1629000" />
68
+ <workItem from="1750211888403" duration="1739000" />
69
+ <workItem from="1750643159276" duration="1164000" />
70
+ <workItem from="1751023632877" duration="2292000" />
71
+ </task>
72
+ <servers />
73
+ </component>
74
+ <component name="TypeScriptGeneratedFilesManager">
75
+ <option name="version" value="3" />
76
+ </component>
77
+ <component name="Vcs.Log.Tabs.Properties">
78
+ <option name="TAB_STATES">
79
+ <map>
80
+ <entry key="MAIN">
81
+ <value>
82
+ <State />
83
+ </value>
84
+ </entry>
85
+ </map>
86
+ </option>
87
+ </component>
88
+ <component name="XDebuggerManager">
89
+ <breakpoint-manager>
90
+ <breakpoints>
91
+ <line-breakpoint enabled="true" type="javascript">
92
+ <url>file://$PROJECT_DIR$/src/middleware/trace.ts</url>
93
+ <line>118</line>
94
+ <option name="timeStamp" value="1" />
95
+ </line-breakpoint>
96
+ </breakpoints>
97
+ </breakpoint-manager>
98
+ </component>
99
+ </project>
package/.prettierignore CHANGED
@@ -1,3 +1,3 @@
1
- tslint.json
2
- tsconfig.json
1
+ tslint.json
2
+ tsconfig.json
3
3
  package.json
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
- # Serverless simple middleware
2
-
3
- This is just simple middleware for me to translate the interface of lambda's handler to use `request => response`.
1
+ # Serverless simple middleware
2
+
3
+ This is just simple middleware for me to translate the interface of lambda's handler to use `request => response`.
@@ -28,7 +28,7 @@ export declare class HandlerResponse {
28
28
  constructor(callback: any);
29
29
  ok(body?: {}, code?: number): any;
30
30
  fail(body?: {}, code?: number): any;
31
- addCookie(key: string, value: string, domain?: string, specifyCrossOrigin?: true, path?: string): void;
31
+ addCookie(key: string, value: string, domain?: string, sameSite?: 'None' | 'Lax' | 'Strict', secure?: boolean, path?: string, httpOnly?: boolean, maxAgeSeconds?: number): void;
32
32
  setCrossOrigin: (origin?: string) => void;
33
33
  addHeader: (header: string, value: string) => void;
34
34
  }
@@ -111,13 +111,23 @@ var HandlerResponse = /** @class */ (function () {
111
111
  this.completed = true;
112
112
  return result;
113
113
  };
114
- HandlerResponse.prototype.addCookie = function (key, value, domain, specifyCrossOrigin, path) {
114
+ HandlerResponse.prototype.addCookie = function (key, value, domain, sameSite, secure, path, httpOnly, maxAgeSeconds) {
115
115
  var keyValueStr = "".concat(key, "=").concat(value);
116
116
  var domainStr = domain ? "Domain=".concat(domain) : '';
117
- var sameSiteStr = specifyCrossOrigin ? 'SameSite=None' : '';
118
- var secureStr = specifyCrossOrigin ? 'Secure' : '';
117
+ var sameSiteStr = sameSite ? "SameSite=".concat(sameSite) : '';
118
+ var secureStr = secure ? 'Secure' : '';
119
119
  var pathStr = path !== undefined ? "Path=".concat(path) : '';
120
- var cookieStr = [keyValueStr, domainStr, sameSiteStr, secureStr, pathStr]
120
+ var httpOnlyStr = httpOnly ? 'HttpOnly' : '';
121
+ var maxAgeStr = maxAgeSeconds || maxAgeSeconds === 0 ? "Max-Age=".concat(maxAgeSeconds) : '';
122
+ var cookieStr = [
123
+ keyValueStr,
124
+ domainStr,
125
+ sameSiteStr,
126
+ secureStr,
127
+ pathStr,
128
+ httpOnlyStr,
129
+ maxAgeStr,
130
+ ]
121
131
  .filter(function (x) { return x; })
122
132
  .join('; ');
123
133
  this.cookies.push(cookieStr);
package/jest.config.js CHANGED
@@ -1,7 +1,7 @@
1
- module.exports = {
2
- transform: {
3
- '^.+\\.tsx?$': 'ts-jest',
4
- },
5
- testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
6
- moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
7
- };
1
+ module.exports = {
2
+ transform: {
3
+ '^.+\\.tsx?$': 'ts-jest',
4
+ },
5
+ testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$',
6
+ moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
7
+ };
package/package.json CHANGED
@@ -1,69 +1,69 @@
1
- {
2
- "name": "serverless-simple-middleware",
3
- "description": "Simple middleware to translate the interface of lambda's handler to request => response",
4
- "version": "0.0.62",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "author": "VoyagerX",
8
- "license": "MIT",
9
- "repository": {
10
- "type": "git",
11
- "url": "git+ssh://git@github.com/v6x/serverless-simple-middleware.git"
12
- },
13
- "engines": {
14
- "node": ">=18"
15
- },
16
- "keywords": [
17
- "serverless"
18
- ],
19
- "bugs": {
20
- "url": "https://github.com/v6x/serverless-simple-middleware/issues"
21
- },
22
- "homepage": "https://github.com/v6x/serverless-simple-middleware#readme",
23
- "scripts": {
24
- "lint": "tslint --project tsconfig.json",
25
- "build": "tsc --project tsconfig.json",
26
- "build:watch": "tsc --project tsconfig.json --watch",
27
- "test": "jest --config jest.config.js",
28
- "test:watch": "jest --config jest.config.js --watch",
29
- "deploy": "yarn build && yarn publish",
30
- "clean": "rm -rf dist && rm -rf node_modules && yarn install"
31
- },
32
- "dependencies": {
33
- "@aws-sdk/client-dynamodb": "^3.828.0",
34
- "@aws-sdk/client-s3": "^3.828.0",
35
- "@aws-sdk/client-sqs": "^3.828.0",
36
- "@aws-sdk/cloudfront-signer": "^3.821.0",
37
- "@aws-sdk/lib-dynamodb": "^3.828.0",
38
- "@aws-sdk/lib-storage": "^3.828.0",
39
- "@aws-sdk/s3-request-presigner": "^3.828.0",
40
- "@types/aws-lambda": "8",
41
- "@types/mysql": "^2.15.5",
42
- "cross-fetch": "^2.2.2",
43
- "mysql": "^2.16.0",
44
- "nanoid": "4.0.2",
45
- "p-limit": "^2.0.0",
46
- "simple-staging": "^0.0.12",
47
- "ts-enum-util": "^3.1.0",
48
- "uuid": "^3.3.2"
49
- },
50
- "devDependencies": {
51
- "@types/jest": "^23.3.1",
52
- "@types/node": "18",
53
- "@types/uuid": "^3.4.4",
54
- "babel-core": "6.26.0",
55
- "babel-jest": "^23.4.2",
56
- "cross-env": "^5.2.0",
57
- "jest": "^23.4.2",
58
- "prettier": "3.3.3",
59
- "ts-jest": "^23.1.3",
60
- "tslint": "^5.11.0",
61
- "tslint-config-prettier": "^1.14.0",
62
- "typescript": "5.5.3"
63
- },
64
- "prettier": {
65
- "printWidth": 80,
66
- "singleQuote": true,
67
- "trailingComma": "all"
68
- }
69
- }
1
+ {
2
+ "name": "serverless-simple-middleware",
3
+ "description": "Simple middleware to translate the interface of lambda's handler to request => response",
4
+ "version": "0.0.63",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "author": "VoyagerX",
8
+ "license": "MIT",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+ssh://git@github.com/v6x/serverless-simple-middleware.git"
12
+ },
13
+ "engines": {
14
+ "node": ">=18"
15
+ },
16
+ "keywords": [
17
+ "serverless"
18
+ ],
19
+ "bugs": {
20
+ "url": "https://github.com/v6x/serverless-simple-middleware/issues"
21
+ },
22
+ "homepage": "https://github.com/v6x/serverless-simple-middleware#readme",
23
+ "scripts": {
24
+ "lint": "tslint --project tsconfig.json",
25
+ "build": "tsc --project tsconfig.json",
26
+ "build:watch": "tsc --project tsconfig.json --watch",
27
+ "test": "jest --config jest.config.js",
28
+ "test:watch": "jest --config jest.config.js --watch",
29
+ "deploy": "yarn build && yarn publish",
30
+ "clean": "rm -rf dist && rm -rf node_modules && yarn install"
31
+ },
32
+ "dependencies": {
33
+ "@aws-sdk/client-dynamodb": "^3.828.0",
34
+ "@aws-sdk/client-s3": "^3.828.0",
35
+ "@aws-sdk/client-sqs": "^3.828.0",
36
+ "@aws-sdk/cloudfront-signer": "^3.821.0",
37
+ "@aws-sdk/lib-dynamodb": "^3.828.0",
38
+ "@aws-sdk/lib-storage": "^3.828.0",
39
+ "@aws-sdk/s3-request-presigner": "^3.828.0",
40
+ "@types/aws-lambda": "8",
41
+ "@types/mysql": "^2.15.5",
42
+ "cross-fetch": "^2.2.2",
43
+ "mysql": "^2.16.0",
44
+ "nanoid": "4.0.2",
45
+ "p-limit": "^2.0.0",
46
+ "simple-staging": "^0.0.12",
47
+ "ts-enum-util": "^3.1.0",
48
+ "uuid": "^3.3.2"
49
+ },
50
+ "devDependencies": {
51
+ "@types/jest": "^23.3.1",
52
+ "@types/node": "18",
53
+ "@types/uuid": "^3.4.4",
54
+ "babel-core": "6.26.0",
55
+ "babel-jest": "^23.4.2",
56
+ "cross-env": "^5.2.0",
57
+ "jest": "^23.4.2",
58
+ "prettier": "3.3.3",
59
+ "ts-jest": "^23.1.3",
60
+ "tslint": "^5.11.0",
61
+ "tslint-config-prettier": "^1.14.0",
62
+ "typescript": "5.5.3"
63
+ },
64
+ "prettier": {
65
+ "printWidth": 80,
66
+ "singleQuote": true,
67
+ "trailingComma": "all"
68
+ }
69
+ }
package/src/aws/config.ts CHANGED
@@ -1,46 +1,46 @@
1
- import fetch from 'cross-fetch';
2
- import * as fs from 'fs';
3
-
4
- import { AWSComponent } from './define';
5
-
6
- export interface AWSConfig {
7
- [key: string]: string | boolean | number | undefined;
8
- }
9
-
10
- export interface AWSConfigs {
11
- [service: string]: AWSConfig;
12
- }
13
-
14
- export type AWSConfigResolver = (service: string) => AWSConfig;
15
-
16
- export type SimpleAWSConfigLoadParam = AWSConfigs | string;
17
-
18
- export class SimpleAWSConfig {
19
- private configs: AWSConfigs | undefined;
20
-
21
- public constructor(configs?: AWSConfigs) {
22
- this.configs = configs;
23
- }
24
-
25
- public get = (service: AWSComponent): AWSConfig | undefined => {
26
- return this.configs ? this.configs[service] : undefined;
27
- };
28
- }
29
-
30
- export const loadAWSConfig = (
31
- newConfigsOrUrl: SimpleAWSConfigLoadParam,
32
- ): Promise<SimpleAWSConfig> => {
33
- if (typeof newConfigsOrUrl === 'string') {
34
- if (/^http.*json$/.test(newConfigsOrUrl)) {
35
- return fetch(newConfigsOrUrl)
36
- .then((r) => r.json())
37
- .then(loadAWSConfig);
38
- } else if (/json$/.test(newConfigsOrUrl)) {
39
- return loadAWSConfig(
40
- JSON.parse(fs.readFileSync(newConfigsOrUrl, 'utf-8')),
41
- );
42
- }
43
- return loadAWSConfig(JSON.parse(newConfigsOrUrl));
44
- }
45
- return Promise.resolve(new SimpleAWSConfig(newConfigsOrUrl));
46
- };
1
+ import fetch from 'cross-fetch';
2
+ import * as fs from 'fs';
3
+
4
+ import { AWSComponent } from './define';
5
+
6
+ export interface AWSConfig {
7
+ [key: string]: string | boolean | number | undefined;
8
+ }
9
+
10
+ export interface AWSConfigs {
11
+ [service: string]: AWSConfig;
12
+ }
13
+
14
+ export type AWSConfigResolver = (service: string) => AWSConfig;
15
+
16
+ export type SimpleAWSConfigLoadParam = AWSConfigs | string;
17
+
18
+ export class SimpleAWSConfig {
19
+ private configs: AWSConfigs | undefined;
20
+
21
+ public constructor(configs?: AWSConfigs) {
22
+ this.configs = configs;
23
+ }
24
+
25
+ public get = (service: AWSComponent): AWSConfig | undefined => {
26
+ return this.configs ? this.configs[service] : undefined;
27
+ };
28
+ }
29
+
30
+ export const loadAWSConfig = (
31
+ newConfigsOrUrl: SimpleAWSConfigLoadParam,
32
+ ): Promise<SimpleAWSConfig> => {
33
+ if (typeof newConfigsOrUrl === 'string') {
34
+ if (/^http.*json$/.test(newConfigsOrUrl)) {
35
+ return fetch(newConfigsOrUrl)
36
+ .then((r) => r.json())
37
+ .then(loadAWSConfig);
38
+ } else if (/json$/.test(newConfigsOrUrl)) {
39
+ return loadAWSConfig(
40
+ JSON.parse(fs.readFileSync(newConfigsOrUrl, 'utf-8')),
41
+ );
42
+ }
43
+ return loadAWSConfig(JSON.parse(newConfigsOrUrl));
44
+ }
45
+ return Promise.resolve(new SimpleAWSConfig(newConfigsOrUrl));
46
+ };
package/src/aws/define.ts CHANGED
@@ -1,10 +1,10 @@
1
- export enum AWSComponent {
2
- s3 = 's3',
3
- sqs = 'sqs',
4
- dynamodb = 'dynamodb',
5
- }
6
-
7
- export interface SQSMessageBody<T> {
8
- handle: string;
9
- body?: T;
10
- }
1
+ export enum AWSComponent {
2
+ s3 = 's3',
3
+ sqs = 'sqs',
4
+ dynamodb = 'dynamodb',
5
+ }
6
+
7
+ export interface SQSMessageBody<T> {
8
+ handle: string;
9
+ body?: T;
10
+ }
package/src/aws/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './define';
2
- export * from './config';
3
- export * from './simple';
1
+ export * from './define';
2
+ export * from './config';
3
+ export * from './simple';