-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunch.js
47 lines (32 loc) · 892 Bytes
/
launch.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import requireDir from 'require-dir'
import fs from 'fs-extra'
import yaml from 'js-yaml'
import _ from 'lodash'
import * as client from './client'
import store from './store'
import * as net from './net'
(async()=>{try{
global.BEO = __dirname
global.CWD = process.cwd()
client.init()
global.$config = {
database: yaml.safeLoad(fs.readFileSync(`${CWD}/config/database.yml`, 'utf8'))
}
net.init()
await store.connect()
global.ActiveRecord = store.ActiveRecord
global.$model = requireDir(`${CWD}/model`)
for(let name in $model){
let model = $model[name]
if(model._isActiveRecord){
await store.wrap(model)
}
}
await $model.Post.find().fetch()
// setInterval(async()=>{
// await $model.User.create({'name': 'kid'})
// }, 1000)
}catch(e){
let msg = e instanceof Error ? e.stack : e
console.log(`\x1b[31m${msg}\x1b[0m`)
}})()