express-ext 0.5.0 → 0.5.2

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/lib/index.js CHANGED
@@ -99,7 +99,6 @@ var FollowController = (function () {
99
99
  this.id = id && id.length > 0 ? id : "id"
100
100
  this.follow = this.follow.bind(this)
101
101
  this.unfollow = this.unfollow.bind(this)
102
- this.checkFollow = this.checkFollow.bind(this)
103
102
  }
104
103
  FollowController.prototype.follow = function (req, res) {
105
104
  var _this = this
@@ -141,25 +140,6 @@ var FollowController = (function () {
141
140
  return http_1.handleError(err, res, _this.log)
142
141
  })
143
142
  }
144
- FollowController.prototype.checkFollow = function (req, res) {
145
- var _this = this
146
- var userId = res.locals[this.userId]
147
- var id = req.params[this.id]
148
- if (!id || id.length === 0) {
149
- return res.status(400).end("'" + this.id + "' cannot be empty")
150
- }
151
- if (!userId || userId.length === 0) {
152
- return res.status(400).end("'" + this.userId + "' cannot be empty")
153
- }
154
- this.service
155
- .checkFollow(userId, id)
156
- .then(function (count) {
157
- return res.status(200).json(count).end()
158
- })
159
- .catch(function (err) {
160
- return http_1.handleError(err, res, _this.log)
161
- })
162
- }
163
143
  return FollowController
164
144
  })()
165
145
  exports.FollowController = FollowController
@@ -348,7 +328,7 @@ function escapeHTML(input) {
348
328
  exports.escapeHTML = escapeHTML
349
329
  function generateChip(value, text, noClose, hasStar) {
350
330
  var s = noClose ? "" : '<span class="close" onclick="removeChip(event)"></span>'
351
- var t = hasStar ? '<i className="star highlight"></i>' : ""
331
+ var t = hasStar ? '<i class="star highlight"></i>' : ""
352
332
  return '<div class="chip" data-value="' + escapeHTML(value) + '">' + escapeHTML(text) + t + s + "</div>"
353
333
  }
354
334
  exports.generateChip = generateChip
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "express-ext",
3
- "version": "0.5.0",
3
+ "version": "0.5.2",
4
4
  "description": "express-ext",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./src/index.ts",
package/src/index.ts CHANGED
@@ -93,7 +93,6 @@ export class SavedController {
93
93
  export interface FollowService {
94
94
  follow(id: string, target: string): Promise<number>
95
95
  unfollow(id: string, target: string): Promise<number>
96
- checkFollow(id: string, target: string): Promise<number>
97
96
  }
98
97
  // tslint:disable-next-line:max-classes-per-file
99
98
  export class FollowController {
@@ -102,11 +101,10 @@ export class FollowController {
102
101
  this.id = id && id.length > 0 ? id : "id"
103
102
  this.follow = this.follow.bind(this)
104
103
  this.unfollow = this.unfollow.bind(this)
105
- this.checkFollow = this.checkFollow.bind(this)
106
104
  }
107
105
  protected userId: string
108
106
  protected id: string
109
- follow(req: Request, res: Response): void {
107
+ follow(req: Request, res: Response) {
110
108
  const userId: string = res.locals[this.userId]
111
109
  const id = req.params[this.id]
112
110
  if (!id || id.length === 0) {
@@ -123,7 +121,7 @@ export class FollowController {
123
121
  })
124
122
  .catch((err) => handleError(err, res, this.log))
125
123
  }
126
- unfollow(req: Request, res: Response): void {
124
+ unfollow(req: Request, res: Response) {
127
125
  const userId: string = res.locals[this.userId]
128
126
  const id = req.params[this.id]
129
127
  if (!id || id.length === 0) {
@@ -140,22 +138,6 @@ export class FollowController {
140
138
  })
141
139
  .catch((err) => handleError(err, res, this.log))
142
140
  }
143
- checkFollow(req: Request, res: Response): void {
144
- const userId: string = res.locals[this.userId]
145
- const id = req.params[this.id]
146
- if (!id || id.length === 0) {
147
- return res.status(400).end(`'${this.id}' cannot be empty`)
148
- }
149
- if (!userId || userId.length === 0) {
150
- return res.status(400).end(`'${this.userId}' cannot be empty`)
151
- }
152
- this.service
153
- .checkFollow(userId, id)
154
- .then((count) => {
155
- return res.status(200).json(count).end()
156
- })
157
- .catch((err) => handleError(err, res, this.log))
158
- }
159
141
  }
160
142
  export interface ReactService {
161
143
  react(id: string, author: string, reaction: string): Promise<number>
@@ -171,7 +153,7 @@ export class UserReactionController {
171
153
  this.checkReaction = this.checkReaction.bind(this)
172
154
  }
173
155
  id: string
174
- react(req: Request, res: Response): void {
156
+ react(req: Request, res: Response) {
175
157
  const id = req.params.id
176
158
  const author = req.params.author
177
159
  const reaction = req.params.reaction
@@ -194,7 +176,7 @@ export class UserReactionController {
194
176
  })
195
177
  .catch((err) => handleError(err, res, this.log))
196
178
  }
197
- unreact(req: Request, res: Response): void {
179
+ unreact(req: Request, res: Response) {
198
180
  const id = req.params.id
199
181
  const author = req.params.author
200
182
  const reaction = req.params.reaction
@@ -217,7 +199,7 @@ export class UserReactionController {
217
199
  })
218
200
  .catch((err) => handleError(err, res, this.log))
219
201
  }
220
- checkReaction(req: Request, res: Response): void {
202
+ checkReaction(req: Request, res: Response) {
221
203
  const id = req.params.id
222
204
  const author = req.params.author
223
205
  if (!id || id.length === 0) {
@@ -332,7 +314,7 @@ export function escapeHTML(input: string): string {
332
314
  }
333
315
  export function generateChip(value: string, text: string, noClose?: boolean, hasStar?: boolean): string {
334
316
  const s = noClose ? "" : `<span class="close" onclick="removeChip(event)"></span>`
335
- const t = hasStar ? `<i className="star highlight"></i>` : ""
317
+ const t = hasStar ? `<i class="star highlight"></i>` : ""
336
318
  return `<div class="chip" data-value="${escapeHTML(value)}">${escapeHTML(text)}${t}${s}</div>`
337
319
  }
338
320
  export function generateTags(v?: string[] | null, noClose?: boolean): string {