express-ext 0.5.12 → 0.5.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-ext",
3
- "version": "0.5.12",
3
+ "version": "0.5.15",
4
4
  "description": "express-ext",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./src/index.ts",
package/src/http.ts CHANGED
@@ -117,7 +117,7 @@ export function queryRequiredNumber(req: Request, res: Response, name: string):
117
117
  res.status(400).end(`'${name}' is not a valid number`)
118
118
  return undefined
119
119
  }
120
- const n = parseFloat(v)
120
+ const n = parseFloat(v as string)
121
121
  return n
122
122
  }
123
123
  export function queryNumber(req: Request, name: string, d: number): number {
@@ -129,7 +129,7 @@ export function queryNumber(req: Request, name: string, d: number): number {
129
129
  if (isNaN(v as any)) {
130
130
  return d
131
131
  }
132
- const n = parseFloat(v)
132
+ const n = parseFloat(v as string)
133
133
  return n
134
134
  }
135
135
  export function queryRequiredDate(req: Request, res: Response, name: string): Date | undefined {
@@ -170,11 +170,11 @@ export function param(req: Request, res: Response, name: string): string | undef
170
170
  res.status(400).end(`'${name}' cannot be empty`)
171
171
  return undefined
172
172
  }
173
- return v
173
+ return v as string
174
174
  }
175
175
  export const getParam = param
176
176
  export function params(req: Request, name: string, d?: string[], split?: string): string[] | undefined {
177
- const v = req.params[name]
177
+ const v = req.params[name] as string
178
178
  if (!v || v.length === 0) {
179
179
  return d
180
180
  }
@@ -185,7 +185,7 @@ export function params(req: Request, name: string, d?: string[], split?: string)
185
185
  }
186
186
  export const getParams = params
187
187
  export function getRequiredParameters(req: Request, res: Response, name: string, split?: string): string[] | undefined {
188
- const v = req.params[name]
188
+ const v = req.params[name] as string
189
189
  if (!v || v.length === 0) {
190
190
  res.status(400).end(`'${name}' cannot be empty`)
191
191
  return undefined
@@ -205,7 +205,7 @@ export function getRequiredNumber(req: Request, res: Response, name: string): nu
205
205
  res.status(400).end(`'${name}' must be a number`)
206
206
  return undefined
207
207
  }
208
- const n = parseFloat(v)
208
+ const n = parseFloat(v as string)
209
209
  return n
210
210
  }
211
211
  export function getNumber(req: Request, name: string, d?: number): number | undefined {
@@ -216,7 +216,7 @@ export function getNumber(req: Request, name: string, d?: number): number | unde
216
216
  if (isNaN(v as any)) {
217
217
  return d
218
218
  }
219
- const n = parseFloat(v)
219
+ const n = parseFloat(v as string)
220
220
  return n
221
221
  }
222
222
  export function getInteger(req: Request, name: string, d?: number): number | undefined {
@@ -227,7 +227,7 @@ export function getInteger(req: Request, name: string, d?: number): number | und
227
227
  if (isNaN(v as any)) {
228
228
  return d
229
229
  }
230
- const n = parseFloat(v)
230
+ const n = parseFloat(v as string)
231
231
  const s = n.toFixed(0)
232
232
  return parseFloat(s)
233
233
  }
package/src/index.ts CHANGED
@@ -20,7 +20,7 @@ export {
20
20
  Controller as Handler,
21
21
  LoadSearchController as LoadSearchHandler,
22
22
  Service as LowCodeService,
23
- SearchController as SearchHandler
23
+ SearchController as SearchHandler,
24
24
  }
25
25
 
26
26
  export * from "./access"
@@ -57,7 +57,7 @@ export class SavedController {
57
57
  protected id: string
58
58
  save(req: Request, res: Response) {
59
59
  const userId: string = res.locals[this.userId]
60
- const id = req.params[this.id]
60
+ const id = req.params[this.id] as string
61
61
  if (!id || id.length === 0) {
62
62
  res.status(400).end(`'${this.id}' cannot be empty`)
63
63
  return
@@ -76,7 +76,7 @@ export class SavedController {
76
76
  }
77
77
  remove(req: Request, res: Response) {
78
78
  const userId: string = res.locals[this.userId]
79
- const id = req.params[this.id]
79
+ const id = req.params[this.id] as string
80
80
  if (!id || id.length === 0) {
81
81
  res.status(400).end(`'${this.id}' cannot be empty`)
82
82
  return
@@ -110,7 +110,7 @@ export class FollowController {
110
110
  protected id: string
111
111
  follow(req: Request, res: Response) {
112
112
  const userId: string = res.locals[this.userId]
113
- const id = req.params[this.id]
113
+ const id = req.params[this.id] as string
114
114
  if (!id || id.length === 0) {
115
115
  res.status(400).end(`'${this.id}' cannot be empty`)
116
116
  return
@@ -129,7 +129,7 @@ export class FollowController {
129
129
  }
130
130
  unfollow(req: Request, res: Response) {
131
131
  const userId: string = res.locals[this.userId]
132
- const id = req.params[this.id]
132
+ const id = req.params[this.id] as string
133
133
  if (!id || id.length === 0) {
134
134
  res.status(400).end(`'${this.id}' cannot be empty`)
135
135
  return
@@ -162,9 +162,9 @@ export class UserReactionController {
162
162
  }
163
163
  id: string
164
164
  react(req: Request, res: Response) {
165
- const id = req.params.id
166
- const author = req.params.author
167
- const reaction = req.params.reaction
165
+ const id = req.params.id as string
166
+ const author = req.params.author as string
167
+ const reaction = req.params.reaction as string
168
168
  if (!id || id.length === 0) {
169
169
  res.status(400).end(`'${this.id}' cannot be empty`)
170
170
  return
@@ -185,9 +185,9 @@ export class UserReactionController {
185
185
  .catch((err) => handleError(err, res, this.log))
186
186
  }
187
187
  unreact(req: Request, res: Response) {
188
- const id = req.params.id
189
- const author = req.params.author
190
- const reaction = req.params.reaction
188
+ const id = req.params.id as string
189
+ const author = req.params.author as string
190
+ const reaction = req.params.reaction as string
191
191
  if (!id || id.length === 0) {
192
192
  res.status(400).end(`'${this.id}' cannot be empty`)
193
193
  return
@@ -208,8 +208,8 @@ export class UserReactionController {
208
208
  .catch((err) => handleError(err, res, this.log))
209
209
  }
210
210
  checkReaction(req: Request, res: Response) {
211
- const id = req.params.id
212
- const author = req.params.author
211
+ const id = req.params.id as string
212
+ const author = req.params.author as string
213
213
  if (!id || id.length === 0) {
214
214
  res.status(400).end(`'${this.id}' cannot be empty`)
215
215
  return