How to use the @foal/core.HttpResponseNotFound 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 / 03-mongodb-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 Todo.findById(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 Todo.findByIdAndRemove(ctx.request.params.id);

    // Returns an successful empty response. The status is 204.
    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 putById(ctx: Context) {
    const testFooBar = await getRepository(TestFooBar).findOne(ctx.request.params.testFooBarId);

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

    Object.assign(testFooBar, ctx.request.body);

    await getRepository(TestFooBar).save(testFooBar);

    return new HttpResponseOK(testFooBar);
  }
github FoalTS / foal / packages / acceptance-tests / src / examples / frontend-integration / single-page-applications.spec.ts View on Github external
renderApp(ctx: Context) {
        if (!ctx.request.accepts('html')) {
          return new HttpResponseNotFound();
        }

        return createHttpResponseFile({
          directory: './src/examples/frontend-integration/public',
          file: 'index.html'
        });
      }
    }
github FoalTS / foal / packages / cli / src / generate / specs / rest-api / test-foo-bar.controller.ts View on Github external
async putById(ctx: Context) {
    const testFooBar = await getRepository(TestFooBar).findOne(ctx.request.params.testFooBarId);

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

    Object.assign(testFooBar, ctx.request.body);

    await getRepository(TestFooBar).save(testFooBar);

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

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

    Object.assign(testFooBar, ctx.request.body);

    await getRepository(TestFooBar).save(testFooBar);

    return new HttpResponseOK(testFooBar);
  }
github FoalTS / foal / packages / acceptance-tests / src / examples / cookbook / 404-page.spec.ts View on Github external
notFound() {
      return new HttpResponseNotFound('The page your are looking for does not exist');
    }
  }
github FoalTS / foal / packages / cli / src / generate / specs / rest-api / test-foo-bar.controller.current-dir.ts View on Github external
async patchById(ctx: Context) {
    const testFooBar = await getRepository(TestFooBar).findOne(ctx.request.params.testFooBarId);

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

    Object.assign(testFooBar, ctx.request.body);

    await getRepository(TestFooBar).save(testFooBar);

    return new HttpResponseOK(testFooBar);
  }
github FoalTS / foal / packages / examples / src / app / controllers / product.controller.ts View on Github external
async patchById(ctx: Context) {
    const product = await getRepository(Product).findOne(ctx.request.params.id);

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

    Object.assign(product, ctx.request.body);

    await getRepository(Product).save(product);

    return new HttpResponseOK(product);
  }
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();
  }
github FoalTS / foal / packages / examples / src / app / controllers / product.controller.ts View on Github external
async putById(ctx: Context) {
    const product = await getRepository(Product).findOne(ctx.request.params.id);

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

    Object.assign(product, ctx.request.body);

    await getRepository(Product).save(product);

    return new HttpResponseOK(product);
  }