Skip to content

Commit ff537cd

Browse files
committed
Adicionando o banco de dados
1 parent 7d01c79 commit ff537cd

File tree

7 files changed

+306
-8
lines changed

7 files changed

+306
-8
lines changed

package-lock.json

Lines changed: 249 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
"devDependencies": {
1515
"@types/express": "^4.17.13",
1616
"@types/node": "^17.0.7",
17+
"@types/pg": "^8.6.4",
1718
"ts-node-dev": "^1.1.8",
1819
"typescript": "^4.5.4"
1920
},
2021
"dependencies": {
2122
"express": "^4.17.2",
2223
"http-status-code": "^2.1.0",
23-
"http-status-codes": "^2.2.0"
24+
"http-status-codes": "^2.2.0",
25+
"pg": "^8.7.1"
2426
}
2527
}

sql/init.sql

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
2+
CREATE EXTENSION IF NOT EXISTS "pgcrypto";
3+
4+
CREATE TABLE IF NOT EXISTS aplication_user (
5+
uuid uuid DEFAULT uuid_generate_v4(),
6+
username VARCHAR NOT NULL,
7+
password VARCHAR NOT NULL,
8+
primary key (uuid)
9+
)
10+
11+
INSERT INTO aplication_user (username, password) VALUES ('joice', crypt('admin', 'my_salt'))

src/db.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { Pool } from "pg";
2+
3+
4+
const connectionString = 'postgres://ubjpeufw:[email protected]/ubjpeufw'
5+
const db = new Pool({connectionString});
6+
7+
8+
9+
export default db;

0 commit comments

Comments
 (0)