UNPKG

797 Btext/coffeescriptView Raw
1'use strict'
2
3fs = require 'fs'
4path = require 'path'
5restify = require 'restify'
6
7create = (config) ->
8 files = config.files or []
9 checkDirPath = path.resolve __dirname, './templates/check.tpl'
10 port = 4321
11 server = restify.createServer
12 name: 'check server'
13 version: '0.0.1'
14 server.get '/', (req, res, next) ->
15 html = fs.readFileSync checkDirPath, 'utf-8'
16 res.write html
17 res.end()
18 next()
19 server.get '/schemas', (req, res, next) ->
20 result = {}
21 files.forEach (file) ->
22 filePath = path.resolve process.cwd(), "./schema/#{file}"
23 result[file] = require filePath
24 res.send result
25 server.listen port, ->
26 console.info "############# \n check server #{server.name} listening at #{port} ... \n#############"
27
28module.exports =
29 create: create