From 82a87c64331b773715be2a5bad0d3ad67bf3da2e Mon Sep 17 00:00:00 2001 From: Digoleira Date: Mon, 13 Jun 2022 18:33:19 -0300 Subject: [PATCH] Projeto Sistema Bancario --- modulo5/projeto-sistema-bancario/.gitignore | 3 + modulo5/projeto-sistema-bancario/package.json | 24 +++++ modulo5/projeto-sistema-bancario/src/index.ts | 96 +++++++++++++++++++ .../projeto-sistema-bancario/tsconfig.json | 14 +++ 4 files changed, 137 insertions(+) create mode 100644 modulo5/projeto-sistema-bancario/.gitignore create mode 100644 modulo5/projeto-sistema-bancario/package.json create mode 100644 modulo5/projeto-sistema-bancario/src/index.ts create mode 100644 modulo5/projeto-sistema-bancario/tsconfig.json diff --git a/modulo5/projeto-sistema-bancario/.gitignore b/modulo5/projeto-sistema-bancario/.gitignore new file mode 100644 index 0000000..a049075 --- /dev/null +++ b/modulo5/projeto-sistema-bancario/.gitignore @@ -0,0 +1,3 @@ +node_modules +package-lock.json +build \ No newline at end of file diff --git a/modulo5/projeto-sistema-bancario/package.json b/modulo5/projeto-sistema-bancario/package.json new file mode 100644 index 0000000..6d8326a --- /dev/null +++ b/modulo5/projeto-sistema-bancario/package.json @@ -0,0 +1,24 @@ +{ + "name": "projeto-sistema-bancario", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "dev": "ts-node-dev ./src/index.ts", + "start": "tsc && node ./build/index.js", + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "devDependencies": { + "@types/cors": "^2.8.12", + "@types/express": "^4.17.13", + "ts-node-dev": "^2.0.0", + "typescript": "^4.7.3" + }, + "dependencies": { + "cors": "^2.8.5", + "express": "^4.18.1" + } +} diff --git a/modulo5/projeto-sistema-bancario/src/index.ts b/modulo5/projeto-sistema-bancario/src/index.ts new file mode 100644 index 0000000..c81f262 --- /dev/null +++ b/modulo5/projeto-sistema-bancario/src/index.ts @@ -0,0 +1,96 @@ +// dentro do index.ts, fazer importações e ativar o Express e Cors. + +import express, {Express, Request, Response} from 'express' +import cors from 'cors' + +const app: Express = express(); + +app.use(express.json()); +app.use(cors()); + +// a função express() inicia a aplicação web com express +// os .use() ativam os módulos de Bodyparser e Cors + +// esse código + essa importação para criar o servidor: +// por performance, é bom o servidor ser o último trecho de código do documento + + +import { AddressInfo } from "net"; + +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}`); + } else { + console.error(`Failure upon starting server.`); + } +}); + +//--------------------------------------------------------------------------// + + +app.post("/create", (req: Request, Res: Response) => { + +try { + +} +catch{ + +} + +}) + +app.post("/create", (req: Request, Res: Response) => { + + try { + + } + catch{ + + } + + }) + +app.post("/addBalance", (req: Request, Res: Response) => { + + try { + + } + catch{ + + } + + }) + +app.get("/balance", (req: Request, Res: Response) => { + + try { + + } + catch{ + + } + + }) + +app.get("/payment", (req: Request, Res: Response) => { + + try { + + } + catch{ + + } + + }) + +app.get("/transfer", (req: Request, Res: Response) => { + + try { + + } + catch{ + + } + + }) \ No newline at end of file diff --git a/modulo5/projeto-sistema-bancario/tsconfig.json b/modulo5/projeto-sistema-bancario/tsconfig.json new file mode 100644 index 0000000..5e55118 --- /dev/null +++ b/modulo5/projeto-sistema-bancario/tsconfig.json @@ -0,0 +1,14 @@ +{ + "compilerOptions": { + "target": "es6", + "module": "commonjs", + "sourceMap": true, + "outDir": "./build", + "rootDir": "./src", + "removeComments": true, + "strict": true, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true + } + } \ No newline at end of file