Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
🐛 Fix degredation, return single entity for POST
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiasrohmer committed Jul 7, 2021
1 parent f43f434 commit 22646ef
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/Helpers/Managers/BaseManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export class BaseManager {

public ctx: HttpContextContract;

public method: string;

public language: string;

public validators: Validators;
Expand All @@ -68,6 +70,7 @@ export class BaseManager {

this.ctx = ctx;
this.language = ctx.language as string;
this.method = this.ctx.request.method();
}

public query(options: { sort?: string; includes?: string; filter?: string }) {
Expand Down Expand Up @@ -197,8 +200,7 @@ export class BaseManager {
}

public fromContext() {
const method = this.ctx.request.method();
switch (method) {
switch (this.method) {
case 'POST':
return this.create();
case 'PATCH':
Expand Down Expand Up @@ -281,7 +283,10 @@ export class BaseManager {
return [];
}

if (this.instances.length === 1 && this.ctx.params.id) {
if (
this.instances.length === 1 &&
(this.ctx.params.id || this.method == 'POST')
) {
return this.$toResource(this.instances[0]);
}

Expand Down

0 comments on commit 22646ef

Please sign in to comment.