• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript v4.v4函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中uuid/v4.v4函数的典型用法代码示例。如果您正苦于以下问题:TypeScript v4函数的具体用法?TypeScript v4怎么用?TypeScript v4使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了v4函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: createVideoChannel

async function createVideoChannel (videoChannelInfo: VideoChannelCreate, account: AccountModel, t: Sequelize.Transaction) {
  const uuid = uuidv4()
  const url = getVideoChannelActivityPubUrl(uuid)
  // We use the name as uuid
  const actorInstance = buildActorInstance('Group', url, uuid, uuid)

  const actorInstanceCreated = await actorInstance.save({ transaction: t })

  const videoChannelData = {
    name: videoChannelInfo.displayName,
    description: videoChannelInfo.description,
    support: videoChannelInfo.support,
    accountId: account.id,
    actorId: actorInstanceCreated.id
  }

  const videoChannel = VideoChannelModel.build(videoChannelData)

  const options = { transaction: t }
  const videoChannelCreated = await videoChannel.save(options)

  // Do not forget to add Account/Actor information to the created video channel
  videoChannelCreated.Account = account
  videoChannelCreated.Actor = actorInstanceCreated

  // No need to seed this empty video channel to followers
  return videoChannelCreated
}
开发者ID:jiang263,项目名称:PeerTube,代码行数:28,代码来源:video-channel.ts


示例2: function

 router.put('/upload/', function (req, res) {
     let body = req.body;
     if (!body || !body.Filename || !body.Size) {
         return res.send({ Success: false, Error: 'No filename!' });
     }
     let fileid = uuidv4();
     pool.getConnection((err, conn) => {
         if (err) {
             console.log(err);
             return res.status(500).send({Error: 'Could not establish connection to database'});
         } else {
             let q = 'Insert into `filemetadata` (`FileID`, `Filename`, `Owner`, `Size`) VALUES (?, ?, ?, ?);';
             let args = [fileid, body.Filename, res.locals.user.ID, body.Size];
             conn.query(q, args, (qerr, result) => {
                 conn.release();
                 if (qerr) {
                     console.log('Error saving file metadata', qerr);
                     return res.status(500).send({ Error: 'Internal Server Error' });
                 }
                 console.log('Beginning upload of', body.Filename);
                 return res.send({ EndpointID: fileid });
             });
         }
     });
 });
开发者ID:TetuSecurity,项目名称:Crypt,代码行数:25,代码来源:files.ts


示例3: updateMyAvatar

async function updateMyAvatar (req: express.Request, res: express.Response, next: express.NextFunction) {
  const avatarPhysicalFile = req.files['avatarfile'][0]
  const user = res.locals.oauth.token.user
  const actor = user.Account.Actor

  const extension = extname(avatarPhysicalFile.filename)
  const avatarName = uuidv4() + extension
  const destination = join(CONFIG.STORAGE.AVATARS_DIR, avatarName)
  await processImage(avatarPhysicalFile, destination, AVATARS_SIZE)

  const avatar = await sequelizeTypescript.transaction(async t => {
    const updatedActor = await updateActorAvatarInstance(actor, avatarName, t)
    await updatedActor.save({ transaction: t })

    await sendUpdateActor(user.Account, t)

    return updatedActor.Avatar
  })

  return res
    .json({
      avatar: avatar.toFormattedJSON()
    })
    .end()
}
开发者ID:quoidautre,项目名称:PeerTube,代码行数:25,代码来源:users.ts


示例4: Error

 return db.findOne({ email, password }).then((user) => {
   if (!user) {
     throw Error("Could not authorize");
   }
   user.token = uuidv4();
   return user.save();
 });
开发者ID:racketometer,项目名称:backend-application,代码行数:7,代码来源:authorize.ts


示例5: authToken

router.post("/edit_user", async ctx => {
  await authToken(ctx, true);
  const {
    uid,
    email,
    note,
    enabled,
    isAdmin,
    isEmailVerified,
    regenerate,
  } = ctx.request.body;
  if (!uid) {
    return raiseApiError(400, "请求格式错误");
  }
  const user = await getRepository(User).findOneById(uid);
  if (!user) {
    return raiseApiError(404, "用户不存在");
  }
  user.email = email || user.email;
  user.note = note || user.note;
  user.enabled = enabled;
  user.isAdmin = isAdmin;
  user.isEmailVerified = isEmailVerified;
  if (regenerate) {
    user.setConnPassword();
    await user.allocConnPort();
    user.vmessUid = uuid();
  }
  await getRepository(User).save(user);
  await writeServerConfig();
  ctx.body = { message: "操作成功" };
});
开发者ID:coderfox,项目名称:Another-SS-Panel,代码行数:32,代码来源:api.ts


示例6: mixin

export function mixin(mixinClass) {
  Object.defineProperty(mixinClass, 'name', {
    value: uuid(),
  });
  Injectable()(mixinClass);
  return mixinClass;
}
开发者ID:SARAVANA1501,项目名称:nest,代码行数:7,代码来源:component.decorator.ts


示例7: generateEmptyPokemon

export function generateEmptyPokemon(pokemon?: Pokemon[]): Pokemon {
    let position: number = 0;
    if (pokemon && pokemon.length > 0) {
        try {
            position = parseInt(pokemon.sort(sortPokes)[pokemon.length - 1].position as any) + 1;
        } catch (e) {
            console.error('Attempted to generate position, but failed.', e);
        }
    }
    const genStatus = () => {
        if (pokemon && pokemon.filter(poke => poke.status === 'Team').length >= 6) return 'Boxed';
        return 'Team';
    };
    return {
        id: uuid(),
        position: position,
        species: '',
        nickname: '',
        status: genStatus(),
        gender: 'genderless',
        level: undefined,
        met: '',
        metLevel: undefined,
        nature: 'None',
        ability: '',
        types: [Types.Normal, Types.Normal],
        egg: false,
    };
}
开发者ID:EmmaRamirez,项目名称:nuzlocke-generator,代码行数:29,代码来源:generateEmptyPokemon.ts


示例8: saveUser

export async function saveUser(req: Request, res: Response, next: NextFunction): Promise<any> {
  let body: User = snakeCase(req.body);
  body.id = uuid();
  
  return await Account
  .findOne({ where: {email: body.email} })
  .then(async account => validateAndCreateUser(body, account, res))
  .catch(err => next(err));
}
开发者ID:KShewengerz,项目名称:ngx-express-passport-setup,代码行数:9,代码来源:user.ts


示例9: constructor

    // CONSTRUCTOR
    // --------------------------------------------------------------------------------------------
    constructor(name: string, tasks: boolean, notices: boolean) {
        this.id = uuid();
        this.name = name;
        this.startTs = Date.now();

        this.tasks = tasks ? [] : undefined;
        this.notices = notices ? [] : undefined;
        this.deferred = [];
    }
开发者ID:herculesinc,项目名称:nova-base,代码行数:11,代码来源:Operation.ts


示例10: uuid

        source.sensors.reduce((acc, sensor) => {
          const id = uuid()
          ids.push(id)

          const sensorWithId = {
            ...sensor,
            visible: true,
            source: source.id,
            id
          }

          return { ...acc, [id]: sensorWithId }
        }, {})
开发者ID:KHP-Informatics,项目名称:RADAR-frontend,代码行数:13,代码来源:sensors.reducer.ts



注:本文中的uuid/v4.v4函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript dom.getRect函数代码示例发布时间:2022-05-25
下一篇:
TypeScript v4.default函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap