How to use the @awaitjs/express.addAsync function in @awaitjs/express

To help you get started, we’ve selected a few @awaitjs/express 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 blockstack / radiks-server / src / controllers / ModelsController.ts View on Github external
const makeModelsController = (
  radiksCollection: Collection,
  config: Config,
  emitter: EventEmitter
) => {
  const ModelsController = addAsync(express.Router());
  ModelsController.use(bodyParser.json());

  ModelsController.postAsync('/crawl', async (req, res) => {
    const { gaiaURL } = req.body;
    const attrs = await request({
      uri: gaiaURL,
      json: true,
    });
    const validator = new Validator(radiksCollection, attrs);
    try {
      await validator.validate();
      await radiksCollection.save(attrs);
      emitter.emit(constants.STREAM_CRAWL_EVENT, [attrs]);

      res.json({
        success: true,

@awaitjs/express

Write Express middleware and route handlers using async/await

Apache-2.0
Latest version published 3 years ago

Package Health Score

48 / 100
Full package analysis