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

TypeScript joi.number函数代码示例

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

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



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

示例1: getTasks

  public getTasks(): Hapi.IRouteAdditionalConfigurationOptions {
    return {
      handler: (request: Hapi.Request, reply: Hapi.IReply) => {
        var top = request.query.top;
        var skip = request.query.skip;

        this.taskRepository.find({}, top, skip).then((tasks: Array<ITask>) => {
          reply(tasks);
        }).catch((error) => {
          reply(Boom.badImplementation(error));
        });
      },
      tags: ['api', 'tasks'],
      description: 'Get all tasks.',
      validate: {
        query: {
          top: Joi.number().default(5),
          skip: Joi.number().default(0)
        }
      },
      plugins: {
        'hapi-swagger': {
          responses: {
            '200': {
              'description': 'Returned Tasks.',
              'schema': TaskModel.taskModel
            }
          }
        }
      }
    };
  }
开发者ID:divramod,项目名称:hapi-seed-advanced,代码行数:32,代码来源:taskController.ts


示例2: validateInput

  private validateInput(envConfig: EnvConfig): EnvConfig {
    const envVarsSchema: Joi.ObjectSchema = Joi.object({
      NODE_ENV: Joi.string()
        .valid(['development', 'production', 'test', 'provision'])
        .default('development'),
      PORT: Joi.number().default(3000),
      JWT_SECRET: Joi.string().required(),
      JWT_EXPIRE: Joi.number().default(3600 * 24 * 7),
      DB_TYPE: Joi.string().default('mysql'),
      DB_HOST: Joi.string().default('localhost'),
      DB_PORT: Joi.number().default(3306),
      DB_USERNAME: Joi.string().required(),
      DB_PASSWORD: Joi.string().required(),
      DB_DATABASE_NAME: Joi.string().required(),
    });

    const { error, value: validatedEnvConfig } = Joi.validate(
      envConfig,
      envVarsSchema,
    );
    if (error) {
      throw new Error(`Config validation error: ${error.message}`);
    }
    return validatedEnvConfig;
  }
开发者ID:CaptainShisha,项目名称:REST-API,代码行数:25,代码来源:config.service.ts


示例3: async

export const createGetAllRoute = (libs: UMServerLibs) => ({
  method: 'GET',
  path: '/api/uptime/pings',
  options: {
    validate: {
      query: Joi.object({
        dateRangeStart: Joi.number().required(),
        dateRangeEnd: Joi.number().required(),
        monitorId: Joi.string(),
        size: Joi.number(),
        sort: Joi.string(),
        status: Joi.string(),
      }),
    },
    tags: ['access:uptime'],
  },
  handler: async (request: any): Promise<PingResults> => {
    const { size, sort, dateRangeStart, dateRangeEnd, monitorId, status } = request.query;
    return await libs.pings.getAll(
      request,
      dateRangeStart,
      dateRangeEnd,
      monitorId,
      status,
      sort,
      size
    );
  },
});
开发者ID:,项目名称:,代码行数:29,代码来源:


示例4: saveDepartment

async function saveDepartment(req, res) {
    try {
        let data = req.body.department;

        let schema = {
            id: Joi.number(),
            name: Joi.string().required(),
            budget: Joi.number().required(),
            startDate: Joi.date().format(config.format.date),
            instructorId: Joi.number().required()
        };

        let result = null;

        let department = await helper.loadSchema(data, schema);

        if (department.id) {
            result = await departmentRepository.updateDepartment(department);
        } else {
            result = await departmentRepository.addDepartment(department);
        }

        department = await departmentRepository.getDepartmentById(result.id);

        return helper.sendData({data: department}, res);
    } catch (err) {
        helper.sendFailureMessage(err, res);
    }
}
开发者ID:Blocklevel,项目名称:contoso-express,代码行数:29,代码来源:departmentController.ts


示例5: saveCourse

async function saveCourse(req, res) {
    try {
        let courseData = req.body.course;

        let schema = {
            id: Joi.number(),
            number: Joi.number().required(),
            title: Joi.string().required(),
            credits: Joi.number().required(),
            departmentId: Joi.number().required()
        };

        let result = null;

        let course = await helper.loadSchema(courseData, schema);

        if (course.id) {
            result = await courseRepository.updateCourse(courseData);
        } else {
            result = await courseRepository.addCourse(courseData);
        }

        course = await courseRepository.getCourseById(result.id);

        return helper.sendData({data: course}, res);
    } catch (err) {
        helper.sendFailureMessage(err, res);
    }
}
开发者ID:Blocklevel,项目名称:contoso-express,代码行数:29,代码来源:courseController.ts


示例6: handler

export const createFindRoute = (prereqs: Prerequisites) => ({
  path: '/api/saved_objects/_find',
  method: 'GET',
  config: {
    pre: [prereqs.getSavedObjectsClient],
    validate: {
      query: Joi.object()
        .keys({
          per_page: Joi.number()
            .min(0)
            .default(20),
          page: Joi.number()
            .min(0)
            .default(1),
          type: Joi.array()
            .items(Joi.string())
            .single()
            .required(),
          search: Joi.string()
            .allow('')
            .optional(),
          default_search_operator: Joi.string()
            .valid('OR', 'AND')
            .default('OR'),
          search_fields: Joi.array()
            .items(Joi.string())
            .single(),
          sort_field: Joi.string(),
          has_reference: Joi.object()
            .keys({
              type: Joi.string().required(),
              id: Joi.string().required(),
            })
            .optional(),
          fields: Joi.array()
            .items(Joi.string())
            .single(),
        })
        .default(),
    },
    handler(request: FindRequest) {
      const query = request.query;
      return request.pre.savedObjectsClient.find({
        perPage: query.per_page,
        page: query.page,
        type: query.type,
        search: query.search,
        defaultSearchOperator: query.default_search_operator,
        searchFields: query.search_fields,
        sortField: query.sort_field,
        hasReference: query.has_reference,
        fields: query.fields,
      });
    },
  },
});
开发者ID:elastic,项目名称:kibana,代码行数:56,代码来源:find.ts


示例7: async

export const createTokensRoute = (libs: CMServerLibs) => ({
  method: 'POST',
  path: '/api/beats/enrollment_tokens',
  licenseRequired: REQUIRED_LICENSES,
  requiredRoles: ['beats_admin'],
  config: {
    validate: {
      payload: Joi.object({
        num_tokens: Joi.number()
          .optional()
          .default(DEFAULT_NUM_TOKENS)
          .min(1),
      }).allow(null),
    },
  },
  handler: async (request: FrameworkRequest) => {
    const numTokens = get(request, 'payload.num_tokens', DEFAULT_NUM_TOKENS);

    try {
      const tokens = await libs.tokens.createEnrollmentTokens(request.user, numTokens);
      return { tokens };
    } catch (err) {
      libs.framework.log(err.message);
      return Boom.internal();
    }
  },
});
开发者ID:gingerwizard,项目名称:kibana,代码行数:27,代码来源:create.ts


示例8: saveStudent

async function saveStudent(req, res) {
    try {
        let data = req.body.student;

        let schema = {
            id: Joi.number(),
            firstName: Joi.string().required(),
            lastName: Joi.string().required(),
            enrollmentDate: Joi.date()
        };

        let result = null;

        let student = await helper.loadSchema(data, schema);

        if (student.id) {
            result = await studentRepository.updateStudent(student);
        } else {
            result = await studentRepository.addStudent(student);
        }

        return helper.sendData({data: result}, res);
    } catch (err) {
        helper.sendFailureMessage(err, res);
    }
}
开发者ID:yegor-sytnyk,项目名称:contoso-express,代码行数:26,代码来源:studentController.ts


示例9: reply

export const createTokensRoute = (libs: CMServerLibs) => ({
  method: 'POST',
  path: '/api/beats/enrollment_tokens',
  licenseRequired: true,
  config: {
    validate: {
      payload: Joi.object({
        num_tokens: Joi.number()
          .optional()
          .default(DEFAULT_NUM_TOKENS)
          .min(1),
      }).allow(null),
    },
  },
  handler: async (request: FrameworkRequest, reply: any) => {
    const numTokens = get(request, 'payload.num_tokens', DEFAULT_NUM_TOKENS);

    try {
      const tokens = await libs.tokens.createEnrollmentTokens(request.user, numTokens);
      reply({ tokens });
    } catch (err) {
      // TODO move this to kibana route thing in adapter
      return reply(wrapEsError(err));
    }
  },
});
开发者ID:salihkardan,项目名称:kibana,代码行数:26,代码来源:create.ts


示例10: RecordsController

exports.register = (server: Server, options: any, next: Function) => {

    const controller = new RecordsController();

    server.dependency("hapi-mongodb", (server: Server, next: Function) => {

        controller.useDb(server.plugins["hapi-mongodb"].db);

        return next();
    });

    server.route({
        path: "/docs/{slug}/subdocs/{subdocId}/records/{recordId}",
        method: "GET",
        config: {
            description: "Get a record",
            notes: "Returns a record by the slug and subdocument id passed in the path",
            tags: ["api"],
            plugins: {
                "hapi-swagger": {
                    order: 3
                }
            },
            validate: {
                params: {
                    slug: Joi.string()
                        .required()
                        .description("the slug for the document"),
                    subdocId: Joi.number()
                        .required()
                        .description("the id for the subdocument"),
                    recordId: Joi.number()
                        .required()
                        .description("the id for the record"),
                }
            },
            pre: [
                { method: controller.getRecord, assign: "record" },
                { method: controller.getSerializedRecord, assign: "serialisedRecord" }
            ],
            handler: controller.sendRecord
        }
    });

    return next();
};
开发者ID:vandemataramlib,项目名称:vml,代码行数:46,代码来源:records.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript joi.object函数代码示例发布时间:2022-05-25
下一篇:
TypeScript joi.func函数代码示例发布时间: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