|
1 | | -const Joi = require('joi') |
| 1 | +import Joi from 'joi' |
2 | 2 |
|
3 | | -const shared = require('./shared') |
| 3 | +import * as shared from './shared.js' |
4 | 4 |
|
5 | | -exports.id = shared.uint16.min(0) |
| 5 | +export const id = shared.uint16.min(0) |
6 | 6 |
|
7 | | -exports.name = Joi.string() |
| 7 | +export const name = Joi.string() |
8 | 8 | .min(2) |
9 | 9 | .max(127) |
10 | 10 | .domain({ allowFullyQualified: true, tlds: false }) |
11 | 11 | .pattern(/\.$/) |
12 | 12 |
|
13 | | -exports.type = Joi.string().valid('bind', 'djbdns', 'knot', 'nsd', 'maradns', 'powerdns', 'dynect') |
| 13 | +export const type = Joi.string().valid('bind', 'djbdns', 'knot', 'nsd', 'maradns', 'powerdns', 'dynect') |
14 | 14 |
|
15 | | -exports.remote_login = Joi.string().empty('').max(127) |
| 15 | +export const remote_login = Joi.string().empty('').max(127) |
16 | 16 |
|
17 | | -exports.v3 = Joi.object({ |
18 | | - id: exports.id, |
| 17 | +export const v3 = Joi.object({ |
| 18 | + id: id, |
19 | 19 | gid: shared.uint32.required(), |
20 | | - name: exports.name.required(), |
| 20 | + name: name.required(), |
21 | 21 | ttl: shared.ttl.required(), |
22 | 22 | description: Joi.string().empty('').max(255), |
23 | 23 | address: shared.ipv4.required(), |
24 | 24 | address6: shared.ipv6.empty(''), |
25 | | - remote_login: exports.remote_login, |
| 25 | + remote_login: remote_login, |
26 | 26 | logdir: Joi.string().empty('').max(255), |
27 | 27 | datadir: Joi.string().empty('').min(2).max(255), |
28 | 28 | export: Joi.object({ |
29 | 29 | interval: shared.uint16, |
30 | 30 | serials: Joi.boolean(), |
31 | 31 | status: Joi.string().empty('').max(255), |
32 | | - type: exports.type.required(), |
| 32 | + type: type.required(), |
33 | 33 | }), |
34 | 34 | deleted: Joi.boolean(), |
35 | 35 | }) |
36 | 36 |
|
37 | | -exports.GET_req = Joi.object({ |
38 | | - id: exports.id, |
39 | | - name: exports.name, |
| 37 | +export const GET_req = Joi.object({ |
| 38 | + id: id, |
| 39 | + name: name, |
40 | 40 | deleted: Joi.boolean(), |
41 | 41 | }) |
42 | 42 |
|
43 | | -exports.GET_res = Joi.object({ |
44 | | - nameserver: Joi.array().items(exports.v3), |
| 43 | +export const GET_res = Joi.object({ |
| 44 | + nameserver: Joi.array().items(v3), |
45 | 45 | meta: shared.meta, |
46 | 46 | }) |
47 | 47 |
|
48 | | -exports.POST = exports.v3 |
| 48 | +export const POST = v3 |
49 | 49 |
|
50 | | -exports.DELETE = Joi.object({ |
51 | | - id: exports.id, |
| 50 | +export const DELETE = Joi.object({ |
| 51 | + id: id, |
52 | 52 | deleted: Joi.boolean(), |
53 | 53 | }) |
0 commit comments