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
//First generic class | |
class Diablo { | |
private readonly brand = "Lamborghini"; | |
private readonly color = "black"; | |
} | |
//Second generic class | |
class Soul { | |
readonly brand = "Kia"; | |
readonly color = "Red"; |
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
export default interface ICar { | |
readonly brand: string; | |
readonly color: string; | |
getMarketPrice(): Promise<number>; | |
} |
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
import ICar from "./ICar"; | |
class Diablo implements ICar { | |
readonly brand = "Lamborghini"; | |
readonly color = "black"; | |
public getMarketPrice(): Promise<number> { | |
return new Promise((resolve, reject) => { | |
let result = 200; |
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
class clients { | |
public function sendEmail (emailType: string){ | |
if (emailType === 'html'){ | |
let email = parseHtml(this.email); | |
} else if (emailType === 'plainText'){ | |
let email = parsePlainText(this.email); | |
} else if (emailType === 'numeric') { | |
let email = parseNumeric(this.email); | |
} |
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
interface IEmailSend { | |
send(): boolean; | |
} | |
class htmlEmail implements IEmailSend { | |
public function send () { | |
return util.sendEmail(this.email, this.user); | |
} | |
} |
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
function solucao(esquerda, direita){ | |
if (esquerda > direita){ | |
console.log("esquerda ganhando"); | |
} else if (esquerda < direita){ | |
console.log("direita ganhando"); | |
} else if (esquerda + direita === 0){ | |
console.log("nenhum voto"); |
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
import { Request, Response } from "express"; | |
import { pool } from "database"; | |
export class UserController { | |
public async create(req: Request, res: Response) { | |
const { name, password, email } = req.body; | |
if (!name) { | |
return res.status(400).json({ message: "Field name cannot be empty" }); | |
} |
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
import { Application } from "express"; | |
import { UserController } from "../controllers/UserController"; | |
export default function userRoutes(app: Application) { | |
const controller = new UserController(); | |
app.post( | |
"/user", | |
controller.create.bind(controller) | |
); |
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
import { body, ValidationChain } from "express-validator"; | |
export function validatePost(): ValidationChain[] { | |
return [ | |
body("name", "check the field 'name' and try again.") | |
.isString() | |
.isLength({ min: 3, max: 35 }), | |
body("email", "check the field 'email' and try again").isEmail(), |
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
import { Request, Response } from "express"; | |
import { pool } from "database"; | |
import { validationResult } from "express-validator"; | |
export class UserController { | |
public async create(req: Request, res: Response) { | |
try { | |
const errors = validationResult(req); | |
if (!errors.isEmpty()) { |
OlderNewer