Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
status = await adminDB.command({replSetGetStatus:{}})
}
globals.db = globals.conn.db('accretion')
await mongoose.connect(`mongodb://${ip}:${port}/accretion`, { useNewUrlParser: true })
globals.history = globals.db.collection('History')
} catch (e) {
console.error(e)
let msg = 'Database connetion error, do you really start the mongodb using the configs/mongod.yml config file???'
consola.error(msg)
}
// clean database if test database and unittest
if (databaseName === "test") {
if (config.demoData || config.unittest) {
consola.ready({
message: `clean database`,
badge: true
})
let dropResult = await mongoose.connection.db.dropDatabase()
}
}
// if unittest, active all plugin by default
await initPlugins({allActive: databaseName === "test" && config.unittest})
initModels()
if (databaseName === "test") {
await initTestDatabase({config})
} else {
await initProductDatabase()
}
}
await builder.build()
} else {
await nuxt.ready()
}
const appConfig = await bootstrap.init()
app.get('/', faucetHandler(appConfig))
app.post('/claims', claimsHandler(appConfig))
// Give nuxt middleware to express
app.use(nuxt.render)
// Listen the server
app.listen(port, host)
consola.ready({
message: `Server listening on http://${host}:${port}`,
badge: true
})
const { API_URL, FAUCET_ACCOUNT } = appConfig
monitor(API_URL, FAUCET_ACCOUNT.address)
}
start()
multipart: true,
parsedMethods: ['POST', 'DELETE', 'PATCH']
}));
router.use('/api', api.routes(), api.allowedMethods())
app.use(router.routes()).use(router.allowedMethods())
app.use((ctx) => {
ctx.status = 200
ctx.respond = false // Bypass Koa's built-in response handling
ctx.req.ctx = ctx // This might be useful later on, e.g. in nuxtServerInit or with nuxt-stash
nuxt.render(ctx.req, ctx.res)
})
app.listen(port, host)
consola.ready({
message: `Server listening on http://${host}:${port}`,
badge: true
})
}
async function initTestDatabase ({config, databaseConfig}) {
if (config.demoData || config.unittest) {
consola.ready({
message: `clean database`,
badge: true
})
let dropResult = await mongoose.connection.db.dropDatabase()
}
await initIDs({config})
// create default user
let exist = await User.findOne({username: 'accretion'})
if (!exist) {
let user = new User({
username: 'accretion',
active: true,
})
await user.setPassword('cc')
await user.save()
}
host = process.env.HOST || '127.0.0.1',
port = process.env.PORT || 3000
} = nuxt.options.server
// Build only in dev mode
if (config.dev) {
const builder = new Builder(nuxt)
await builder.build()
}
// Give nuxt middleware to express
app.use(nuxt.render)
// Listen the server
app.listen(port, host)
consola.ready({
message: `Server listening on http://${host}:${port}`,
badge: true
})
}
start()
}
const server = micro(async (req, res) => {
await dispatch().dispatch('*', ['GET'], (req, res) =>
nuxt.render(req, res)
)(req, res)
})
const {
host = process.env.HOST || '127.0.0.1',
port = process.env.PORT || 3000
} = nuxt.options.server
// Listen the server
server.listen(port, host)
consola.ready({
message: `Server listening on http://${host}:${port}`,
badge: true
})
}
const { host, port } = nuxt.options.server;
// Build only in dev mode
if (config.dev) {
const builder = new Builder(nuxt);
await builder.build();
} else {
await nuxt.ready();
}
// Give nuxt middleware to express
app.use(nuxt.render);
// Listen the server
app.listen(port, host);
consola.ready({
message: `Server listening on http://${host}:${port}`,
badge: true
});
}
start();
if (config.dev) {
const builder = new Builder(nuxt)
await builder.build()
} else {
await nuxt.ready()
}
const configuration = require('@feathersjs/configuration')
app.configure(configuration()).use(nuxt.render)
const host = app.get('host')
const port = app.get('port')
app.listen(port)
consola.ready({
message: `Feathers application started on ${host}:${port}`,
badge: true
})
}
async function start() {
const nuxt = new Nuxt(config);
if (config.dev) {
const builder = new Builder(nuxt);
await builder.build();
}
app.use(nuxt.render);
app.listen(port, host);
consola.ready({
message: `Opa is now running on the address: http://${host}:${port}`,
badge: true
});
consola.info({
message: `BaseURL: ${BASE_URL !== undefined ? BASE_URL : '/'}`,
badge: true
});
}
start();