How to use the @foal/core.HttpResponseNoContent function in @foal/core

To help you get started, we’ve selected a few @foal/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FoalTS / foal / samples / tutorials / 01-simple-todo-list / src / app / controllers / api.controller.ts View on Github external
async deleteTodo(ctx: Context) {
    // Get the todo with the id given in the URL if it exists.
    const todo = await getRepository(Todo).findOne({ id: +ctx.request.params.id });

    // Return a 404 Not Found response if no such todo exists.
    if (!todo) {
      return new HttpResponseNotFound();
    }

    // Remove the todo from the database.
    await getRepository(Todo).remove(todo);

    // Returns an successful empty response. The status is 204.
    return new HttpResponseNoContent();
  }
github FoalTS / foal / samples / tutorials / 02-multi-user-todo-list-mpa / src / app / controllers / api.controller.ts View on Github external
const todo = await getRepository(Todo).findOne({
      id: +ctx.request.params.id,
      // Do not return the todo if it does not belong to the current user.
      owner: ctx.user
    });

    // Return a 404 Not Found response if no such todo exists.
    if (!todo) {
      return new HttpResponseNotFound();
    }

    // Remove the todo from the database.
    await getRepository(Todo).remove(todo);

    // Returns an successful empty response. The status is 204.
    return new HttpResponseNoContent();
  }
github FoalTS / foal / packages / acceptance-tests / src / auth.typeorm.spec.ts View on Github external
async logout(ctx: Context) {
        const response = new HttpResponseNoContent();
        await this.store.destroy(ctx.session.sessionID);
        removeSessionCookie(response);
        return new HttpResponseNoContent();
      }
github FoalTS / foal / packages / acceptance-tests / src / auth.spec.ts View on Github external
logout(ctx: Context) {
        logOut(ctx);
        return new HttpResponseNoContent();
      }
github FoalTS / foal / packages / cli / src / generate / specs / rest-api / test-foo-bar.controller.current-dir.ts View on Github external
async deleteById(ctx: Context) {
    const testFooBar = await getRepository(TestFooBar).findOne(ctx.request.params.testFooBarId);

    if (!testFooBar) {
      return new HttpResponseNotFound();
    }

    await getRepository(TestFooBar).delete(ctx.request.params.testFooBarId);

    return new HttpResponseNoContent();
  }
github FoalTS / foal / packages / cli / src / generate / specs / rest-api / test-foo-bar.controller.ts View on Github external
async deleteById(ctx: Context) {
    const testFooBar = await getRepository(TestFooBar).findOne(ctx.request.params.testFooBarId);

    if (!testFooBar) {
      return new HttpResponseNotFound();
    }

    await getRepository(TestFooBar).delete(ctx.request.params.testFooBarId);

    return new HttpResponseNoContent();
  }
github FoalTS / foal / packages / acceptance-tests / src / authentication / session-token.cookie.spec.ts View on Github external
async login(ctx: Context) {
      const user = await getRepository(User).findOne({ email: ctx.request.body.email });

      if (!user) {
        return new HttpResponseUnauthorized();
      }

      if (!await verifyPassword(ctx.request.body.password, user.password)) {
        return new HttpResponseUnauthorized();
      }

      const session = await this.store.createAndSaveSessionFromUser(user);
      const response = new HttpResponseNoContent();
      const token = session.getToken();
      setSessionCookie(response, token);
      return response;
    }
github FoalTS / foal / packages / acceptance-tests / src / authentication / session-token.cookie.spec.ts View on Github external
async logout(ctx: Context) {
      await this.store.destroy(ctx.session.sessionID);
      const response = new HttpResponseNoContent();
      removeSessionCookie(response);
      return response;
    }
  }
github FoalTS / foal / packages / examples / src / app / controllers / product.controller.ts View on Github external
async deleteById(ctx: Context) {
    const product = await getRepository(Product).findOne(ctx.request.params.id);

    if (!product) {
      return new HttpResponseNotFound();
    }

    await getRepository(Product).delete(ctx.request.params.id);

    return new HttpResponseNoContent();
  }