Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
consola.info(`Connecting to redis://${settings.host}:${settings.port}/${settings.db.db}...`)
const _connect = () => {
const client = redis.createClient(settings)
client.get = promisify(client.get).bind(client)
client.set = promisify(client.set).bind(client)
client.getJSON = getJSON.bind(client)
client.setJSON = setJSON.bind(client)
return client
}
const db = _connect()
// db.on('error', errorCallback)
consola.info(`Connected to ${settings.host} database`)
consola.info('backend', `$${backend}`)
this.nuxt[`$${backend}`] = db
}
export const buildApp = async (buildCommands: string[]) => {
for (let i = 0; i < buildCommands.length; ++i) {
const command = buildCommands[i];
const parsedCommand = command.split(/\s/);
const commandName = parsedCommand.shift();
if (typeof commandName !== 'string' || commandName.length === 0) {
consola.info(`Skip build command: \`${command}\`, index: ${i}`);
continue;
}
await spawn(commandName, parsedCommand);
}
};
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();
process.on('SIGINT', () => {
consola.info('Generating report...');
});
detectModernBuild () {
const { options, resources } = this.serverContext
if ([false, 'client', 'server'].includes(options.modern)) {
return
}
if (!resources.modernManifest) {
options.modern = false
return
}
options.modern = options.render.ssr ? 'server' : 'client'
consola.info(`Modern bundles are detected. Modern mode (\`${options.modern}\`) is enabled now.`)
}