Skip to content

Commit

Permalink
Merge pull request #39 from ElectroAAC/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
WalistonBelles authored May 22, 2022
2 parents f48014c + 6a121aa commit 587a4ff
Show file tree
Hide file tree
Showing 191 changed files with 3,268 additions and 523 deletions.
85 changes: 49 additions & 36 deletions backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ $ npm run build
$ npm run start
```

## 🕵🏾‍♂️ Routes Authorization (Login/Logout)

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :------------------------- | :------------------------------------ |
| POST | /auth | Login |
| DELETE | /auth | Logout |


<br>

## 🕵🏾‍♂️ Routes News

| METHOD | ENDPOINT | DESCRIPTION |
Expand Down Expand Up @@ -61,16 +71,6 @@ $ npm run start
| POST | /player/change-name | Change character name |
| POST | /player/delete | Delete character |

<br>

## 🕵🏾‍♂️ Routes Authorization (Login/Logout)

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :------------------------- | :------------------------------------ |
| POST | /auth | Login |
| DELETE | /auth | Logout |


<br>

## 🕵🏾‍♂️ Routes Highscores
Expand Down Expand Up @@ -100,38 +100,32 @@ $ npm run start

## 🕵🏾‍♂️ Routes Guilds

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :------------------------- | :------------------------------------ |
| GET | /guilds/:page/:limit | Get all guilds |
| GET | /guild/view/:name | Get guild info |
| GET | /guild/players-without-guild| Get guild info |
| POST | /guild/create-guild | Create Guild |
| POST | /guild/invite | Invite character |
| POST | /guild/invites | Get all invites |
| POST | /guild/accept-invite | Accept invite character |
| POST | /guild/cancel-invite | Cancel invite character |
| POST | /guild/leave | Leave guild |
| POST | /guild/pass-leadership | Pass Leadership |
| POST | /guild/change-motd | Change Motd |
| POST | /guild/change-rank | Change Rank of Member |
| POST | /guild/change-description | Change Description |
| POST | /guild/delete | Delete Guild |
| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :----------------------------| :------------------------------------ |
| GET | /guilds/:page/:limit | Get all guilds |
| GET | /guild/view/:name | Get guild info |
| GET | /guild/players-without-guild | Get guild info |
| POST | /guild/create-guild | Create Guild |
| POST | /guild/invite | Invite character |
| POST | /guild/invites | Get all invites |
| POST | /guild/accept-invite | Accept invite character |
| POST | /guild/cancel-invite | Cancel invite character |
| POST | /guild/leave | Leave guild |
| POST | /guild/pass-leadership | Pass Leadership |
| POST | /guild/change-motd | Change Motd |
| POST | /guild/change-rank | Change Rank of Member |
| POST | /guild/change-description | Change Description |
| POST | /guild/delete | Delete Guild |

<br>

## 🕵🏾‍♂️ Routes Shop

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :-------------------------------| :------------------------------------ |
| GET | /shop/category/list | Get all categories |
| POST | /shop/category/create | Create new category |
| PUT | /shop/category/update | Update category |
| DELETE | /shop/category/destroy/:id | Delete category |
| GET | /shop/item/list | Get all items |
| POST | /shop/item/create | Create new offer item |
| PUT | /shop/item/update | Update offer item |
| DELETE | /shop/item/destroy/:id | Delete offer item |
| POST | //shop/purchase | Purchase Items |
| GET | /shop/offers/:categorie | Get offers |
| GET | /shop/categories/:page/:limit | Get categories |
| POST | /shop/purchase | Purchase Items |

<br>

Expand Down Expand Up @@ -165,11 +159,30 @@ $ npm run start
| POST | /dashboard/character | Update character |
| POST | /dashboard/character-skills | Update characterSkills |

<br>

## 🕵🏾‍♂️ Routes Dashboard - News

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :-------------------------------| :------------------------------------ |
| GET | /news/listDashboard/:page/:limit| Get news to Dashboard |
| POST | /news/create | Create new post |
| GET | /news/find/:id | Find post |
| PATCH | /news/edit | Update post |
| PATCH | /news/edit | Update post |

<br>

## 🕵🏾‍♂️ Routes Dashboard - Shop

| METHOD | ENDPOINT | DESCRIPTION |
| :----- | :-------------------------------| :------------------------------------ |
| GET | /shop/category/list | Get all categories |
| POST | /shop/category/create | Create new category |
| GET | /shop/category/find:id | Find category |
| PUT | /shop/category/update | Update category |
| DELETE | /shop/category/destroy/:id | Delete category |
| GET | /shop/item/list | Get all items |
| POST | /shop/item/create | Create new offer item |
| GET | /shop/item/find:id | Find offer item |
| PUT | /shop/item/update | Update offer item |
| DELETE | /shop/item/destroy/:id | Delete offer item |
2 changes: 1 addition & 1 deletion backend/app/Controllers/Dashboard/News.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
import { StoreValidator, UpdateValidator } from 'App/Validators/News'
import { NewsRepository, NewsView } from 'App/Services';

export default class AccountsController {
export default class NewsController {
public newsView: NewsView = new NewsView();
public newsRepository: NewsRepository = new NewsRepository();

Expand Down
22 changes: 19 additions & 3 deletions backend/app/Controllers/Dashboard/ShopCategory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
import { StoreValidator, UpdateValidator } from 'App/Validators/Shop/Category'
import { ShopCategoryView, ShopCategoryRepository } from 'App/Services';

export default class AccountsController {
export default class ShopCategoryController {
public categoryView: ShopCategoryView = new ShopCategoryView();
public categoryRepository: ShopCategoryRepository = new ShopCategoryRepository();

public async index(ctx: HttpContextContract) {
try {
const news = await this.categoryView.getCategories();
const categories = await this.categoryView.getCategories(ctx.request.param('page'), ctx.request.param('limit'));

return ctx.response.status(200).send({ status: 200, news });
return ctx.response.status(200).send({ status: 200, categories });
} catch(err) {
console.log('Error getCategories Query: ', err);
return ctx.response.status(400).send({ error: 'An error occurred, check the api console.'});
Expand Down Expand Up @@ -45,6 +45,22 @@ export default class AccountsController {
}
}

public async show(ctx: HttpContextContract) {
try {
await ctx.bouncer.with('DashboardPolicy').authorize('admin');

const category = await this.categoryView.getCategoryById(ctx.request.param('id'));

if (!category.length) {
return ctx.response.status(404).send({ message: 'Category not found.' });
}
return ctx.response.status(200).send({ status: 200, category });
} catch (err) {
console.log('Error getCategory Query: ', err);
return ctx.response.status(400).send({ error: 'An error occurred, check the api console.'});
}
}

public async update(ctx: HttpContextContract) {
try {
await ctx.bouncer.with('DashboardPolicy').authorize('admin');
Expand Down
22 changes: 19 additions & 3 deletions backend/app/Controllers/Dashboard/ShopItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
import { StoreValidator, UpdateValidator } from 'App/Validators/Shop/Item'
import { ShopItemRepository, ShopItemView} from 'App/Services';

export default class AccountsController {
export default class ShopItemController {
public shopItemView: ShopItemView = new ShopItemView();
public shopItemRepository: ShopItemRepository = new ShopItemRepository();

public async index(ctx: HttpContextContract) {
try {
const items = await this.shopItemView.getShopItems();
const items = await this.shopItemView.getOffers("", ctx.request.param('page'), ctx.request.param('limit'));

return ctx.response.status(200).send({ status: 200, items });
} catch(err) {
Expand Down Expand Up @@ -38,6 +38,22 @@ export default class AccountsController {
}
}

public async show(ctx: HttpContextContract) {
try {
await ctx.bouncer.with('DashboardPolicy').authorize('admin');

const item = await this.shopItemView.getOfferById(ctx.request.param('id'));

if (!item.length) {
return ctx.response.status(404).send({ message: 'Item not found.' });
}
return ctx.response.status(200).send({ status: 200, item });
} catch (err) {
console.log('Error getItem Query: ', err);
return ctx.response.status(400).send({ error: 'An error occurred, check the api console.'});
}
}

public async update(ctx: HttpContextContract) {
try {
await ctx.bouncer.with('DashboardPolicy').authorize('admin');
Expand All @@ -50,7 +66,7 @@ export default class AccountsController {
return ctx.response.unauthorized();
}

await this.shopItemRepository.update(data.offer_id, data);
await this.shopItemRepository.update(data.id, data);

return ctx.response.status(200).send({ status: 200, message: "Offer successfully updated." });
} catch (err) {
Expand Down
2 changes: 1 addition & 1 deletion backend/app/Controllers/Dashboard/Vocations.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
import { CharacterView } from 'App/Services';

export default class PremiumPointsController {
export default class VocationsController {
public characterView: CharacterView = new CharacterView();

public async show(ctx: HttpContextContract) {
Expand Down
19 changes: 19 additions & 0 deletions backend/app/Controllers/Shop/Categorie.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
import {
ShopCategoryView
} from 'App/Services'

export default class ShopController {
public shopCategory: ShopCategoryView = new ShopCategoryView();

public async show(ctx: HttpContextContract) {
try {
const categories = await this.shopCategory.getCategories();

return ctx.response.status(200).send({ result: categories});
} catch (err) {
console.log('Error getCategories: ', err);
return ctx.response.status(400).send({ message: 'Categories not found.'})
}
}
}
Loading

0 comments on commit 587a4ff

Please sign in to comment.