generated from Arquisoft/dede_0
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #217 from Arquisoft/master-dev
Mejoras finales
- Loading branch information
Showing
66 changed files
with
2,721 additions
and
2,415 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: CI Develop Branch | ||
|
||
on: | ||
push: | ||
branches: | ||
- 'dev' | ||
|
||
jobs: | ||
unit-test-webapp: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: webapp | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
- run: npm ci | ||
- run: npm test | ||
- uses: codecov/codecov-action@v2 | ||
unit-test-restapi: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: restapi | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: 16 | ||
- run: touch .env | ||
- run: echo "${{ secrets.ENV }}" > .env | ||
- run: cp .env ./tests/.env | ||
- run: npm ci | ||
- run: npm test | ||
- uses: codecov/codecov-action@v2 | ||
# e2e-tests: | ||
# needs: [unit-test-webapp, unit-test-restapi] | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - uses: actions/checkout@v2 | ||
# - uses: actions/setup-node@v2 | ||
# with: | ||
# node-version: 16 | ||
# - run: npm --prefix webapp install | ||
# - run: npm --prefix restapi install | ||
# - run: npm --prefix webapp run build | ||
# - run: npm --prefix webapp run test:e2e |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { Request, Response } from 'express'; | ||
const Order = require('../models/order') | ||
|
||
//funciones | ||
const findAllOrders = async (req: Request, res: Response) => { | ||
|
||
//llamada al repositorio | ||
const orders = await Order.find() | ||
|
||
return res.status(200).send(orders); | ||
|
||
} | ||
|
||
const findOrder = async (req: Request, res: Response) => { | ||
|
||
const order = await Order.findById(req.params.id) | ||
|
||
return res.status(200).send(order); | ||
|
||
} | ||
|
||
const findOrderByClient = async (req: Request, res: Response) => { | ||
|
||
const order = await Order.find({user: req.params.userName}) | ||
|
||
return res.status(200).send(order); | ||
|
||
} | ||
|
||
const deleteOrder = async (req: Request, res: Response) => { | ||
|
||
//llamada al respositorio | ||
await Order.findByIdAndDelete(req.params.id) | ||
|
||
return res.status(200).send({msg:"Pedido eliminado"}); | ||
|
||
} | ||
|
||
const updateOrder = async (req: Request, res: Response) => { | ||
|
||
const { id } = req.params | ||
|
||
const {_id,user, ...other} = req.body | ||
|
||
//lo actualizamos | ||
try{ | ||
await Order.findByIdAndUpdate(id, other) | ||
return res.status(200).send({msg:"Pedido actualizado"}); | ||
} catch (e){ | ||
console.log(e); | ||
res.status(400).send({msg: e}); | ||
} | ||
} | ||
|
||
const addOrder = async (req: Request, res: Response) => { | ||
const orderData = req.body; | ||
|
||
//creamos nuevo producto | ||
const order = new Order({ | ||
user:orderData.user, | ||
products: orderData.products, | ||
order_date: orderData.order_date, | ||
status: orderData.status, | ||
shipping_address: orderData.shipping_address | ||
}); | ||
|
||
//lo guardamos | ||
try{ | ||
await order.save() | ||
return res.status(200).send(order); | ||
} catch (e){ | ||
console.log(e); | ||
res.status(400).send({msg:"Pedido no añadido"}); | ||
} | ||
} | ||
|
||
module.exports = { | ||
addOrder, | ||
findAllOrders, | ||
findOrder, | ||
findOrderByClient, | ||
updateOrder, | ||
deleteOrder | ||
} |
Oops, something went wrong.