Skip to content

Refresh details #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 29, 2023
Merged
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
10 changes: 5 additions & 5 deletions .example.env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
DATABASE_PORT=5422
DATABASE_PORT=5433
DATABASE_HOST=localhost
DATABASE_NAME=hw_db
DATABASE_USER=hw_user
DATABASE_ACCESS_KEY=hw_password
JWT_SECRET=secret_secret
DATABASE_NAME=backend_hw_db
DATABASE_USER=a_user
DATABASE_ACCESS_KEY=a_password
JWT_SECRET=testing12345
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:14.21.1-buster-slim AS base
FROM node:20.9-buster-slim AS base

WORKDIR /app

Expand Down
2 changes: 1 addition & 1 deletion Task_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ _Congratulations! Not by hearsay, you already know about the Backend structure,

![Neo from the Matrix, seating near Oracle and saying: "Who needs documentation, I can read code"](https://i.ibb.co/cN2CmJx/meme1.jpg "Meme")

- Beside of invoking the tests, to figure out the existing business logic - the Postman [collection](https://github.com/BinaryStudioAcademy/lecture-starter-backend-structure/tree/main/postman) is here to help. Please feel free importing it into your own Postman to see the requests examples and playing with those requests during manual testing.
- Beside of invoking the tests, to figure out the existing business logic - the Postman [collection](https://github.com/BinaryStudioAcademy/lecture-starter-backend-structure/tree/main/postman) is here to help. Please feel free importing it (don't forget the postman env file) into your own Postman to see the requests examples and playing with those requests during manual testing.

Technologies:

Expand Down
2 changes: 1 addition & 1 deletion Task_UA.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ _Вітаю! Ти вже не з чуток знаєш про структуру

![Нео, з фільму Матриця, сидить біля Провидиці та каже: "Кому потрібна документація, коли вмієш читати код"](https://i.ibb.co/cN2CmJx/meme1.jpg "Мем")

- Окрім запуску автотестів, розібратись з бізнес-логікою тобі допоможе Postman [колекція](https://github.com/BinaryStudioAcademy/lecture-starter-backend-structure/tree/main/postman). Ти можеш імпортувати її до себе у Postman, щоб побачити приклади HTTP запитів та використовувати їх для мануального тестування.
- Окрім запуску автотестів, розібратись з бізнес-логікою тобі допоможе Postman [колекція](https://github.com/BinaryStudioAcademy/lecture-starter-backend-structure/tree/main/postman). Ти можеш імпортувати її (не забудь також postman env файл) до себе у Postman, щоб побачити приклади HTTP запитів та використовувати їх для мануального тестування.

Технології:

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ services:
volumes:
- './.docker_pgdata_test:/var/lib/postgresql/data'
ports:
- '5440:5432'
- '5444:5432'

hm_test:
build:
Expand Down
10 changes: 5 additions & 5 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ version: '3.8'
services:
hw_db:
image: postgres:12-alpine
container_name: hw_db
container_name: backend_hw_db
environment:
POSTGRES_DB: hw_db
POSTGRES_USER: hw_user
POSTGRES_PASSWORD: hw_password
POSTGRES_DB: backend_hw_db
POSTGRES_USER: a_user
POSTGRES_PASSWORD: a_password
volumes:
- './.docker_pgdata:/var/lib/postgresql/data'
ports:
- '5422:5432'
- '5433:5432'
18 changes: 11 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ var ee = require('events');
var dbConfig = require("./knexfile");
var app = express();

var port = 3000;
var port = 4000;

var statEmitter = new ee();
var stats = {
Expand Down Expand Up @@ -95,7 +95,7 @@ app.post("/users", (req, res) => {
});

app.put("/users/:id", (req, res) => {
let token = req.headers['authorization'];
let token = req.headers[`authorization`];
let tokenPayload;
if(!token) {
return res.status(401).send({ error: 'Not Authorized' });
Expand Down Expand Up @@ -151,7 +151,7 @@ app.post("/transactions", (req, res) => {
return;
};

let token = req.headers['authorization'];
let token = req.headers["authorization"];
if(!token) {
return res.status(401).send({ error: 'Not Authorized' });
}
Expand Down Expand Up @@ -218,7 +218,8 @@ app.post("/events", (req, res) => {
};

try {
let token = req.headers['authorization'];
var authKey = "authorization";
let token = req.headers[authKey];
if(!token) {
return res.status(401).send({ error: 'Not Authorized' });
}
Expand Down Expand Up @@ -296,7 +297,8 @@ app.post("/bets", (req, res) => {

let userId;
try {
let token = req.headers['authorization'];
var authorizationKey = 'authorization';
let token = req.headers[authorizationKey];
if(!token) {
return res.status(401).send({ error: 'Not Authorized' });
}
Expand Down Expand Up @@ -390,7 +392,8 @@ app.put("/events/:id", (req, res) => {
};

try {
let token = req.headers['authorization'];
var authorization = `authorization`;
let token = req.headers[authorization];
if(!token) {
return res.status(401).send({ error: 'Not Authorized' });
}
Expand Down Expand Up @@ -458,7 +461,8 @@ app.put("/events/:id", (req, res) => {

app.get("/stats", (req, res) => {
try {
let token = req.headers['authorization'];
var ak = 'authorization';
let token = req.headers[ak];
if(!token) {
return res.status(401).send({ error: 'Not Authorized' });
}
Expand Down
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@
"author": "",
"license": "ISC",
"dependencies": {
"dotenv": "10.0.0",
"express": "4.17.1",
"joi": "17.4.0",
"jsonwebtoken": "9.0.0",
"knex": "2.4.0",
"pg": "8.6.0"
"dotenv": "16.3.1",
"express": "4.18.2",
"joi": "17.11.0",
"jsonwebtoken": "9.0.2",
"knex": "3.0.1",
"pg": "8.11.3"
},
"devDependencies": {
"chai": "4.3.4",
"chai-http": "4.3.0",
"jest": "29.3.1",
"nodemon": "2.0.7"
"chai": "4.3.10",
"chai-http": "4.4.0",
"jest": "29.7.0",
"nodemon": "3.0.1"
},
"engines": {
"node": "14"
"node": "20"
}
}
Loading