From 0be3807855d2478510f030221855a23f67022829 Mon Sep 17 00:00:00 2001 From: "rafaelgarcianunes13@gmail.com" Date: Tue, 13 Sep 2022 21:40:16 -0300 Subject: [PATCH] criptografia e user roles --- modulo5/criptografia-e-user-roles/.gitignore | 4 ++++ .../src/connection.ts | 20 +++++++++++++++++++ .../criptografia-e-user-roles/src/index.ts | 17 ++++++++++++++++ .../criptografia-e-user-roles/tsconfig.json | 11 ++++++++++ 4 files changed, 52 insertions(+) create mode 100644 modulo5/criptografia-e-user-roles/.gitignore create mode 100644 modulo5/criptografia-e-user-roles/src/connection.ts create mode 100644 modulo5/criptografia-e-user-roles/src/index.ts create mode 100644 modulo5/criptografia-e-user-roles/tsconfig.json diff --git a/modulo5/criptografia-e-user-roles/.gitignore b/modulo5/criptografia-e-user-roles/.gitignore new file mode 100644 index 0000000..fd1fa8a --- /dev/null +++ b/modulo5/criptografia-e-user-roles/.gitignore @@ -0,0 +1,4 @@ +.env +node_modules +package.json +package-lock.json \ No newline at end of file diff --git a/modulo5/criptografia-e-user-roles/src/connection.ts b/modulo5/criptografia-e-user-roles/src/connection.ts new file mode 100644 index 0000000..df6d08c --- /dev/null +++ b/modulo5/criptografia-e-user-roles/src/connection.ts @@ -0,0 +1,20 @@ +import knex, { Knex } from "knex"; +import dotenv from "dotenv"; + +dotenv.config(); + + +export class BaseDatabase { + + protected static connection: Knex = 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, + multipleStatements: true + }, + }); +} \ No newline at end of file diff --git a/modulo5/criptografia-e-user-roles/src/index.ts b/modulo5/criptografia-e-user-roles/src/index.ts new file mode 100644 index 0000000..cb4fc5e --- /dev/null +++ b/modulo5/criptografia-e-user-roles/src/index.ts @@ -0,0 +1,17 @@ +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}`); + } else { + console.error(`Failure upon starting server.`); + } +}) \ No newline at end of file diff --git a/modulo5/criptografia-e-user-roles/tsconfig.json b/modulo5/criptografia-e-user-roles/tsconfig.json new file mode 100644 index 0000000..3b3fa40 --- /dev/null +++ b/modulo5/criptografia-e-user-roles/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