express-sweet 1.0.15 → 1.0.18
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.
- package/CHANGELOG.md +215 -0
- package/INSTALL-Redis.md +51 -0
- package/README.md +13 -44
- package/dist/build.common.js +59 -0
- package/dist/build.esm.js +59 -0
- package/docs/{styles/docs.css → docs.css} +99 -100
- package/docs/docs.js +41 -0
- package/docs/{images → img/associations}/belongs-to-many.png +0 -0
- package/docs/{images → img/associations}/belongs-to.png +0 -0
- package/docs/{images → img/associations}/has-many.png +0 -0
- package/docs/{images → img/associations}/has-one.png +0 -0
- package/docs/img/demos/login&users.jfif +0 -0
- package/docs/img/hero.svg +1 -0
- package/docs/{images → img}/logo.svg +0 -0
- package/docs/index.html +2520 -3144
- package/docs/templates/cjs/authentication.js +96 -0
- package/docs/templates/cjs/config.js +78 -0
- package/docs/templates/cjs/database.js +35 -0
- package/docs/templates/cjs/view.js +36 -0
- package/docs/templates/esm/authentication.js +96 -0
- package/docs/templates/esm/config.js +78 -0
- package/docs/templates/esm/database.js +35 -0
- package/docs/templates/esm/view.js +36 -0
- package/package.json +9 -6
- package/types/database/Database.d.ts +162 -0
- package/types/database/Model.d.ts +221 -0
- package/types/database/index.d.ts +4 -0
- package/types/database/loadModels.d.ts +6 -0
- package/types/exceptions/ApiError.d.ts +29 -0
- package/types/exceptions/index.d.ts +2 -0
- package/types/handlebars_helpers/comparison.d.ts +302 -0
- package/types/handlebars_helpers/date.d.ts +21 -0
- package/types/handlebars_helpers/html.d.ts +11 -0
- package/types/handlebars_helpers/index.d.ts +5 -0
- package/types/handlebars_helpers/object.d.ts +21 -0
- package/types/handlebars_helpers/string.d.ts +32 -0
- package/types/index.d.ts +9 -0
- package/types/interfaces/AuthenticationOptions.d.ts +97 -0
- package/types/interfaces/BoundingBox.d.ts +25 -0
- package/types/interfaces/Config.d.ts +66 -0
- package/types/interfaces/DatabaseOptions.d.ts +7 -0
- package/types/interfaces/FaceMatch.d.ts +31 -0
- package/types/interfaces/RekognitionOptions.d.ts +26 -0
- package/types/interfaces/ViewOptions.d.ts +30 -0
- package/types/interfaces/index.d.ts +8 -0
- package/types/middlewares/Authentication.d.ts +16 -0
- package/types/middlewares/CORS.d.ts +16 -0
- package/types/middlewares/Environment.d.ts +17 -0
- package/types/middlewares/ErrorHandling.d.ts +16 -0
- package/types/middlewares/Global.d.ts +13 -0
- package/types/middlewares/Http.d.ts +16 -0
- package/types/middlewares/Local.d.ts +20 -0
- package/types/middlewares/View.d.ts +16 -0
- package/types/middlewares/index.d.ts +8 -0
- package/types/mount.d.ts +7 -0
- package/types/package.d.ts +94 -0
- package/types/routing/Router.d.ts +19 -0
- package/types/routing/index.d.ts +2 -0
- package/types/services/AWSRekognitionClient.d.ts +359 -0
- package/types/services/Authentication.d.ts +39 -0
- package/types/services/RedisClient.d.ts +80 -0
- package/types/services/index.d.ts +3 -0
- package/types/utils/Types.d.ts +24 -0
- package/types/utils/index.d.ts +6 -0
- package/types/utils/isAsyncFunction.d.ts +12 -0
- package/types/utils/isObject.d.ts +8 -0
- package/types/utils/isString.d.ts +8 -0
- package/docs/images/all.jpg +0 -0
- package/docs/images/edit-user.png +0 -0
- package/docs/images/home.png +0 -0
- package/docs/images/login.png +0 -0
- package/docs/images/logo-dark.svg +0 -12
- package/docs/images/new-user.png +0 -0
- package/docs/images/user-list.png +0 -0
- package/docs/scripts/docs.js +0 -23
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
|
|
4
|
+
## [1.0.18] - 2022-05-18
|
|
5
|
+
### Fixed
|
|
6
|
+
- User authentication sessions can now be stored in redis.
|
|
7
|
+
To use redis for session storage, simply add the following option to config/authentication.js.
|
|
8
|
+
Please give it a try.
|
|
9
|
+
|
|
10
|
+
config/authentication.js:
|
|
11
|
+
```json
|
|
12
|
+
/**
|
|
13
|
+
* The session store instance, defaults to a new MemoryStore(memory) instance.
|
|
14
|
+
* @type {'memory|redis'}
|
|
15
|
+
*/
|
|
16
|
+
session_store: 'memory',
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* If the session is stored in "redis", this field is required and should be set to the hostname of the Redis server.
|
|
20
|
+
* For example, to connect to redis on localhost on port 6379, set "redis://localhost:6379".
|
|
21
|
+
* To connect to a different host or port, use a connection string in the format "redis[s]://[[username][:password]@][host][:port][/db-number]".
|
|
22
|
+
* For example, "redis://alice:foobared@awesome.redis.server:6380".
|
|
23
|
+
* @type {string|undefined}
|
|
24
|
+
*/
|
|
25
|
+
redis_host: 'redis://localhost:6379'
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## [1.0.17] - 2022-05-17
|
|
29
|
+
### Fixed
|
|
30
|
+
- Updated documentation and refactored variable names.
|
|
31
|
+
|
|
32
|
+
## [1.0.16] - 2022-02-14
|
|
33
|
+
### Fixed
|
|
34
|
+
- I forgot to include the build file, so I added the build file.
|
|
35
|
+
|
|
36
|
+
## [1.0.15] - 2022-02-14
|
|
37
|
+
### Fixed
|
|
38
|
+
- Changed the type of 'config/authentication.js#allow_unauthenticated' from'string[]' to'(string|RegExp)[]}'.
|
|
39
|
+
|
|
40
|
+
## [1.0.14] - 2022-01-17
|
|
41
|
+
### Fixed
|
|
42
|
+
- empty view helper can now check any type. Previously I could only check arrays.
|
|
43
|
+
```html
|
|
44
|
+
// If the value is an array.
|
|
45
|
+
let value = [5, 6];
|
|
46
|
+
{{empty value}} => false
|
|
47
|
+
|
|
48
|
+
{{#if (empty value)}}
|
|
49
|
+
Hello
|
|
50
|
+
{{/if}}
|
|
51
|
+
|
|
52
|
+
// If the value is a string.
|
|
53
|
+
let value = 'Hello';
|
|
54
|
+
{{empty value}} => false
|
|
55
|
+
|
|
56
|
+
let value = '';
|
|
57
|
+
{{empty value}} => true
|
|
58
|
+
|
|
59
|
+
let value = ' ';
|
|
60
|
+
{{empty value}} => true
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
- Added not_empty view helper.
|
|
64
|
+
```html
|
|
65
|
+
// If the value is an array.
|
|
66
|
+
let value = [5, 6];
|
|
67
|
+
{{not_empty value}} => true
|
|
68
|
+
|
|
69
|
+
{{#if (not_empty value)}}
|
|
70
|
+
Hello
|
|
71
|
+
{{/if}}
|
|
72
|
+
|
|
73
|
+
// If the value is a string.
|
|
74
|
+
let value = 'Hello';
|
|
75
|
+
{{not_empty value}} => true
|
|
76
|
+
|
|
77
|
+
let value = '';
|
|
78
|
+
{{not_empty value}} => false
|
|
79
|
+
|
|
80
|
+
let value = ' ';
|
|
81
|
+
{{not_empty value}} => false
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## [1.0.13] - 2021-12-13
|
|
85
|
+
### Fixed
|
|
86
|
+
- The model's begin method now accepts the transaction option.
|
|
87
|
+
See [Transaction | Sequelize](https://sequelize.org/master/class/lib/transaction.js~Transaction.html) for transaction options.
|
|
88
|
+
```js
|
|
89
|
+
let transaction;
|
|
90
|
+
try {
|
|
91
|
+
transaction = await BookModel.begin({
|
|
92
|
+
isolationLevel: BookModel.Transaction.ISOLATION_LEVELS.REPEATABLE_READ,
|
|
93
|
+
type: BookModel.Transaction.TYPES.DEFERRED,
|
|
94
|
+
});
|
|
95
|
+
const book = await BookModel.findOne({where: {id: 1}}, {transaction});
|
|
96
|
+
book.title = 'When Im Gone';
|
|
97
|
+
await book.save({transaction});
|
|
98
|
+
await transaction.commit();
|
|
99
|
+
|
|
100
|
+
// Check the update result.
|
|
101
|
+
// Output: New title of book: When Im Gone
|
|
102
|
+
await book.reload();
|
|
103
|
+
console.log(`New title of book: ${book.title}`);
|
|
104
|
+
} catch (err) {
|
|
105
|
+
if (transaction)
|
|
106
|
+
await transaction.rollback();
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## [1.0.12] - 2021-11-16
|
|
111
|
+
### Fixed
|
|
112
|
+
- Added a method to the model that can execute raw SQL.
|
|
113
|
+
As there are often use cases in which it is just easier to execute raw / already prepared SQL queries, you can use the Model.query method.
|
|
114
|
+
|
|
115
|
+
```js
|
|
116
|
+
// By default the function will return two arguments - a results array, and an object containing metadata (such as amount of affected rows, etc).
|
|
117
|
+
// Note that since this is a raw query, the metadata are dialect specific.
|
|
118
|
+
const [results, metadata] = await BookModel.query("UPDATE book SET title = 'When Im Gone' WHERE id = 1");
|
|
119
|
+
|
|
120
|
+
// In cases where you don't need to access the metadata you can pass in a query type to tell sequelize how to format the results. For example, for a simple select query you could do:
|
|
121
|
+
// We didn't need to destructure the result here - the results were returned directly
|
|
122
|
+
const users = await BookModel.query("SELECT * FROM book", {type: BookModel.QueryTypes.SELECT});
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
## [1.0.11] - 2021-11-10
|
|
126
|
+
### Fixed
|
|
127
|
+
- Fixed a bug that the database config was read before NODE_ENV was set and the database config matching NODE_ENV could not be read.
|
|
128
|
+
|
|
129
|
+
## [1.0.10] - 2021-10-19
|
|
130
|
+
### Fixed
|
|
131
|
+
- Added face similarity found to face search results in collection.
|
|
132
|
+
|
|
133
|
+
```js
|
|
134
|
+
import * as sweet from 'express-sweet';
|
|
135
|
+
|
|
136
|
+
// Find a face from the collection.
|
|
137
|
+
// Output: Face search results: [
|
|
138
|
+
// {
|
|
139
|
+
// faceId: '385e1b00-4ede-4219-a7b0-0b9cbe4953e5',
|
|
140
|
+
// boundingBox: {
|
|
141
|
+
// width: 0.3204210102558136,
|
|
142
|
+
// height: 1.0046900510787964,
|
|
143
|
+
// left: 0.39145898818969727,
|
|
144
|
+
// top: 0.07936319708824158
|
|
145
|
+
// },
|
|
146
|
+
// similarity: 99.98941802978516
|
|
147
|
+
// }
|
|
148
|
+
// ]
|
|
149
|
+
const collectionId = 'MyCollection';
|
|
150
|
+
const res = await client.searchFaces(collectionId, 'img/face.jpg');
|
|
151
|
+
console.log('Face search results:', res);
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## [1.0.9] - 2021-10-13
|
|
155
|
+
### Fixed
|
|
156
|
+
- Updated dependent package'sharp'from 0.25.4 to 0.29.1.
|
|
157
|
+
This update statically links sharp's pre-built libvips binaries, eliminating the need to install Phton.
|
|
158
|
+
Click [here](https://sharp.pixelplumbing.com/changelog) for sharp change log.
|
|
159
|
+
|
|
160
|
+
## [1.0.8] - 2021-09-25
|
|
161
|
+
### Fixed
|
|
162
|
+
- Fixed a bug where the default router couldn't aqua from the endpoint URL.
|
|
163
|
+
|
|
164
|
+
## [1.0.7] - 2021-08-13
|
|
165
|
+
### Fixed
|
|
166
|
+
- Added where member functions to Model class. Please see [here](https://takuya-motoshima.github.io/express-sweet/#model-class) for details.
|
|
167
|
+
|
|
168
|
+
## [1.0.6] - 2021-08-13
|
|
169
|
+
### Fixed
|
|
170
|
+
- Added fn, col and literal member functions to Model class. Please see [here](https://takuya-motoshima.github.io/express-sweet/#model-class) for details.
|
|
171
|
+
|
|
172
|
+
## [1.0.5] - 2021-08-12
|
|
173
|
+
### Fixed
|
|
174
|
+
- Changed the maximum size per field for multipart (multipart/form-data) requests from 1MB to unlimited.
|
|
175
|
+
|
|
176
|
+
## [1.0.4] - 2021-06-13
|
|
177
|
+
### Fixed
|
|
178
|
+
- Fixed a bug where the referrer URL was set in app.locals.currentPath instead of the current URL.
|
|
179
|
+
|
|
180
|
+
## [1.0.3] - 2021-06-13
|
|
181
|
+
### Fixed
|
|
182
|
+
- Change the current URL path of a local variable.app.locals.currentPath is a USVString containing an initial '/' followed by the path of the URL not including the query string or fragment.
|
|
183
|
+
|
|
184
|
+
```js
|
|
185
|
+
// For example, when the current URL is "https://example.com/docs/api?q=value", "/docs/api" is set for "app.locals.currentPath".
|
|
186
|
+
console.log(app.locals.currentPath);
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## [1.0.2] - 2021-06-10
|
|
190
|
+
### Fixed
|
|
191
|
+
- Updated rollup from version 2.44 to 2.51.
|
|
192
|
+
- Fixed a bug where preloading models failed in cjs.
|
|
193
|
+
|
|
194
|
+
## [1.0.1] - 2021-06-02
|
|
195
|
+
### Fixed
|
|
196
|
+
- Fixed a bug that caused an error when reading options defined in ESM's default Export.
|
|
197
|
+
|
|
198
|
+
[1.0.1]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.0...v1.0.1
|
|
199
|
+
[1.0.2]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.1...v1.0.2
|
|
200
|
+
[1.0.3]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.2...v1.0.3
|
|
201
|
+
[1.0.4]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.3...v1.0.4
|
|
202
|
+
[1.0.5]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.4...v1.0.5
|
|
203
|
+
[1.0.6]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.5...v1.0.6
|
|
204
|
+
[1.0.7]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.6...v1.0.7
|
|
205
|
+
[1.0.8]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.7...v1.0.8
|
|
206
|
+
[1.0.9]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.8...v1.0.9
|
|
207
|
+
[1.0.10]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.9...v1.0.10
|
|
208
|
+
[1.0.11]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.10...v1.0.11
|
|
209
|
+
[1.0.12]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.11...v1.0.12
|
|
210
|
+
[1.0.13]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.12...v1.0.13
|
|
211
|
+
[1.0.14]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.13...v1.0.14
|
|
212
|
+
[1.0.15]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.14...v1.0.15
|
|
213
|
+
[1.0.16]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.15...v1.0.16
|
|
214
|
+
[1.0.17]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.16...v1.0.17
|
|
215
|
+
[1.0.18]: https://github.com/takuya-motoshima/express-sweet/compare/v1.0.17...v1.0.18
|
package/INSTALL-Redis.md
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Install Redis
|
|
2
|
+
==============
|
|
3
|
+
|
|
4
|
+
* OS: `Amazon Linux 2`
|
|
5
|
+
* Redis: `v6.2.6 or later`
|
|
6
|
+
* see more: https://redis.io/download#installation
|
|
7
|
+
|
|
8
|
+
Check the version of Redis that can be installed.
|
|
9
|
+
```sh
|
|
10
|
+
amazon-linux-extras list|grep redis
|
|
11
|
+
# Below is an example of the output.
|
|
12
|
+
# 56 redis6 available [ =stable ]
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Install Redis by specifying the version.
|
|
16
|
+
```sh
|
|
17
|
+
sudo amazon-linux-extras install -y redis6
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Configure and start Redis autostart.
|
|
21
|
+
```sh
|
|
22
|
+
sudo systemctl status redis.service
|
|
23
|
+
sudo systemctl start redis.service
|
|
24
|
+
sudo systemctl enable redis.service
|
|
25
|
+
sudo systemctl is-enabled redis.service
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Check Redis process.
|
|
29
|
+
```sh
|
|
30
|
+
ps -ef | grep redis | grep -v grep
|
|
31
|
+
# Below is an example of the output.
|
|
32
|
+
# redis 5407 1 0 11:02 ? 00:00:00 /usr/bin/redis-server 127.0.0.1:6379
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Check Redis behavior. If "redis-cli ping" returns PONG, it is success.
|
|
36
|
+
```sh
|
|
37
|
+
redis-cli ping
|
|
38
|
+
# Below is an example of the output.
|
|
39
|
+
# PONG
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Test Redis read/write.
|
|
43
|
+
```sh
|
|
44
|
+
redis-cli
|
|
45
|
+
|
|
46
|
+
set myMessage "hello world"
|
|
47
|
+
# OK
|
|
48
|
+
|
|
49
|
+
get myMessage
|
|
50
|
+
# "hello world"
|
|
51
|
+
```
|
package/README.md
CHANGED
|
@@ -1,51 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
# express-sweet
|
|
2
|
+

|
|
2
3
|
|
|
3
4
|
Extend Express functionality with Express Sweet and start developing fast, minimal web applications.
|
|
4
5
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
For details on installing Express Sweet, see the <a href="https://takuya-motoshima.github.io/express-sweet/#instl" target="_blank">"installation reference"</a>.
|
|
17
|
-
|
|
18
|
-
<table>
|
|
19
|
-
<tr>
|
|
20
|
-
<td valign="top">
|
|
21
|
-
<div>Login</div>
|
|
22
|
-
<img src="https://raw.githubusercontent.com/takuya-motoshima/express-sweet/main/screencaps/login.png" width="400">
|
|
23
|
-
</td>
|
|
24
|
-
<td valign="top">
|
|
25
|
-
<div>Home</div>
|
|
26
|
-
<img src="https://raw.githubusercontent.com/takuya-motoshima/express-sweet/main/screencaps/home.png" width="400">
|
|
27
|
-
</td>
|
|
28
|
-
</tr>
|
|
29
|
-
<tr>
|
|
30
|
-
<td valign="top">
|
|
31
|
-
<div>User list</div>
|
|
32
|
-
<img src="https://raw.githubusercontent.com/takuya-motoshima/express-sweet/main/screencaps/user-list.png" width="400">
|
|
33
|
-
</td>
|
|
34
|
-
<td valign="top">
|
|
35
|
-
<div>New user</div>
|
|
36
|
-
<img src="https://raw.githubusercontent.com/takuya-motoshima/express-sweet/main/screencaps/new-user.png" width="400">
|
|
37
|
-
</td>
|
|
38
|
-
</tr>
|
|
39
|
-
<tr>
|
|
40
|
-
<td valign="top">
|
|
41
|
-
<div>Edit user</div>
|
|
42
|
-
<img src="https://raw.githubusercontent.com/takuya-motoshima/express-sweet/main/screencaps/edit-user.png" width="400">
|
|
43
|
-
</td>
|
|
44
|
-
</tr>
|
|
45
|
-
</table>
|
|
6
|
+
## Documentation
|
|
7
|
+
* [Introduction](https://takuya-motoshima.github.io/express-sweet/#introduction)
|
|
8
|
+
* [Quick Start](https://takuya-motoshima.github.io/express-sweet/#quick-start)
|
|
9
|
+
* [Environment variable](https://takuya-motoshima.github.io/express-sweet/#environment-variable)
|
|
10
|
+
* [Base configuration](https://takuya-motoshima.github.io/express-sweet/#base-configuration)
|
|
11
|
+
* [Routing](https://takuya-motoshima.github.io/express-sweet/#routing)
|
|
12
|
+
* [Views](https://takuya-motoshima.github.io/express-sweet/#views)
|
|
13
|
+
* [Model](https://takuya-motoshima.github.io/express-sweet/#model)
|
|
14
|
+
* [User authentication](https://takuya-motoshima.github.io/express-sweet/#user-authentication)
|
|
15
|
+
* [Rekognition](https://takuya-motoshima.github.io/express-sweet/#rekognition)
|
|
16
|
+
* [Changelog](https://takuya-motoshima.github.io/express-sweet/#changelog)
|
|
46
17
|
|
|
47
18
|
## Author
|
|
48
|
-
|
|
49
19
|
**Takuya Motoshima**
|
|
50
20
|
|
|
51
21
|
* [github/takuya-motoshima](https://github.com/takuya-motoshima)
|
|
@@ -53,5 +23,4 @@ For details on installing Express Sweet, see the <a href="https://takuya-motoshi
|
|
|
53
23
|
* [facebook/takuya.motoshima.7](https://www.facebook.com/takuya.motoshima.7)
|
|
54
24
|
|
|
55
25
|
## License
|
|
56
|
-
|
|
57
26
|
[MIT](LICENSE)
|