本文整理汇总了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;未经允许,请勿转载。 |
请发表评论