Commit 1e3f8088 authored by Rafael Dias's avatar Rafael Dias

Merge branch 'issue/15' into 'develop'

Issue #15: Adicionada rota para comprar jogo

Closes #15

See merge request !17
parents 14935c41 2d4f788c
Pipeline #22259 passed with stage
in 1 minute and 13 seconds
......@@ -187,6 +187,12 @@
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-2.0.1.tgz",
"integrity": "sha512-FwI9gX75FgVBJ7ywgnq/P7tw+/o1GUbtP0KzbtusLigAOgIgNISRK0ZPl4qertvXSIE8YbsVJueQ90cDt9YYyw=="
},
"@types/minimatch": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz",
"integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==",
"dev": true
},
"@types/mocha": {
"version": "5.2.7",
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.7.tgz",
......@@ -329,6 +335,15 @@
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=",
"dev": true
},
"backbone": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/backbone/-/backbone-1.4.0.tgz",
"integrity": "sha512-RLmDrRXkVdouTg38jcgHhyQ/2zjg7a8E6sz2zxfz21Hh17xDJYUHBZimVIt5fUyS8vbfpeSmTL3gUjTEvUV3qQ==",
"dev": true,
"requires": {
"underscore": ">=1.8.3"
}
},
"balanced-match": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
......@@ -865,6 +880,17 @@
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
},
"fs-extra": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz",
"integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==",
"dev": true,
"requires": {
"graceful-fs": "^4.2.0",
"jsonfile": "^4.0.0",
"universalify": "^0.1.0"
}
},
"fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
......@@ -969,6 +995,12 @@
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",
"dev": true
},
"highlight.js": {
"version": "9.16.2",
"resolved": "https://registry.npmjs.org/highlight.js/-/highlight.js-9.16.2.tgz",
"integrity": "sha512-feMUrVLZvjy0oC7FVJQcSQRqbBq9kwqnYE4+Kj9ZjbHh3g+BisiPgF49NyQbVLNdrL/qqZr3Ca9yOKwgn2i/tw==",
"dev": true
},
"hosted-git-info": {
"version": "2.8.5",
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.5.tgz",
......@@ -1016,6 +1048,12 @@
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"interpret": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/interpret/-/interpret-1.2.0.tgz",
"integrity": "sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw==",
"dev": true
},
"ipaddr.js": {
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz",
......@@ -1186,6 +1224,12 @@
"handlebars": "^4.1.2"
}
},
"jquery": {
"version": "3.4.1",
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.4.1.tgz",
"integrity": "sha512-36+AdBzCL+y6qjw5Tx7HgzeGCzC81MDDgaUP8ld2zhx58HdqXGoBd+tHdrBMiyjGQs0Hxs/MLZTu/eHNJJuWPw==",
"dev": true
},
"js-tokens": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz",
......@@ -1214,6 +1258,15 @@
"integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==",
"dev": true
},
"jsonfile": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
"dev": true,
"requires": {
"graceful-fs": "^4.1.6"
}
},
"load-json-file": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz",
......@@ -1275,6 +1328,12 @@
"yallist": "^2.1.2"
}
},
"lunr": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.8.tgz",
"integrity": "sha512-oxMeX/Y35PNFuZoHp+jUj5OSEmLCaIH4KTFJh7a93cHBoFmpw2IoPs22VIz7vyO2YUnx2Tn9dzIwO2P/4quIRg==",
"dev": true
},
"make-dir": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/make-dir/-/make-dir-2.1.0.tgz",
......@@ -1298,6 +1357,12 @@
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.5.tgz",
"integrity": "sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g=="
},
"marked": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/marked/-/marked-0.7.0.tgz",
"integrity": "sha512-c+yYdCZJQrsRjTPhUx7VKkApw9bwDkNbHUKo1ovgcfDjb2kc8rLuRbIFyXL5WOEUwzSSKo3IXpph2K6DqB/KZg==",
"dev": true
},
"media-typer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
......@@ -1793,6 +1858,12 @@
"integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==",
"dev": true
},
"progress": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz",
"integrity": "sha512-7PiHtLll5LdnKIMw100I+8xJXR5gW2QwWYkT6iJva0bXitZKa/XMrSbdmg3r2Xnaidz9Qumd0VPaMrZlF9V9sA==",
"dev": true
},
"proxy-addr": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz",
......@@ -1865,6 +1936,15 @@
"util-deprecate": "~1.0.1"
}
},
"rechoir": {
"version": "0.6.2",
"resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.6.2.tgz",
"integrity": "sha1-hSBLVNuoLVdC4oyWdW70OvUOM4Q=",
"dev": true,
"requires": {
"resolve": "^1.1.6"
}
},
"release-zalgo": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz",
......@@ -1974,6 +2054,17 @@
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz",
"integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw=="
},
"shelljs": {
"version": "0.8.3",
"resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.3.tgz",
"integrity": "sha512-fc0BKlAWiLpwZljmOvAOTE/gXawtCoNrP5oaY7KIaQbbyHeQVg01pSEuEGvGh3HEdBU4baCD7wQBwADmM/7f7A==",
"dev": true,
"requires": {
"glob": "^7.0.0",
"interpret": "^1.0.0",
"rechoir": "^0.6.2"
}
},
"signal-exit": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",
......@@ -2272,6 +2363,54 @@
"mime-types": "~2.1.24"
}
},
"typedoc": {
"version": "0.15.0",
"resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.15.0.tgz",
"integrity": "sha512-NOtfq5Tis4EFt+J2ozhVq9RCeUnfEYMFKoU6nCXCXUULJz1UQynOM+yH3TkfZCPLzigbqB0tQYGVlktUWweKlw==",
"dev": true,
"requires": {
"@types/minimatch": "3.0.3",
"fs-extra": "^8.1.0",
"handlebars": "^4.1.2",
"highlight.js": "^9.15.8",
"lodash": "^4.17.15",
"marked": "^0.7.0",
"minimatch": "^3.0.0",
"progress": "^2.0.3",
"shelljs": "^0.8.3",
"typedoc-default-themes": "^0.6.0",
"typescript": "3.5.x"
},
"dependencies": {
"typescript": {
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.3.tgz",
"integrity": "sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==",
"dev": true
}
}
},
"typedoc-default-themes": {
"version": "0.6.0",
"resolved": "https://registry.npmjs.org/typedoc-default-themes/-/typedoc-default-themes-0.6.0.tgz",
"integrity": "sha512-MdTROOojxod78CEv22rIA69o7crMPLnVZPefuDLt/WepXqJwgiSu8Xxq+H36x0Jj3YGc7lOglI2vPJ2GhoOybw==",
"dev": true,
"requires": {
"backbone": "^1.4.0",
"jquery": "^3.4.1",
"lunr": "^2.3.6",
"underscore": "^1.9.1"
}
},
"typedoc-plugin-markdown": {
"version": "2.2.11",
"resolved": "https://registry.npmjs.org/typedoc-plugin-markdown/-/typedoc-plugin-markdown-2.2.11.tgz",
"integrity": "sha512-tzBJJjM23DZMbfV+wds+M/IH8xNUVX4iyvABWyL9+gQZY6Fwbf2xGur2Dg6jNXGn2OsuqjZRI3dvSeqw64MSMA==",
"dev": true,
"requires": {
"fs-extra": "^8.1.0"
}
},
"typescript": {
"version": "3.6.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.6.3.tgz",
......@@ -2297,6 +2436,18 @@
}
}
},
"underscore": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz",
"integrity": "sha512-5/4etnCkd9c8gwgowi5/om/mYO5ajCaOgdzj/oW+0eQV9WxKBDZw5+ycmKmeaTXjInS/W0BzpGLo2xR2aBwZdg==",
"dev": true
},
"universalify": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==",
"dev": true
},
"unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
......
......@@ -6,7 +6,8 @@
"scripts": {
"start": "node index",
"lint": "tslint -s node_modules/tslint_stylish -t stylish src/**/*.ts",
"test": "ts-node node_modules/nyc/bin/nyc.js mocha"
"test": "ts-node node_modules/nyc/bin/nyc.js mocha",
"doc-code": "typedoc --mode 'file' --module 'commonjs' --target 'ES6' --ignoreCompilerErrors --exclude '**/*.spec.ts' --out 'doc/code' 'src'"
},
"repository": {
"type": "git",
......@@ -53,6 +54,8 @@
"mocha": "^6.2.1",
"nyc": "^14.1.1",
"supertest": "^4.0.2",
"tslint": "^5.20.0"
"tslint": "^5.20.0",
"typedoc": "^0.15.0",
"typedoc-plugin-markdown": "^2.2.11"
}
}
......@@ -20,7 +20,8 @@ export class DBHandler {
, 110
)
, new Jogador("Player2", [], [], 100)
, new Jogador("Player3", [], [], 110)
, new Jogador("Player3", [], [], 400)
, new Jogador("Player4", [], [], 400)
];
this.jogos = [
new Jogo("Overcooked", "fracasso", "fracasso", new Date("2010-01-01"), 200),
......@@ -74,7 +75,7 @@ export class DBHandler {
}
if (argument === "compras") {
for (let i = 0; i < this.compras.length; ++i) {
nomes.push(this.compras[i].writeinfo());
nomes.push(this.compras[i].getBuy());
}
return nomes;
}
......
interface CompraOpts {
name: string;
game: string;
price: number;
date: Date;
owner?: string;
}
import { Jogador } from "./jogador";
import { Jogo } from "./jogo";
......@@ -6,18 +14,22 @@ export class Compra {
private game: Jogo;
private date: Date;
private owner: Jogador;
constructor(buyer, game, date, owner) {
constructor(buyer, game, date, owner?) {
this.buyer = buyer;
this.game = game;
this.date = date;
this.owner = owner;
this.owner = (owner) ? owner : null;
}
public writeinfo(): CompraOpts {
return {
name: this.buyer.getName()
, game: this.game.getName()
, price: this.game.getPrice()
, date: this.date
, owner: (this.owner === this.buyer) ? this.buyer.getName() : this.owner.getName()
};
}
public writeinfo(): string {
if (this.buyer === this.owner) {
return "O jogador " + this.buyer.getName() + " comprou o jogo " + this.game.getName() + " para ele mesmo." + " Preço: " + this.game.getPrice() + "R$" + " Data: " + this.date + ".";
}
else {
return "O jogador " + this.buyer.getName() + " comprou o jogo " + this.game.getName() + " para o jogador " + this.owner.getName() + " Preço: " + this.game.getPrice() + "R$" + " Data: " + this.date + ".";
}
public getBuy(): string{
return "O jogador " + this.buyer.getName() + " comprou o jogo " + this.game.getName() + " de preço R$ " + this.game.getPrice() + " na data " + this.date + ".";
}
}
......@@ -39,25 +39,35 @@ export class Jogador {
public getmoney(): number {
return this.carteira;
}
public buy(jogo: Jogo, jogador: Jogador): number {
/**
* Verifica a validade da compra
* @param jogo O jogo que o jogador está tentando comprar
* @returns Código correspondente à possibilidade de fazer a compra
*/
public verifyBuy(jogo: Jogo): number {
if (this.carteira < jogo.getPrice()) {
return 2;
}
if (this.name === jogador.getName()) {
if (this.jogos.some((value: string) => {
return value === jogo.getName();
})) {
return 4;
}
/**
* Retorna 0 para o caso do jogador não ter dinheiro
*/
return 0;
} else {
if (jogador.library().some((value: string) => {
return value === jogo.getName();
})) {
return 3;
}
}
if (this.jogos.some((value: string) => {
return value === jogo.getName();
})) {
/**
* Retorna 1 para o caso do jogador já possuir o jogo
*/
return 1;
}
/**
* Retorna 2 para o caso do jogador poder comprar o jogo
*/
return 2;
}
public buy(game: Jogo) {
this.carteira = this.carteira - game.getPrice();
this.jogos.push(game.getName());
}
public addfriend(jogador: Jogador) {
......@@ -86,12 +96,6 @@ export class Jogador {
public addcredit(amount: number): number {
return this.carteira = this.carteira + amount;
}
public newmoney(amout: number): number {
return this.carteira = this.carteira - amout;
}
public addgame(game: Jogo) {
return this.jogos.push(game.getName());
}
public balance(): string {
return "Balanço da carteira de " + this.name + ": " + this.carteira + "R$";
}
......
......@@ -11,8 +11,8 @@ describe("Arquivo main.ts", () => {
.expect(200)
.expect((res: any) => {
expect(res.body).to.be.an("array");
expect(res.body).to.have.length(3);
for (let i = 0; i < 3; ++i) {
expect(res.body).to.have.length(4);
for (let i = 0; i < 4; ++i) {
expect(res.body[i]).to.be.eql("Player" + (i + 1));
}
})
......@@ -619,4 +619,109 @@ describe("Arquivo main.ts", () => {
})
.end(done);
});
// Teste de sucesso em comprar um jogo.
it("Sucesso em comprar um jogo", (done) => {
request(server)
.post("/compra/2/0")
// .send(undefined)
.expect(200)
.expect((res: any) => {
expect(res.body).to.be.an("object");
expect(res.body).to.have.property("name");
expect(res.body.name).to.be.an("string");
expect(res.body.name).to.be.eql("Player4");
expect(res.body).to.have.property("game");
expect(res.body.game).to.be.an("string");
expect(res.body.game).to.be.eql("Overcooked");
expect(res.body).to.have.property("price");
expect(res.body.price).to.be.an("number");
expect(res.body.price).to.be.eql(200);
expect(res.body).to.have.property("date");
expect(res.body.date).to.be.an("string");
expect(res.body.date).to.includes("2019-07-13");
expect(res.body).to.have.property("owner");
expect(res.body.owner).to.be.an("string");
expect(res.body.owner).to.be.eql("Player4");
})
.end(done);
});
// Teste de falha em comprar um jogo
it("Falha em comprar um jogo -- jogador inválido", (done) => {
request(server)
.post("/compra/asadelta/2")
.expect(400)
.expect((res: any) => {
expect(res.body).to.be.an("object");
expect(res.body).to.have.property("msg");
expect(res.body.msg).to.be.an("string");
expect(res.body.msg).to.be.eql("Jogador inválido");
})
.end(done);
});
it("Falha em comprar um jogo -- jogo inválido", (done) => {
request(server)
.post("/compra/2/asadelta")
.expect(400)
.expect((res: any) => {
expect(res.body).to.be.an("object");
expect(res.body).to.have.property("msg");
expect(res.body.msg).to.be.an("string");
expect(res.body.msg).to.be.eql("Jogo inválido");
})
.end(done);
});
it("Falha em comprar um jogo -- jogador não existe no banco", (done) => {
request(server)
.post("/compra/777555/2")
.expect(400)
.expect((res: any) => {
expect(res.body).to.be.an("object");
expect(res.body).to.have.property("msg");
expect(res.body.msg).to.be.an("string");
expect(res.body.msg).to.be.eql("Jogador não existe no banco");
})
.end(done);
});
it("Falha em comprar um jogo -- jogo não existe no banco", (done) => {
request(server)
.post("/compra/2/777555")
.expect(400)
.expect((res: any) => {
expect(res.body).to.be.an("object");
expect(res.body).to.have.property("msg");
expect(res.body.msg).to.be.an("string");
expect(res.body.msg).to.be.eql("Jogo não existe no banco");
})
.end(done);
});
it("Falha em comprar um jogo -- jogador não tem fundos", (done) => {
request(server)
.post("/compra/0/0")
.expect(400)
.expect((res: any) => {
expect(res.body).to.be.an("object");
expect(res.body).to.have.property("msg");
expect(res.body.msg).to.be.an("string");
expect(res.body.msg).to.be.eql("Saldo insuficiente");
})
.end(done);
});
it("Falha em comprar um jogo -- jogador já tem o jogo", (done) => {
request(server)
.post("/compra/2/0")
.expect(400)
.expect((res: any) => {
expect(res.body).to.be.an("object");
expect(res.body).to.have.property("msg");
expect(res.body.msg).to.be.an("string");
expect(res.body.msg).to.be.eql("O jogador já tem o jogo");
})
.end(done);
});
});
......@@ -145,7 +145,7 @@ app.get("/jogadores", (req: Request, res: express.Response) => {
res.json(req.db.list("jogadores"));
});
app.get("/compras", (req: Request, res: express.Response) => {
/*app.get("/compras", (req: Request, res: express.Response) => {
res.json(req.db.list("compras"));
});
......@@ -162,7 +162,8 @@ app.get("/comprar", (req: Request, res: express.Response) => {
res.json("Você já possui este jogo.");
}
});
*/
/*
app.get("/comprar/amigo", (req: Request, res: express.Response) => {
if (req.db.readplayer(0).buy(req.db.readgame(0), req.db.readplayer(1)) === 2) {
res.json("Saldo insuficiente. Adicione mais dinheiro a sua conta.");
......@@ -177,6 +178,7 @@ app.get("/comprar/amigo", (req: Request, res: express.Response) => {
res.json("O jogador " + req.db.readplayer(1).getName() + " já possui este jogo.");
}
});
*/
app.get("/jogos-em-comum", (req: Request, res: express.Response) => {
res.json(req.db.readplayer(0).library().filter((value: string) => {
......@@ -335,6 +337,67 @@ app.delete("/amizade/:idA/:idB", (req: Request, res: express.Response) => {
res.json({msg: "Sucesso em desfazer amizade"});
});
/**
* Faz uma compra para o @param idJogador do jogo @param idJogo
* @returns A última compra feita
*/
app.post("/compra/:idJogador/:idJogo", (req: Request, res: express.Response) => {
const idJogador: number = Math.abs(parseInt(req.params.idJogador, 10));
const idJogo: number = Math.abs(parseInt(req.params.idJogo, 10));
/**
* Testes de erro
*/
/** Parâmetros não numéricos retornam erro */
if (isNaN(idJogador)) {
res.status(400).json({msg: "Jogador inválido"});
return;
}
if (isNaN(idJogo)) {
res.status(400).json({msg: "Jogo inválido"});
return;
}
/** Parâmetros excedem o tamanho da base de dados */
if (idJogador >= req.db.list("jogadores").length) {
res.status(400).json({msg: "Jogador não existe no banco"});
return;
}
if (idJogo >= req.db.list("jogos").length) {
res.status(400).json({msg: "Jogo não existe no banco"});
return;
}
const Comprador: Jogador = req.db.readplayer(idJogador);
const Produto: Jogo = req.db.readgame(idJogo);
/**
* Executa uma ação com base no valor de retorno de verifyBuy
* 0 - Erro por saldo insuficiente
* 1 - Erro por o jogador já ter o jogo
* 2 - Executa a compra com sucesso e a registra no banco de dados
* Default - Casos inesperados.
*/
switch (Comprador.verifyBuy(Produto)) {
case 0:
res.status(400).json({msg: "Saldo insuficiente"});
return;
case 1:
res.status(400).json({msg: "O jogador já tem o jogo"});
return;
case 2:
Comprador.buy(Produto);
const compra = new Compra (Comprador, Produto, new Date("2019-07-13"), Comprador);
req.db.createbuy(compra);
break;
default:
res.status(400).json({msg: "Algo inesperado aconteceu"});
return;
}
res.json(req.db.readbuy(req.db.list("compras").length - 1).writeinfo());
});
app.get("/teste", (req: Request, res: express.Response) => {
res.json({msg: req.db.list("compras")});
});
app.listen(3000);
console.log("Server listening on port 3000");
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment