本文整理汇总了TypeScript中inflection.pluralize函数的典型用法代码示例。如果您正苦于以下问题:TypeScript pluralize函数的具体用法?TypeScript pluralize怎么用?TypeScript pluralize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pluralize函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
locals: function(options) {
return {
middlePath: `${inflector.pluralize(options.middlePath)}`,
projectName: `${options.project.name()}`,
entityName: `${options.entity.name}`
}
}
示例2: pluralize
export function pluralize(str: string): string {
return inflection.pluralize(str);
}
示例3: authRoutesFor
/**
* Generate any routes needed based on the facets applied to the given model.
*/
export default function authRoutesFor(modelName: string, router: Router, options: AuthRoutesOptions) {
options.except = options.except || [];
let Model = router.container.lookup(`model:${ modelName }`);
// Generate the root namespace for all the auth related routes we will be
// adding. Defaults to type/auth, so for the User model, it would be
// `users/auth/*`.
router.namespace(Model.authNamespace || `${ pluralize(modelName) }/auth`, (namespace) => {
// Registerable
// Adds routes that allow for users to register a new account
if (Model.isRegisterable) {
if (!options.except.includes('/register')) {
namespace.post('/register', 'auth/register', { modelName });
}
}
// Confirmable
// Adds routes that allow for users to confirm their email address
if (Model.isConfirmable) {
if (!options.except.includes('/confirm-email')) {
namespace.post('/confirm-email', 'auth/confirm-email', { modelName });
}
if (!options.except.includes('/resend-email-confirmation')) {
namespace.post('/resend-email-confirmation', 'auth/resend-email-confirmation', { modelName });
}
}
// Resetable
// Adds routes that allow users to reset their passwords
if (Model.isResetable) {
if (!options.except.includes('/reset-password')) {
namespace.post('/reset-password', 'auth/reset-password', { modelName });
}
if (!options.except.includes('/send-reset-password')) {
namespace.post('/send-reset-password', 'auth/send-reset-password', { modelName });
}
}
// Invitable
// Adds routes that allow users to reset their passwords
if (Model.isInvitable) {
if (!options.except.includes('/send-invitation')) {
namespace.post('/send-invitation', 'auth/send-invitation', { modelName });
}
}
// Oauthable
// Adds routes that allow users to login / register via OAuth providers
if (Model.isOauthable) {
if (!options.except.includes('/oauth')) {
namespace.post('/oauth/:provider', 'auth/oauth', { modelName });
}
}
// Fetchable
// Adds a route that allow users to fetch their own records when logged in
if (Model.isFetchable) {
if (!options.except.includes('/me')) {
namespace.get('/me', 'auth/fetch-user', { modelName });
}
}
// Authenticable
// Adds routes allowing users to authenticate and establish a session
if (Model.isAuthenticatable) {
if (!options.except.includes('/login')) {
namespace.post('/login', 'auth/login', { modelName });
}
if (!options.except.includes('/logout')) {
namespace.delete('/logout', 'auth/logout', { modelName });
}
}
});
}