Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added modulo6/.gitignore
Empty file.
4 changes: 4 additions & 0 deletions modulo6/heranca-polimorfismo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
package-lock.json
build
.env
31 changes: 31 additions & 0 deletions modulo6/heranca-polimorfismo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "heranca-polimorfismo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "ts-node-dev ./src/endpoints/index.ts",
"start": "tsc && node ./build/index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},

"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@types/knex": "^0.16.1",
"@types/mysql": "^2.15.21",
"@types/node": "^18.0.4",
"knex": "^2.1.0",
"mysql": "^2.18.1",
"ts-node-dev": "^2.0.0",
"typescript": "^4.7.4"
},
"dependencies": {
"@types/cors": "^2.8.12",
"@types/express": "^4.17.13",
"cors": "^2.8.5",
"dotenv": "^16.0.1",
"express": "^4.18.1"
}
}
3 changes: 3 additions & 0 deletions modulo6/heranca-polimorfismo/request.rest
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// padrão
GET http://localhost:3003/
###
21 changes: 21 additions & 0 deletions modulo6/heranca-polimorfismo/src/data/BaseDatabase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import knex from "knex"
import dotenv from "dotenv"

dotenv.config()

export class BaseDatabase {

protected connection = knex({
client: "mysql",
connection: {
host: process.env.DB_HOST,
port: 3306,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_SCHEMA,
multipleStatements: true
}
})
}


53 changes: 53 additions & 0 deletions modulo6/heranca-polimorfismo/src/data/User.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
class User {
private id: string;
private email: string;
private name: string;
private password: string;

constructor(
id: string,
email: string,
name: string,
password: string
){
console.log("Chamando o construtor da classe User")
this.id = id
this.email = email
this.name = name
this.password = password
}

public getId(): string {
return this.id
}

public getEmail(): string {
return this.email
}

public getName(): string {
return this.name
}
}

//------------- exercício2----------------
class Customer extends User {
public purchaseTotal: number = 0;
private creditCard: string;

constructor(
id: string,
email: string,
name: string,
password: string,
creditCard: string
) {
super(id, email, name, password);
console.log("Chamando o construtor da classe Customer");
this.creditCard = creditCard;
}

public getCreditCard(): string {
return this.creditCard;
}
}
19 changes: 19 additions & 0 deletions modulo6/heranca-polimorfismo/src/endpoints/app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import express from "express"
import cors from "cors"
import { AddressInfo } from "net"

export const app = express()

app.use(express.json())
app.use(cors())

const server = app.listen(process.env.PORT || 3003, () => {
if (server) {
const address = server.address() as AddressInfo;
console.log(`Server is running in http://localhost:${address.port}`);
//console.log(`Server is running in ${address.address}:${address.port}`);

} else {
console.error(`Failure upon starting server.`);
}
})
4 changes: 4 additions & 0 deletions modulo6/heranca-polimorfismo/src/endpoints/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { app } from "./app";
//import {getexemplo } from "./endpoints";

//app.get("/", getexemplo)
Empty file.
12 changes: 12 additions & 0 deletions modulo6/heranca-polimorfismo/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"compilerOptions": {
"target": "es6" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"outDir": "./build" /* Redirect output structure to the directory. */,
"rootDir": "./src" /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */,
"strict": true /* Enable all strict type-checking options. */,
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
"resolveJsonModule": true
}
}
Loading