Hands-On RESTful Web Services with TypeScript 3 by Biharck Muniz Araújo

Hands-On RESTful Web Services with TypeScript 3 by Biharck Muniz Araújo

Author:Biharck Muniz Araújo
Language: eng
Format: epub, mobi
Tags: COM000000 - COMPUTERS / General, COM082000 - COMPUTERS / Bioinformatics, COM006000 - COMPUTERS / Buyer
Publisher: Packt Publishing
Published: 2019-03-25T08:35:34+00:00


export let getAllOrders = (req: Request, res: Response, next: NextFunction) => {

const limit = req.query.limit || orders.length

const offset = req.query.offset || 0

const filteredOrders = _(orders)

.drop(offset)

.take(limit)

.value()

res.format({

json: () => {

res.type(APPLICATION_JSON)

res.status(200).send(filteredOrders)

},

default: () => {

res.status(406).send()

},

})

}

export let addOrder = (req: Request, res: Response, next: NextFunction) => {

const order: Order = {

// generic random value from 1 to 100 only for tests so far

id: Math.floor(Math.random() * 100) + 1,

userId: req.body.userId,

quantity: req.body.quantity,

shipDate: req.body.shipDate,

status: OrderStatus.Placed,

complete: false,

}



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.