How to use @awaitjs/express - 4 common examples

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,
github blockstack / radiks-server / app / controllers / CentralController.js View on Github external
module.exports = (radiksCollection, centralCollection) => {
  const CentralController = decorateApp(express.Router());
  CentralController.use(bodyParser.json());

  CentralController.postAsync('/', async (req, res) => {
    const {
      key, value, signature, username,
    } = req.body;

    const { publicKey } = await radiksCollection.findOne({ username, radiksType: 'BlockstackUser' });
    const _id = `${username}-${key}`;
    if (verifyECDSA(_id, publicKey, signature)) {
      await centralCollection.updateOne({ _id }, { $set: value }, { upsert: true });
      return res.json({
        success: true,
      });
    }
    return res.status(400).json({
github blockstack-radiks / banter / server / ApiController.js View on Github external
const makeApiController = (db) => {
  const Router = decorateApp(express.Router());
  const radiksData = db.collection(COLLECTION);

  Router.getAsync('/messages', async (req, res) => {
    let messages = await aggregateMessages(radiksData, req.query);

    let username = req.query.fetcher || req.universalCookies.get('username');
    if (username) username = username.replace(/"/g, '');
    messages = transformMessageVotes(messages, username);

    res.json({ messages });
  });

  Router.getAsync('/avatar/:username', async (req, res) => {
    const { username } = req.params;
    const user = await radiksData.findOne({ _id: username });
    if (!user) {
github ntheile / blockusign / Blockusign.Radik / ApiController.js View on Github external
const makeApiController = (db) => {
  const Router = decorateApp(express.Router());
  const radiksData = db.collection(COLLECTION);

  Router.getAsync('/messages', async (req, res) => {
    let messages = await aggregateMessages(radiksData, req.query);

   
    let username = (req.query.fetcher || req.universalCookies.get('username'));
    if (username) username = username.replace(/"/g, '');
    messages = await transformMessageVotes(messages, username);
 
    res.json({ messages });
  });

  Router.getAsync('/avatar/:username', async (req, res) => {
    const { username } = req.params;
    const user = await radiksData.findOne({ _id: username });

@awaitjs/express

Write Express middleware and route handlers using async/await

Apache-2.0
Latest version published 2 years ago

Package Health Score

48 / 100
Full package analysis

Similar packages