Conversation
I wanted to start a console with our app loaded for easier debugging of stuffs. To do this I need app to be available for export without starting the server. This commit moves the app definition into its own file which can be required separately
This is a command that will start a REPL. The app can be loaded into the
repl context with:
import('<path to app.js>')
| import sqlite from 'sqlite3' | ||
| import ejs from 'ejs' | ||
|
|
||
| const db = new sqlite.Database('../db.sqlite') |
There was a problem hiding this comment.
Codacy has a fix for the issue: Replace '../db.sqlite') with "../db.sqlite");
| const db = new sqlite.Database('../db.sqlite') | |
| const db = new sqlite.Database("../db.sqlite"); |
| }) | ||
|
|
||
| db.close() | ||
| app.db.close() |
There was a problem hiding this comment.
Codacy has a fix for the issue: Insert ;
| app.db.close() | |
| app.db.close(); |
| response.render('index') | ||
| }) | ||
|
|
||
| export default app |
There was a problem hiding this comment.
Codacy has a fix for the issue: Insert ;
| export default app | |
| export default app; |
|
|
||
| app.db = db | ||
|
|
||
| app.set('view engine', 'ejs') |
There was a problem hiding this comment.
Codacy has a fix for the issue: Replace 'view·engine',·'ejs') with "view·engine",·"ejs");
| app.set('view engine', 'ejs') | |
| app.set("view engine", "ejs"); |
|
|
||
| const app = express() | ||
|
|
||
| app.db = db |
There was a problem hiding this comment.
Codacy has a fix for the issue: Insert ;
| app.db = db | |
| app.db = db; |
| @@ -0,0 +1,6 @@ | |||
| import repl from 'repl' | |||
| import app from '../src/app.js' | |||
There was a problem hiding this comment.
Codacy has a fix for the issue: Replace '../src/app.js' with "../src/app.js";
| import app from '../src/app.js' | |
| import app from "../src/app.js"; |
| @@ -0,0 +1,18 @@ | |||
| import cors from 'express' | |||
| import express from 'express' | |||
There was a problem hiding this comment.
Codacy has a fix for the issue: Replace 'express' with "express";
| import express from 'express' | |
| import express from "express"; |
| @@ -0,0 +1,6 @@ | |||
| import repl from 'repl' | |||
There was a problem hiding this comment.
Codacy has a fix for the issue: Replace 'repl' with "repl";
| import repl from 'repl' | |
| import repl from "repl"; |
I wanted to start a console with our app loaded for easier debugging of
stuffs.
To do this I need app to be available for export without starting the
server.
The app can now be started in a repl consol locally with
yarn console.The app object is made available to the local context