From 9866d8e18b1976ab29296bdca05bd495c149e2fd Mon Sep 17 00:00:00 2001 From: "rafaelgarcianunes13@gmail.com" Date: Mon, 12 Sep 2022 20:11:44 -0300 Subject: [PATCH] configurando atividade --- modulo5/introducao-autenticacao/.gitignore | 6 ++++ modulo5/introducao-autenticacao/src/index.ts | 30 +++++++++++++++++++ modulo5/introducao-autenticacao/tsconfig.json | 11 +++++++ 3 files changed, 47 insertions(+) create mode 100644 modulo5/introducao-autenticacao/.gitignore create mode 100644 modulo5/introducao-autenticacao/src/index.ts create mode 100644 modulo5/introducao-autenticacao/tsconfig.json diff --git a/modulo5/introducao-autenticacao/.gitignore b/modulo5/introducao-autenticacao/.gitignore new file mode 100644 index 0000000..8a14341 --- /dev/null +++ b/modulo5/introducao-autenticacao/.gitignore @@ -0,0 +1,6 @@ +.env +node_modules +package.json +package-lock.json +build + diff --git a/modulo5/introducao-autenticacao/src/index.ts b/modulo5/introducao-autenticacao/src/index.ts new file mode 100644 index 0000000..7a4504f --- /dev/null +++ b/modulo5/introducao-autenticacao/src/index.ts @@ -0,0 +1,30 @@ +import knex from "knex"; +import dotenv from "dotenv"; +import express from "express"; +import { AddressInfo } from "net"; + +dotenv.config(); + +const connection = knex({ + client: "mysql", + connection: { + host: process.env.DB_HOST, + port: Number(process.env.DB_PORT || "3306"), + user: process.env.DB_USER, + password: process.env.DB_PASSWORD, + database: process.env.DB_SCHEMA, + }, +}); + +const app = express(); + +app.use(express.json()); + +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.`); + } +}); \ No newline at end of file diff --git a/modulo5/introducao-autenticacao/tsconfig.json b/modulo5/introducao-autenticacao/tsconfig.json new file mode 100644 index 0000000..3b3fa40 --- /dev/null +++ b/modulo5/introducao-autenticacao/tsconfig.json @@ -0,0 +1,11 @@ +{ + "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": "./" /* 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. */ + } +} \ No newline at end of file