create-nkvs-mongoose-hono 1.0.2 → 1.0.3

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.
Files changed (2) hide show
  1. package/README.md +165 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Package
2
2
 
3
- The logic of this package is not yet perfect, but you can try using it.
3
+ The logic of this package is not yet perfect, but you can try to use it.
4
4
 
5
5
  Once you start the project, you can open http://localhost:3000/static/compass (default port is 3000).
6
6
 
@@ -15,3 +15,167 @@ Once you start the project, you can open http://localhost:3000/static/compass (d
15
15
  - npm run dev
16
16
  - npm run build
17
17
  - npm run start
18
+
19
+ ### Global Middleware
20
+
21
+ ```JavaScript
22
+ import { cors } from 'hono/cors'
23
+ import { prettyJSON } from 'hono/pretty-json'
24
+
25
+ const { globalMiddleware } = store.get('app')
26
+ globalMiddleware.push(cors(), prettyJSON())
27
+ ```
28
+
29
+ ### Middleware
30
+
31
+ ```JavaScript
32
+ const { middleware } = store.get('app')
33
+ middleware['test'] = async function (context, next) {
34
+ console.log(1)
35
+ await next()
36
+ }
37
+ ```
38
+
39
+ ### Global Middleware & Middleware / middleware/_import.js
40
+
41
+ ```JavaScript
42
+ import './global.js'
43
+ import './test.js'
44
+ ```
45
+
46
+ ### Global Middleware - Dev
47
+
48
+ ```JavaScript
49
+ const { globalMiddleware } = store.get('_app')
50
+ globalMiddleware['cors'] = 'cors.'
51
+ globalMiddleware['prettyJSON'] = 'pretty JSON.'
52
+ ```
53
+
54
+ ### Middleware - Dev
55
+
56
+ ```JavaScript
57
+ const { middleware } = store.get('_app')
58
+ middleware['test'] = 'console log 1.'
59
+ ```
60
+
61
+ ### Global Middleware - Dev & Middleware - Dev / middleware/_import.dev.js
62
+
63
+ ```JavaScript
64
+ import './global.dev.js'
65
+ import './test.dev.js'
66
+ ```
67
+
68
+ ### Router
69
+
70
+ ```JavaScript
71
+ store.get('app').routers.push({
72
+ path: '/apples',
73
+ crud: {
74
+ model: 'Apple',
75
+ findAll: { count: true, populate: 'color', limit: 5 }
76
+ findOne: { populate: 'color' }
77
+ },
78
+ events: {
79
+ 'GET /test': { middleware: ['test'], async handler({ json }) { return json({}) } }
80
+ }
81
+ )}
82
+ ```
83
+
84
+ ### Router / findAll
85
+
86
+ Boolean or Object
87
+
88
+ | Name | Type | Example |
89
+ | :--------- | :------------------------------- | :----------------------------------------------------------- |
90
+ | middleware | Array-String | ['test'] |
91
+ | filter | Object | { 'age[gte]': 18 } |
92
+ | fields | String | 'name color' ✅, 'name -createdAt' ❌, '-createdAt -upadtedAt' ❌ |
93
+ | sort | String | '-createdAt' |
94
+ | page | Number | 1 |
95
+ | limit | Number or Boolean | false, 10, If number > 300 then number = 300 |
96
+ | populate | String or Object or Array-Object | 'color', { path: 'color', select: 'name', populate: {} }, [{ path: 'color' }] |
97
+ | count | Boolean | true |
98
+
99
+ ### Router / findOne
100
+
101
+ Boolean or Object
102
+
103
+ | Name | Type | Example |
104
+ | :--------- | :------------------------------- | :----------------------------------------------------------- |
105
+ | middleware | Array-String | ['test'] |
106
+ | filter | Object | { 'age[gte]': 18 } |
107
+ | fields | String | 'name color' ✅, 'name -createdAt' ❌, '-createdAt -upadtedAt' ❌ |
108
+ | populate | String or Object or Array-Object | 'color', { path: 'color', select: 'name', populate: {} }, [{ path: 'color' }] |
109
+
110
+ ### Router / create
111
+
112
+ Boolean or Object
113
+
114
+ | Name | Type | Example |
115
+ | :--------- | :----------- | :------- |
116
+ | middleware | Array-String | ['test'] |
117
+
118
+ ### Router / update
119
+
120
+ Boolean or Object
121
+
122
+ | Name | Type | Example |
123
+ | :----------- | :----------- | :------------ |
124
+ | middleware | Array-String | ['test'] |
125
+ | ignoreFields | Array | ['active'] |
126
+ | options | Object | { new: true } |
127
+
128
+ ### Router / remove
129
+
130
+ Boolean or Object
131
+
132
+ | Name | Type | Example |
133
+ | :--------- | :----------- | :------- |
134
+ | middleware | Array-String | ['test'] |
135
+
136
+ ### Router / _import.js
137
+
138
+ ```JavaScript
139
+ import './apples.js'
140
+ ```
141
+
142
+ ### Router - Dev
143
+
144
+ ```JavaScript
145
+ store.get('_app').routers['/apples'] = {
146
+ description: 'Apple',
147
+ events: {
148
+ 'GET /test': { description: 'Apple test interface.' }
149
+ }
150
+ }
151
+ ```
152
+
153
+ ### Router - Dev / _import.dev.js
154
+
155
+ ```JavaScript
156
+ import './apples.dev.js'
157
+ ```
158
+
159
+ ### Model
160
+
161
+ ```JavaScript
162
+ store.get('app').models.Apple = {
163
+ collection: 'apples',
164
+ documentName: 'apple',
165
+ schema: {
166
+ name: { type: 'String', required: true },
167
+ color: { type: 'ObjectId', ref: 'Color' },
168
+ },
169
+ options: { timestamps: true, methods: {}, statics: {} },
170
+ middleware: [{ hook: 'pre', 'method': 'save', async handler(doc) {} }]
171
+ }
172
+ ```
173
+
174
+ ### Model / _import.js
175
+
176
+ ```JavaScript
177
+ import './Apple.js'
178
+ import './Color.js'
179
+ ```
180
+
181
+ For more details: [Mongoose](https://mongoosejs.com/) and [Hono](https://hono.dev/).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nkvs-mongoose-hono",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Create a mongoose-hono project.",
5
5
  "bin": {
6
6
  "create-nkvs-mongoose-hono": "index.js"